Fossil SCM

Update the built-in SQLite to the 3.8.8 alpha that includes the enhanced sqlite3_table_column_metadata() interface. Use that new interface to build new utility methods db_table_exists() and db_table_has_column() that work more efficiently than the older technique of querying the sqlite_master table.

drh 2014-12-10 14:16 trunk
Commit 1aa8067704fb1520d1328fc2176aec991dc2b9a4
+1 -2
--- src/checkout.c
+++ src/checkout.c
@@ -305,12 +305,11 @@
305305
306306
if( !forceFlag && unsaved_changes(0) ){
307307
fossil_fatal("there are unsaved changes in the current checkout");
308308
}
309309
if( !forceFlag
310
- && db_exists("SELECT 1 FROM %s.sqlite_master WHERE name='stash'",
311
- db_name("localdb"))
310
+ && db_table_exists("localdb","stash")
312311
&& db_exists("SELECT 1 FROM %s.stash", db_name("localdb"))
313312
){
314313
fossil_fatal("closing the checkout will delete your stash");
315314
}
316315
if( db_is_writeable("repository") ){
317316
--- src/checkout.c
+++ src/checkout.c
@@ -305,12 +305,11 @@
305
306 if( !forceFlag && unsaved_changes(0) ){
307 fossil_fatal("there are unsaved changes in the current checkout");
308 }
309 if( !forceFlag
310 && db_exists("SELECT 1 FROM %s.sqlite_master WHERE name='stash'",
311 db_name("localdb"))
312 && db_exists("SELECT 1 FROM %s.stash", db_name("localdb"))
313 ){
314 fossil_fatal("closing the checkout will delete your stash");
315 }
316 if( db_is_writeable("repository") ){
317
--- src/checkout.c
+++ src/checkout.c
@@ -305,12 +305,11 @@
305
306 if( !forceFlag && unsaved_changes(0) ){
307 fossil_fatal("there are unsaved changes in the current checkout");
308 }
309 if( !forceFlag
310 && db_table_exists("localdb","stash")
 
311 && db_exists("SELECT 1 FROM %s.stash", db_name("localdb"))
312 ){
313 fossil_fatal("closing the checkout will delete your stash");
314 }
315 if( db_is_writeable("repository") ){
316
+28 -32
--- src/db.c
+++ src/db.c
@@ -958,30 +958,47 @@
958958
g.zConfigDbType = "configdb";
959959
}
960960
g.zConfigDbName = zDbName;
961961
}
962962
963
+/*
964
+** Return TRUE if zTable exists.
965
+*/
966
+int db_table_exists(
967
+ const char *zDb, /* One of: NULL, "configdb", "localdb", "repository" */
968
+ const char *zTable /* Name of table */
969
+){
970
+ return sqlite3_table_column_metadata(g.db,
971
+ zDb ? db_name(zDb) : 0, zTable, 0,
972
+ 0, 0, 0, 0, 0)==SQLITE_OK;
973
+}
974
+
975
+/*
976
+** Return TRUE if zTable exists and contains column zColumn.
977
+** Return FALSE if zTable does not exist or if zTable exists
978
+** but lacks zColumn.
979
+*/
980
+int db_table_has_column(
981
+ const char *zDb, /* One of: NULL, "config", "localdb", "repository" */
982
+ const char *zTable, /* Name of table */
983
+ const char *zColumn /* Name of column in table */
984
+){
985
+ return sqlite3_table_column_metadata(g.db,
986
+ zDb ? db_name(zDb) : 0, zTable, zColumn,
987
+ 0, 0, 0, 0, 0)==SQLITE_OK;
988
+}
963989
964990
/*
965991
** Returns TRUE if zTable exists in the local database but lacks column
966992
** zColumn
967993
*/
968994
static int db_local_table_exists_but_lacks_column(
969995
const char *zTable,
970996
const char *zColumn
971997
){
972
- char *zDef = db_text(0, "SELECT sql FROM %s.sqlite_master"
973
- " WHERE name==%Q /*scan*/",
974
- db_name("localdb"), zTable);
975
- int rc = 0;
976
- if( zDef ){
977
- char *zPattern = mprintf("* %s *", zColumn);
978
- rc = sqlite3_strglob(zPattern, zDef)!=0;
979
- fossil_free(zPattern);
980
- fossil_free(zDef);
981
- }
982
- return rc;
998
+ return db_table_exists(db_name("localdb"), zTable)
999
+ && !db_table_has_column(db_name("localdb"), zTable, zColumn);
9831000
}
9841001
9851002
/*
9861003
** If zDbName is a valid local database file, open it and return
9871004
** true. If it is not a valid local database file, return 0.
@@ -2047,31 +2064,10 @@
20472064
}
20482065
void db_lset_int(const char *zName, int value){
20492066
db_multi_exec("REPLACE INTO vvar(name,value) VALUES(%Q,%d)", zName, value);
20502067
}
20512068
2052
-/*
2053
-** Returns non-0 if the database (which must be open) table identified
2054
-** by zTableName has a column named zColName (case-sensitive), else
2055
-** returns 0.
2056
-*/
2057
-int db_table_has_column(const char *zTableName, const char *zColName){
2058
- Stmt q = empty_Stmt;
2059
- int rc = 0;
2060
- db_prepare( &q, "PRAGMA table_info(%Q)", zTableName );
2061
- while(SQLITE_ROW == db_step(&q)){
2062
- /* Columns: (cid, name, type, notnull, dflt_value, pk) */
2063
- const char *zCol = db_column_text(&q, 1);
2064
- if( 0==fossil_strcmp(zColName, zCol) ){
2065
- rc = 1;
2066
- break;
2067
- }
2068
- }
2069
- db_finalize(&q);
2070
- return rc;
2071
-}
2072
-
20732069
/*
20742070
** Record the name of a local repository in the global_config() database.
20752071
** The repository filename %s is recorded as an entry with a "name" field
20762072
** of the following form:
20772073
**
20782074
--- src/db.c
+++ src/db.c
@@ -958,30 +958,47 @@
958 g.zConfigDbType = "configdb";
959 }
960 g.zConfigDbName = zDbName;
961 }
962
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
963
964 /*
965 ** Returns TRUE if zTable exists in the local database but lacks column
966 ** zColumn
967 */
968 static int db_local_table_exists_but_lacks_column(
969 const char *zTable,
970 const char *zColumn
971 ){
972 char *zDef = db_text(0, "SELECT sql FROM %s.sqlite_master"
973 " WHERE name==%Q /*scan*/",
974 db_name("localdb"), zTable);
975 int rc = 0;
976 if( zDef ){
977 char *zPattern = mprintf("* %s *", zColumn);
978 rc = sqlite3_strglob(zPattern, zDef)!=0;
979 fossil_free(zPattern);
980 fossil_free(zDef);
981 }
982 return rc;
983 }
984
985 /*
986 ** If zDbName is a valid local database file, open it and return
987 ** true. If it is not a valid local database file, return 0.
@@ -2047,31 +2064,10 @@
2047 }
2048 void db_lset_int(const char *zName, int value){
2049 db_multi_exec("REPLACE INTO vvar(name,value) VALUES(%Q,%d)", zName, value);
2050 }
2051
2052 /*
2053 ** Returns non-0 if the database (which must be open) table identified
2054 ** by zTableName has a column named zColName (case-sensitive), else
2055 ** returns 0.
2056 */
2057 int db_table_has_column(const char *zTableName, const char *zColName){
2058 Stmt q = empty_Stmt;
2059 int rc = 0;
2060 db_prepare( &q, "PRAGMA table_info(%Q)", zTableName );
2061 while(SQLITE_ROW == db_step(&q)){
2062 /* Columns: (cid, name, type, notnull, dflt_value, pk) */
2063 const char *zCol = db_column_text(&q, 1);
2064 if( 0==fossil_strcmp(zColName, zCol) ){
2065 rc = 1;
2066 break;
2067 }
2068 }
2069 db_finalize(&q);
2070 return rc;
2071 }
2072
2073 /*
2074 ** Record the name of a local repository in the global_config() database.
2075 ** The repository filename %s is recorded as an entry with a "name" field
2076 ** of the following form:
2077 **
2078
--- src/db.c
+++ src/db.c
@@ -958,30 +958,47 @@
958 g.zConfigDbType = "configdb";
959 }
960 g.zConfigDbName = zDbName;
961 }
962
963 /*
964 ** Return TRUE if zTable exists.
965 */
966 int db_table_exists(
967 const char *zDb, /* One of: NULL, "configdb", "localdb", "repository" */
968 const char *zTable /* Name of table */
969 ){
970 return sqlite3_table_column_metadata(g.db,
971 zDb ? db_name(zDb) : 0, zTable, 0,
972 0, 0, 0, 0, 0)==SQLITE_OK;
973 }
974
975 /*
976 ** Return TRUE if zTable exists and contains column zColumn.
977 ** Return FALSE if zTable does not exist or if zTable exists
978 ** but lacks zColumn.
979 */
980 int db_table_has_column(
981 const char *zDb, /* One of: NULL, "config", "localdb", "repository" */
982 const char *zTable, /* Name of table */
983 const char *zColumn /* Name of column in table */
984 ){
985 return sqlite3_table_column_metadata(g.db,
986 zDb ? db_name(zDb) : 0, zTable, zColumn,
987 0, 0, 0, 0, 0)==SQLITE_OK;
988 }
989
990 /*
991 ** Returns TRUE if zTable exists in the local database but lacks column
992 ** zColumn
993 */
994 static int db_local_table_exists_but_lacks_column(
995 const char *zTable,
996 const char *zColumn
997 ){
998 return db_table_exists(db_name("localdb"), zTable)
999 && !db_table_has_column(db_name("localdb"), zTable, zColumn);
 
 
 
 
 
 
 
 
 
1000 }
1001
1002 /*
1003 ** If zDbName is a valid local database file, open it and return
1004 ** true. If it is not a valid local database file, return 0.
@@ -2047,31 +2064,10 @@
2064 }
2065 void db_lset_int(const char *zName, int value){
2066 db_multi_exec("REPLACE INTO vvar(name,value) VALUES(%Q,%d)", zName, value);
2067 }
2068
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2069 /*
2070 ** Record the name of a local repository in the global_config() database.
2071 ** The repository filename %s is recorded as an entry with a "name" field
2072 ** of the following form:
2073 **
2074
+1 -1
--- src/info.c
+++ src/info.c
@@ -1919,11 +1919,11 @@
19191919
}
19201920
if( strcmp(zModAction,"approve")==0 ){
19211921
moderation_approve(rid);
19221922
}
19231923
}
1924
- zTktTitle = db_table_has_column( "ticket", "title" )
1924
+ zTktTitle = db_table_has_column("repository", "ticket", "title" )
19251925
? db_text("(No title)", "SELECT title FROM ticket WHERE tkt_uuid=%Q", zTktName)
19261926
: 0;
19271927
style_header("Ticket Change Details");
19281928
style_submenu_element("Raw", "Raw", "%R/artifact/%s", zUuid);
19291929
style_submenu_element("History", "History", "%R/tkthistory/%s", zTktName);
19301930
--- src/info.c
+++ src/info.c
@@ -1919,11 +1919,11 @@
1919 }
1920 if( strcmp(zModAction,"approve")==0 ){
1921 moderation_approve(rid);
1922 }
1923 }
1924 zTktTitle = db_table_has_column( "ticket", "title" )
1925 ? db_text("(No title)", "SELECT title FROM ticket WHERE tkt_uuid=%Q", zTktName)
1926 : 0;
1927 style_header("Ticket Change Details");
1928 style_submenu_element("Raw", "Raw", "%R/artifact/%s", zUuid);
1929 style_submenu_element("History", "History", "%R/tkthistory/%s", zTktName);
1930
--- src/info.c
+++ src/info.c
@@ -1919,11 +1919,11 @@
1919 }
1920 if( strcmp(zModAction,"approve")==0 ){
1921 moderation_approve(rid);
1922 }
1923 }
1924 zTktTitle = db_table_has_column("repository", "ticket", "title" )
1925 ? db_text("(No title)", "SELECT title FROM ticket WHERE tkt_uuid=%Q", zTktName)
1926 : 0;
1927 style_header("Ticket Change Details");
1928 style_submenu_element("Raw", "Raw", "%R/artifact/%s", zUuid);
1929 style_submenu_element("History", "History", "%R/tkthistory/%s", zTktName);
1930
+1 -6
--- src/moderate.c
+++ src/moderate.c
@@ -38,16 +38,11 @@
3838
3939
/*
4040
** Return TRUE if the modreq table exists
4141
*/
4242
int moderation_table_exists(void){
43
- static int modreqExists = -1;
44
- if( modreqExists<0 ){
45
- modreqExists = db_exists("SELECT 1 FROM %s.sqlite_master /*scan*/"
46
- " WHERE name='modreq'", db_name("repository"));
47
- }
48
- return modreqExists;
43
+ return db_table_exists("repository", "modreq");
4944
}
5045
5146
/*
5247
** Return TRUE if the object specified is being held for moderation.
5348
*/
5449
--- src/moderate.c
+++ src/moderate.c
@@ -38,16 +38,11 @@
38
39 /*
40 ** Return TRUE if the modreq table exists
41 */
42 int moderation_table_exists(void){
43 static int modreqExists = -1;
44 if( modreqExists<0 ){
45 modreqExists = db_exists("SELECT 1 FROM %s.sqlite_master /*scan*/"
46 " WHERE name='modreq'", db_name("repository"));
47 }
48 return modreqExists;
49 }
50
51 /*
52 ** Return TRUE if the object specified is being held for moderation.
53 */
54
--- src/moderate.c
+++ src/moderate.c
@@ -38,16 +38,11 @@
38
39 /*
40 ** Return TRUE if the modreq table exists
41 */
42 int moderation_table_exists(void){
43 return db_table_exists("repository", "modreq");
 
 
 
 
 
44 }
45
46 /*
47 ** Return TRUE if the object specified is being held for moderation.
48 */
49
+2 -3
--- src/purge.c
+++ src/purge.c
@@ -205,12 +205,11 @@
205205
** are about to be deleted or otherwise made inaccessible. This routine
206206
** is checking to ensure that purging the checkins in zTab will not delete
207207
** a baseline manifest out from under a delta.
208208
*/
209209
int purge_baseline_out_from_under_delta(const char *zTab){
210
- if( !db_exists("SELECT 1 FROM %s.sqlite_master WHERE name='plink'"
211
- " AND sql GLOB '* baseid *'", db_name("repository")) ){
210
+ if( !db_table_has_column("repository","plink","baseid") ){
212211
/* Skip this check if the current database is an older schema that
213212
** does not contain the PLINK.BASEID field. */
214213
return 0;
215214
}else{
216215
return db_int(0,
@@ -492,11 +491,11 @@
492491
}
493492
/* The "checkins" subcommand goes here in alphabetical order, but it must
494493
** be moved to the end since it is the default case */
495494
}else if( strncmp(zSubcmd, "list", n)==0 || strcmp(zSubcmd,"ls")==0 ){
496495
int showDetail = find_option("l","l",0)!=0;
497
- if( db_int(-1,"PRAGMA table_info('purgeevent')")<0 ) return;
496
+ if( !db_table_exists("repository","purgeevent") ) return;
498497
db_prepare(&q, "SELECT peid, datetime(ctime,'unixepoch','localtime')"
499498
" FROM purgeevent");
500499
while( db_step(&q)==SQLITE_ROW ){
501500
fossil_print("%4d on %s\n", db_column_int(&q,0), db_column_text(&q,1));
502501
if( showDetail ){
503502
--- src/purge.c
+++ src/purge.c
@@ -205,12 +205,11 @@
205 ** are about to be deleted or otherwise made inaccessible. This routine
206 ** is checking to ensure that purging the checkins in zTab will not delete
207 ** a baseline manifest out from under a delta.
208 */
209 int purge_baseline_out_from_under_delta(const char *zTab){
210 if( !db_exists("SELECT 1 FROM %s.sqlite_master WHERE name='plink'"
211 " AND sql GLOB '* baseid *'", db_name("repository")) ){
212 /* Skip this check if the current database is an older schema that
213 ** does not contain the PLINK.BASEID field. */
214 return 0;
215 }else{
216 return db_int(0,
@@ -492,11 +491,11 @@
492 }
493 /* The "checkins" subcommand goes here in alphabetical order, but it must
494 ** be moved to the end since it is the default case */
495 }else if( strncmp(zSubcmd, "list", n)==0 || strcmp(zSubcmd,"ls")==0 ){
496 int showDetail = find_option("l","l",0)!=0;
497 if( db_int(-1,"PRAGMA table_info('purgeevent')")<0 ) return;
498 db_prepare(&q, "SELECT peid, datetime(ctime,'unixepoch','localtime')"
499 " FROM purgeevent");
500 while( db_step(&q)==SQLITE_ROW ){
501 fossil_print("%4d on %s\n", db_column_int(&q,0), db_column_text(&q,1));
502 if( showDetail ){
503
--- src/purge.c
+++ src/purge.c
@@ -205,12 +205,11 @@
205 ** are about to be deleted or otherwise made inaccessible. This routine
206 ** is checking to ensure that purging the checkins in zTab will not delete
207 ** a baseline manifest out from under a delta.
208 */
209 int purge_baseline_out_from_under_delta(const char *zTab){
210 if( !db_table_has_column("repository","plink","baseid") ){
 
211 /* Skip this check if the current database is an older schema that
212 ** does not contain the PLINK.BASEID field. */
213 return 0;
214 }else{
215 return db_int(0,
@@ -492,11 +491,11 @@
491 }
492 /* The "checkins" subcommand goes here in alphabetical order, but it must
493 ** be moved to the end since it is the default case */
494 }else if( strncmp(zSubcmd, "list", n)==0 || strcmp(zSubcmd,"ls")==0 ){
495 int showDetail = find_option("l","l",0)!=0;
496 if( !db_table_exists("repository","purgeevent") ) return;
497 db_prepare(&q, "SELECT peid, datetime(ctime,'unixepoch','localtime')"
498 " FROM purgeevent");
499 while( db_step(&q)==SQLITE_ROW ){
500 fossil_print("%4d on %s\n", db_column_int(&q,0), db_column_text(&q,1));
501 if( showDetail ){
502
+45 -33
--- src/sqlite3.c
+++ src/sqlite3.c
@@ -231,11 +231,11 @@
231231
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
232232
** [sqlite_version()] and [sqlite_source_id()].
233233
*/
234234
#define SQLITE_VERSION "3.8.8"
235235
#define SQLITE_VERSION_NUMBER 3008008
236
-#define SQLITE_SOURCE_ID "2014-12-06 14:56:49 6aeece19a235344be2537e66a3fe08b1febfb5a0"
236
+#define SQLITE_SOURCE_ID "2014-12-10 04:58:43 3528f8dd39acace8eeb7337994c8617313f4b04b"
237237
238238
/*
239239
** CAPI3REF: Run-Time Library Version Numbers
240240
** KEYWORDS: sqlite3_version, sqlite3_sourceid
241241
**
@@ -5279,24 +5279,31 @@
52795279
52805280
52815281
/*
52825282
** CAPI3REF: Extract Metadata About A Column Of A Table
52835283
**
5284
-** ^This routine returns metadata about a specific column of a specific
5285
-** database table accessible using the [database connection] handle
5286
-** passed as the first function argument.
5284
+** ^(The sqlite3_table_column_metadata(X,D,T,C,....) routine returns
5285
+** information about column C of table T in database D
5286
+** on [database connection] X.)^ ^The sqlite3_table_column_metadata()
5287
+** interface returns SQLITE_OK and fills in the non-NULL pointers in
5288
+** the final five arguments with appropriate values if the specified
5289
+** column exists. ^The sqlite3_table_column_metadata() interface returns
5290
+** SQLITE_ERROR and if the specified column does not exist.
5291
+** ^If the column-name parameter to sqlite3_table_column_metadata() is a
5292
+** NULL pointer, then this routine simply checks for the existance of the
5293
+** table and returns SQLITE_OK if the table exists and SQLITE_ERROR if it
5294
+** does not.
52875295
**
52885296
** ^The column is identified by the second, third and fourth parameters to
5289
-** this function. ^The second parameter is either the name of the database
5297
+** this function. ^(The second parameter is either the name of the database
52905298
** (i.e. "main", "temp", or an attached database) containing the specified
5291
-** table or NULL. ^If it is NULL, then all attached databases are searched
5299
+** table or NULL.)^ ^If it is NULL, then all attached databases are searched
52925300
** for the table using the same algorithm used by the database engine to
52935301
** resolve unqualified table references.
52945302
**
52955303
** ^The third and fourth parameters to this function are the table and column
5296
-** name of the desired column, respectively. Neither of these parameters
5297
-** may be NULL.
5304
+** name of the desired column, respectively.
52985305
**
52995306
** ^Metadata is returned by writing to the memory locations passed as the 5th
53005307
** and subsequent parameters to this function. ^Any of these arguments may be
53015308
** NULL, in which case the corresponding element of metadata is omitted.
53025309
**
@@ -5311,36 +5318,33 @@
53115318
** <tr><td> 9th <td> int <td> True if column is [AUTOINCREMENT]
53125319
** </table>
53135320
** </blockquote>)^
53145321
**
53155322
** ^The memory pointed to by the character pointers returned for the
5316
-** declaration type and collation sequence is valid only until the next
5323
+** declaration type and collation sequence is valid until the next
53175324
** call to any SQLite API function.
53185325
**
53195326
** ^If the specified table is actually a view, an [error code] is returned.
53205327
**
5321
-** ^If the specified column is "rowid", "oid" or "_rowid_" and an
5328
+** ^If the specified column is "rowid", "oid" or "_rowid_" and the table
5329
+** is not a [WITHOUT ROWID] table and an
53225330
** [INTEGER PRIMARY KEY] column has been explicitly declared, then the output
53235331
** parameters are set for the explicitly declared column. ^(If there is no
5324
-** explicitly declared [INTEGER PRIMARY KEY] column, then the output
5325
-** parameters are set as follows:
5332
+** [INTEGER PRIMARY KEY] column, then the outputs
5333
+** for the [rowid] are set as follows:
53265334
**
53275335
** <pre>
53285336
** data type: "INTEGER"
53295337
** collation sequence: "BINARY"
53305338
** not null: 0
53315339
** primary key: 1
53325340
** auto increment: 0
53335341
** </pre>)^
53345342
**
5335
-** ^(This function may load one or more schemas from database files. If an
5336
-** error occurs during this process, or if the requested table or column
5337
-** cannot be found, an [error code] is returned and an error message left
5338
-** in the [database connection] (to be retrieved using sqlite3_errmsg()).)^
5339
-**
5340
-** ^This API is only available if the library was compiled with the
5341
-** [SQLITE_ENABLE_COLUMN_METADATA] C-preprocessor symbol defined.
5343
+** ^This function causes all database schemas to be read from disk and
5344
+** parsed, if that has not already been done, and returns an error if
5345
+** any errors are encountered while loading the schema.
53425346
*/
53435347
SQLITE_API int sqlite3_table_column_metadata(
53445348
sqlite3 *db, /* Connection handle */
53455349
const char *zDbName, /* Database name or NULL */
53465350
const char *zTableName, /* Table name */
@@ -59329,11 +59333,11 @@
5932959333
+ nMaxCells*sizeof(u16) /* szCell */
5933059334
+ pBt->pageSize; /* aSpace1 */
5933159335
5933259336
/* EVIDENCE-OF: R-28375-38319 SQLite will never request a scratch buffer
5933359337
** that is more than 6 times the database page size. */
59334
- assert( szScratch<=6*pBt->pageSize );
59338
+ assert( szScratch<=6*(int)pBt->pageSize );
5933559339
apCell = sqlite3ScratchMalloc( szScratch );
5933659340
if( apCell==0 ){
5933759341
rc = SQLITE_NOMEM;
5933859342
goto balance_cleanup;
5933959343
}
@@ -77429,11 +77433,13 @@
7742977433
*/
7743077434
#define SRVAL(p) ((void*)((SorterRecord*)(p) + 1))
7743177435
7743277436
/* The minimum PMA size is set to this value multiplied by the database
7743377437
** page size in bytes. */
77434
-#define SORTER_MIN_WORKING 10
77438
+#ifndef SQLITE_SORTER_PMASZ
77439
+# define SQLITE_SORTER_PMASZ 10
77440
+#endif
7743577441
7743677442
/* Maximum number of PMAs that a single MergeEngine can merge */
7743777443
#define SORTER_MAX_MERGE_COUNT 16
7743877444
7743977445
static int vdbeIncrSwap(IncrMerger*);
@@ -77828,13 +77834,13 @@
7782877834
SortSubtask *pTask = &pSorter->aTask[i];
7782977835
pTask->pSorter = pSorter;
7783077836
}
7783177837
7783277838
if( !sqlite3TempInMemory(db) ){
77833
- pSorter->mnPmaSize = SORTER_MIN_WORKING * pgsz;
77839
+ pSorter->mnPmaSize = SQLITE_SORTER_PMASZ * pgsz;
7783477840
mxCache = db->aDb[0].pSchema->cache_size;
77835
- if( mxCache<SORTER_MIN_WORKING ) mxCache = SORTER_MIN_WORKING;
77841
+ if( mxCache<SQLITE_SORTER_PMASZ ) mxCache = SQLITE_SORTER_PMASZ;
7783677842
pSorter->mxPmaSize = MIN((i64)mxCache*pgsz, SQLITE_MAX_MXPMASIZE);
7783777843
7783877844
/* EVIDENCE-OF: R-26747-61719 When the application provides any amount of
7783977845
** scratch memory using SQLITE_CONFIG_SCRATCH, SQLite avoids unnecessary
7784077846
** large heap allocations.
@@ -101080,11 +101086,10 @@
101080101086
# define sqlite3_column_database_name16 0
101081101087
# define sqlite3_column_table_name 0
101082101088
# define sqlite3_column_table_name16 0
101083101089
# define sqlite3_column_origin_name 0
101084101090
# define sqlite3_column_origin_name16 0
101085
-# define sqlite3_table_column_metadata 0
101086101091
#endif
101087101092
101088101093
#ifdef SQLITE_OMIT_AUTHORIZATION
101089101094
# define sqlite3_set_authorizer 0
101090101095
#endif
@@ -127175,15 +127180,17 @@
127175127180
for(j=0; j<db->nDb; j++){
127176127181
struct Db *pDb = &db->aDb[j];
127177127182
if( pDb->pBt ){
127178127183
if( pDb->pSchema ){
127179127184
/* Must clear the KeyInfo cache. See ticket [e4a18565a36884b00edf] */
127185
+ sqlite3BtreeEnter(pDb->pBt);
127180127186
for(i=sqliteHashFirst(&pDb->pSchema->idxHash); i; i=sqliteHashNext(i)){
127181127187
Index *pIdx = sqliteHashData(i);
127182127188
sqlite3KeyInfoUnref(pIdx->pKeyInfo);
127183127189
pIdx->pKeyInfo = 0;
127184127190
}
127191
+ sqlite3BtreeLeave(pDb->pBt);
127185127192
}
127186127193
sqlite3BtreeClose(pDb->pBt);
127187127194
pDb->pBt = 0;
127188127195
if( j!=1 ){
127189127196
pDb->pSchema = 0;
@@ -128882,10 +128889,13 @@
128882128889
| SQLITE_RecTriggers
128883128890
#endif
128884128891
#if defined(SQLITE_DEFAULT_FOREIGN_KEYS) && SQLITE_DEFAULT_FOREIGN_KEYS
128885128892
| SQLITE_ForeignKeys
128886128893
#endif
128894
+#if defined(SQLITE_REVERSE_UNORDERED_SELECTS)
128895
+ | SQLITE_ReverseOrder
128896
+#endif
128887128897
;
128888128898
sqlite3HashInit(&db->aCollSeq);
128889128899
#ifndef SQLITE_OMIT_VIRTUALTABLE
128890128900
sqlite3HashInit(&db->aModule);
128891128901
#endif
@@ -128929,11 +128939,13 @@
128929128939
rc = SQLITE_NOMEM;
128930128940
}
128931128941
sqlite3Error(db, rc);
128932128942
goto opendb_out;
128933128943
}
128944
+ sqlite3BtreeEnter(db->aDb[0].pBt);
128934128945
db->aDb[0].pSchema = sqlite3SchemaGet(db, db->aDb[0].pBt);
128946
+ sqlite3BtreeLeave(db->aDb[0].pBt);
128935128947
db->aDb[1].pSchema = sqlite3SchemaGet(db, 0);
128936128948
128937128949
/* The default safety_level for the main database is 'full'; for the temp
128938128950
** database it is 'NONE'. This matches the pager layer defaults.
128939128951
*/
@@ -129283,11 +129295,10 @@
129283129295
129284129296
/*
129285129297
** Return meta information about a specific column of a database table.
129286129298
** See comment in sqlite3.h (sqlite.h.in) for details.
129287129299
*/
129288
-#ifdef SQLITE_ENABLE_COLUMN_METADATA
129289129300
SQLITE_API int sqlite3_table_column_metadata(
129290129301
sqlite3 *db, /* Connection handle */
129291129302
const char *zDbName, /* Database name or NULL */
129292129303
const char *zTableName, /* Table name */
129293129304
const char *zColumnName, /* Column name */
@@ -129323,25 +129334,27 @@
129323129334
pTab = 0;
129324129335
goto error_out;
129325129336
}
129326129337
129327129338
/* Find the column for which info is requested */
129328
- if( sqlite3IsRowid(zColumnName) ){
129329
- iCol = pTab->iPKey;
129330
- if( iCol>=0 ){
129331
- pCol = &pTab->aCol[iCol];
129332
- }
129339
+ if( zColumnName==0 ){
129340
+ /* Query for existance of table only */
129333129341
}else{
129334129342
for(iCol=0; iCol<pTab->nCol; iCol++){
129335129343
pCol = &pTab->aCol[iCol];
129336129344
if( 0==sqlite3StrICmp(pCol->zName, zColumnName) ){
129337129345
break;
129338129346
}
129339129347
}
129340129348
if( iCol==pTab->nCol ){
129341
- pTab = 0;
129342
- goto error_out;
129349
+ if( HasRowid(pTab) && sqlite3IsRowid(zColumnName) ){
129350
+ iCol = pTab->iPKey;
129351
+ pCol = iCol>=0 ? &pTab->aCol[iCol] : 0;
129352
+ }else{
129353
+ pTab = 0;
129354
+ goto error_out;
129355
+ }
129343129356
}
129344129357
}
129345129358
129346129359
/* The following block stores the meta information that will be returned
129347129360
** to the caller in local variables zDataType, zCollSeq, notnull, primarykey
@@ -129390,11 +129403,10 @@
129390129403
sqlite3DbFree(db, zErrMsg);
129391129404
rc = sqlite3ApiExit(db, rc);
129392129405
sqlite3_mutex_leave(db->mutex);
129393129406
return rc;
129394129407
}
129395
-#endif
129396129408
129397129409
/*
129398129410
** Sleep for a little while. Return the amount of time slept.
129399129411
*/
129400129412
SQLITE_API int sqlite3_sleep(int ms){
129401129413
--- src/sqlite3.c
+++ src/sqlite3.c
@@ -231,11 +231,11 @@
231 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
232 ** [sqlite_version()] and [sqlite_source_id()].
233 */
234 #define SQLITE_VERSION "3.8.8"
235 #define SQLITE_VERSION_NUMBER 3008008
236 #define SQLITE_SOURCE_ID "2014-12-06 14:56:49 6aeece19a235344be2537e66a3fe08b1febfb5a0"
237
238 /*
239 ** CAPI3REF: Run-Time Library Version Numbers
240 ** KEYWORDS: sqlite3_version, sqlite3_sourceid
241 **
@@ -5279,24 +5279,31 @@
5279
5280
5281 /*
5282 ** CAPI3REF: Extract Metadata About A Column Of A Table
5283 **
5284 ** ^This routine returns metadata about a specific column of a specific
5285 ** database table accessible using the [database connection] handle
5286 ** passed as the first function argument.
 
 
 
 
 
 
 
 
5287 **
5288 ** ^The column is identified by the second, third and fourth parameters to
5289 ** this function. ^The second parameter is either the name of the database
5290 ** (i.e. "main", "temp", or an attached database) containing the specified
5291 ** table or NULL. ^If it is NULL, then all attached databases are searched
5292 ** for the table using the same algorithm used by the database engine to
5293 ** resolve unqualified table references.
5294 **
5295 ** ^The third and fourth parameters to this function are the table and column
5296 ** name of the desired column, respectively. Neither of these parameters
5297 ** may be NULL.
5298 **
5299 ** ^Metadata is returned by writing to the memory locations passed as the 5th
5300 ** and subsequent parameters to this function. ^Any of these arguments may be
5301 ** NULL, in which case the corresponding element of metadata is omitted.
5302 **
@@ -5311,36 +5318,33 @@
5311 ** <tr><td> 9th <td> int <td> True if column is [AUTOINCREMENT]
5312 ** </table>
5313 ** </blockquote>)^
5314 **
5315 ** ^The memory pointed to by the character pointers returned for the
5316 ** declaration type and collation sequence is valid only until the next
5317 ** call to any SQLite API function.
5318 **
5319 ** ^If the specified table is actually a view, an [error code] is returned.
5320 **
5321 ** ^If the specified column is "rowid", "oid" or "_rowid_" and an
 
5322 ** [INTEGER PRIMARY KEY] column has been explicitly declared, then the output
5323 ** parameters are set for the explicitly declared column. ^(If there is no
5324 ** explicitly declared [INTEGER PRIMARY KEY] column, then the output
5325 ** parameters are set as follows:
5326 **
5327 ** <pre>
5328 ** data type: "INTEGER"
5329 ** collation sequence: "BINARY"
5330 ** not null: 0
5331 ** primary key: 1
5332 ** auto increment: 0
5333 ** </pre>)^
5334 **
5335 ** ^(This function may load one or more schemas from database files. If an
5336 ** error occurs during this process, or if the requested table or column
5337 ** cannot be found, an [error code] is returned and an error message left
5338 ** in the [database connection] (to be retrieved using sqlite3_errmsg()).)^
5339 **
5340 ** ^This API is only available if the library was compiled with the
5341 ** [SQLITE_ENABLE_COLUMN_METADATA] C-preprocessor symbol defined.
5342 */
5343 SQLITE_API int sqlite3_table_column_metadata(
5344 sqlite3 *db, /* Connection handle */
5345 const char *zDbName, /* Database name or NULL */
5346 const char *zTableName, /* Table name */
@@ -59329,11 +59333,11 @@
59329 + nMaxCells*sizeof(u16) /* szCell */
59330 + pBt->pageSize; /* aSpace1 */
59331
59332 /* EVIDENCE-OF: R-28375-38319 SQLite will never request a scratch buffer
59333 ** that is more than 6 times the database page size. */
59334 assert( szScratch<=6*pBt->pageSize );
59335 apCell = sqlite3ScratchMalloc( szScratch );
59336 if( apCell==0 ){
59337 rc = SQLITE_NOMEM;
59338 goto balance_cleanup;
59339 }
@@ -77429,11 +77433,13 @@
77429 */
77430 #define SRVAL(p) ((void*)((SorterRecord*)(p) + 1))
77431
77432 /* The minimum PMA size is set to this value multiplied by the database
77433 ** page size in bytes. */
77434 #define SORTER_MIN_WORKING 10
 
 
77435
77436 /* Maximum number of PMAs that a single MergeEngine can merge */
77437 #define SORTER_MAX_MERGE_COUNT 16
77438
77439 static int vdbeIncrSwap(IncrMerger*);
@@ -77828,13 +77834,13 @@
77828 SortSubtask *pTask = &pSorter->aTask[i];
77829 pTask->pSorter = pSorter;
77830 }
77831
77832 if( !sqlite3TempInMemory(db) ){
77833 pSorter->mnPmaSize = SORTER_MIN_WORKING * pgsz;
77834 mxCache = db->aDb[0].pSchema->cache_size;
77835 if( mxCache<SORTER_MIN_WORKING ) mxCache = SORTER_MIN_WORKING;
77836 pSorter->mxPmaSize = MIN((i64)mxCache*pgsz, SQLITE_MAX_MXPMASIZE);
77837
77838 /* EVIDENCE-OF: R-26747-61719 When the application provides any amount of
77839 ** scratch memory using SQLITE_CONFIG_SCRATCH, SQLite avoids unnecessary
77840 ** large heap allocations.
@@ -101080,11 +101086,10 @@
101080 # define sqlite3_column_database_name16 0
101081 # define sqlite3_column_table_name 0
101082 # define sqlite3_column_table_name16 0
101083 # define sqlite3_column_origin_name 0
101084 # define sqlite3_column_origin_name16 0
101085 # define sqlite3_table_column_metadata 0
101086 #endif
101087
101088 #ifdef SQLITE_OMIT_AUTHORIZATION
101089 # define sqlite3_set_authorizer 0
101090 #endif
@@ -127175,15 +127180,17 @@
127175 for(j=0; j<db->nDb; j++){
127176 struct Db *pDb = &db->aDb[j];
127177 if( pDb->pBt ){
127178 if( pDb->pSchema ){
127179 /* Must clear the KeyInfo cache. See ticket [e4a18565a36884b00edf] */
 
127180 for(i=sqliteHashFirst(&pDb->pSchema->idxHash); i; i=sqliteHashNext(i)){
127181 Index *pIdx = sqliteHashData(i);
127182 sqlite3KeyInfoUnref(pIdx->pKeyInfo);
127183 pIdx->pKeyInfo = 0;
127184 }
 
127185 }
127186 sqlite3BtreeClose(pDb->pBt);
127187 pDb->pBt = 0;
127188 if( j!=1 ){
127189 pDb->pSchema = 0;
@@ -128882,10 +128889,13 @@
128882 | SQLITE_RecTriggers
128883 #endif
128884 #if defined(SQLITE_DEFAULT_FOREIGN_KEYS) && SQLITE_DEFAULT_FOREIGN_KEYS
128885 | SQLITE_ForeignKeys
128886 #endif
 
 
 
128887 ;
128888 sqlite3HashInit(&db->aCollSeq);
128889 #ifndef SQLITE_OMIT_VIRTUALTABLE
128890 sqlite3HashInit(&db->aModule);
128891 #endif
@@ -128929,11 +128939,13 @@
128929 rc = SQLITE_NOMEM;
128930 }
128931 sqlite3Error(db, rc);
128932 goto opendb_out;
128933 }
 
128934 db->aDb[0].pSchema = sqlite3SchemaGet(db, db->aDb[0].pBt);
 
128935 db->aDb[1].pSchema = sqlite3SchemaGet(db, 0);
128936
128937 /* The default safety_level for the main database is 'full'; for the temp
128938 ** database it is 'NONE'. This matches the pager layer defaults.
128939 */
@@ -129283,11 +129295,10 @@
129283
129284 /*
129285 ** Return meta information about a specific column of a database table.
129286 ** See comment in sqlite3.h (sqlite.h.in) for details.
129287 */
129288 #ifdef SQLITE_ENABLE_COLUMN_METADATA
129289 SQLITE_API int sqlite3_table_column_metadata(
129290 sqlite3 *db, /* Connection handle */
129291 const char *zDbName, /* Database name or NULL */
129292 const char *zTableName, /* Table name */
129293 const char *zColumnName, /* Column name */
@@ -129323,25 +129334,27 @@
129323 pTab = 0;
129324 goto error_out;
129325 }
129326
129327 /* Find the column for which info is requested */
129328 if( sqlite3IsRowid(zColumnName) ){
129329 iCol = pTab->iPKey;
129330 if( iCol>=0 ){
129331 pCol = &pTab->aCol[iCol];
129332 }
129333 }else{
129334 for(iCol=0; iCol<pTab->nCol; iCol++){
129335 pCol = &pTab->aCol[iCol];
129336 if( 0==sqlite3StrICmp(pCol->zName, zColumnName) ){
129337 break;
129338 }
129339 }
129340 if( iCol==pTab->nCol ){
129341 pTab = 0;
129342 goto error_out;
 
 
 
 
 
129343 }
129344 }
129345
129346 /* The following block stores the meta information that will be returned
129347 ** to the caller in local variables zDataType, zCollSeq, notnull, primarykey
@@ -129390,11 +129403,10 @@
129390 sqlite3DbFree(db, zErrMsg);
129391 rc = sqlite3ApiExit(db, rc);
129392 sqlite3_mutex_leave(db->mutex);
129393 return rc;
129394 }
129395 #endif
129396
129397 /*
129398 ** Sleep for a little while. Return the amount of time slept.
129399 */
129400 SQLITE_API int sqlite3_sleep(int ms){
129401
--- src/sqlite3.c
+++ src/sqlite3.c
@@ -231,11 +231,11 @@
231 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
232 ** [sqlite_version()] and [sqlite_source_id()].
233 */
234 #define SQLITE_VERSION "3.8.8"
235 #define SQLITE_VERSION_NUMBER 3008008
236 #define SQLITE_SOURCE_ID "2014-12-10 04:58:43 3528f8dd39acace8eeb7337994c8617313f4b04b"
237
238 /*
239 ** CAPI3REF: Run-Time Library Version Numbers
240 ** KEYWORDS: sqlite3_version, sqlite3_sourceid
241 **
@@ -5279,24 +5279,31 @@
5279
5280
5281 /*
5282 ** CAPI3REF: Extract Metadata About A Column Of A Table
5283 **
5284 ** ^(The sqlite3_table_column_metadata(X,D,T,C,....) routine returns
5285 ** information about column C of table T in database D
5286 ** on [database connection] X.)^ ^The sqlite3_table_column_metadata()
5287 ** interface returns SQLITE_OK and fills in the non-NULL pointers in
5288 ** the final five arguments with appropriate values if the specified
5289 ** column exists. ^The sqlite3_table_column_metadata() interface returns
5290 ** SQLITE_ERROR and if the specified column does not exist.
5291 ** ^If the column-name parameter to sqlite3_table_column_metadata() is a
5292 ** NULL pointer, then this routine simply checks for the existance of the
5293 ** table and returns SQLITE_OK if the table exists and SQLITE_ERROR if it
5294 ** does not.
5295 **
5296 ** ^The column is identified by the second, third and fourth parameters to
5297 ** this function. ^(The second parameter is either the name of the database
5298 ** (i.e. "main", "temp", or an attached database) containing the specified
5299 ** table or NULL.)^ ^If it is NULL, then all attached databases are searched
5300 ** for the table using the same algorithm used by the database engine to
5301 ** resolve unqualified table references.
5302 **
5303 ** ^The third and fourth parameters to this function are the table and column
5304 ** name of the desired column, respectively.
 
5305 **
5306 ** ^Metadata is returned by writing to the memory locations passed as the 5th
5307 ** and subsequent parameters to this function. ^Any of these arguments may be
5308 ** NULL, in which case the corresponding element of metadata is omitted.
5309 **
@@ -5311,36 +5318,33 @@
5318 ** <tr><td> 9th <td> int <td> True if column is [AUTOINCREMENT]
5319 ** </table>
5320 ** </blockquote>)^
5321 **
5322 ** ^The memory pointed to by the character pointers returned for the
5323 ** declaration type and collation sequence is valid until the next
5324 ** call to any SQLite API function.
5325 **
5326 ** ^If the specified table is actually a view, an [error code] is returned.
5327 **
5328 ** ^If the specified column is "rowid", "oid" or "_rowid_" and the table
5329 ** is not a [WITHOUT ROWID] table and an
5330 ** [INTEGER PRIMARY KEY] column has been explicitly declared, then the output
5331 ** parameters are set for the explicitly declared column. ^(If there is no
5332 ** [INTEGER PRIMARY KEY] column, then the outputs
5333 ** for the [rowid] are set as follows:
5334 **
5335 ** <pre>
5336 ** data type: "INTEGER"
5337 ** collation sequence: "BINARY"
5338 ** not null: 0
5339 ** primary key: 1
5340 ** auto increment: 0
5341 ** </pre>)^
5342 **
5343 ** ^This function causes all database schemas to be read from disk and
5344 ** parsed, if that has not already been done, and returns an error if
5345 ** any errors are encountered while loading the schema.
 
 
 
 
5346 */
5347 SQLITE_API int sqlite3_table_column_metadata(
5348 sqlite3 *db, /* Connection handle */
5349 const char *zDbName, /* Database name or NULL */
5350 const char *zTableName, /* Table name */
@@ -59329,11 +59333,11 @@
59333 + nMaxCells*sizeof(u16) /* szCell */
59334 + pBt->pageSize; /* aSpace1 */
59335
59336 /* EVIDENCE-OF: R-28375-38319 SQLite will never request a scratch buffer
59337 ** that is more than 6 times the database page size. */
59338 assert( szScratch<=6*(int)pBt->pageSize );
59339 apCell = sqlite3ScratchMalloc( szScratch );
59340 if( apCell==0 ){
59341 rc = SQLITE_NOMEM;
59342 goto balance_cleanup;
59343 }
@@ -77429,11 +77433,13 @@
77433 */
77434 #define SRVAL(p) ((void*)((SorterRecord*)(p) + 1))
77435
77436 /* The minimum PMA size is set to this value multiplied by the database
77437 ** page size in bytes. */
77438 #ifndef SQLITE_SORTER_PMASZ
77439 # define SQLITE_SORTER_PMASZ 10
77440 #endif
77441
77442 /* Maximum number of PMAs that a single MergeEngine can merge */
77443 #define SORTER_MAX_MERGE_COUNT 16
77444
77445 static int vdbeIncrSwap(IncrMerger*);
@@ -77828,13 +77834,13 @@
77834 SortSubtask *pTask = &pSorter->aTask[i];
77835 pTask->pSorter = pSorter;
77836 }
77837
77838 if( !sqlite3TempInMemory(db) ){
77839 pSorter->mnPmaSize = SQLITE_SORTER_PMASZ * pgsz;
77840 mxCache = db->aDb[0].pSchema->cache_size;
77841 if( mxCache<SQLITE_SORTER_PMASZ ) mxCache = SQLITE_SORTER_PMASZ;
77842 pSorter->mxPmaSize = MIN((i64)mxCache*pgsz, SQLITE_MAX_MXPMASIZE);
77843
77844 /* EVIDENCE-OF: R-26747-61719 When the application provides any amount of
77845 ** scratch memory using SQLITE_CONFIG_SCRATCH, SQLite avoids unnecessary
77846 ** large heap allocations.
@@ -101080,11 +101086,10 @@
101086 # define sqlite3_column_database_name16 0
101087 # define sqlite3_column_table_name 0
101088 # define sqlite3_column_table_name16 0
101089 # define sqlite3_column_origin_name 0
101090 # define sqlite3_column_origin_name16 0
 
101091 #endif
101092
101093 #ifdef SQLITE_OMIT_AUTHORIZATION
101094 # define sqlite3_set_authorizer 0
101095 #endif
@@ -127175,15 +127180,17 @@
127180 for(j=0; j<db->nDb; j++){
127181 struct Db *pDb = &db->aDb[j];
127182 if( pDb->pBt ){
127183 if( pDb->pSchema ){
127184 /* Must clear the KeyInfo cache. See ticket [e4a18565a36884b00edf] */
127185 sqlite3BtreeEnter(pDb->pBt);
127186 for(i=sqliteHashFirst(&pDb->pSchema->idxHash); i; i=sqliteHashNext(i)){
127187 Index *pIdx = sqliteHashData(i);
127188 sqlite3KeyInfoUnref(pIdx->pKeyInfo);
127189 pIdx->pKeyInfo = 0;
127190 }
127191 sqlite3BtreeLeave(pDb->pBt);
127192 }
127193 sqlite3BtreeClose(pDb->pBt);
127194 pDb->pBt = 0;
127195 if( j!=1 ){
127196 pDb->pSchema = 0;
@@ -128882,10 +128889,13 @@
128889 | SQLITE_RecTriggers
128890 #endif
128891 #if defined(SQLITE_DEFAULT_FOREIGN_KEYS) && SQLITE_DEFAULT_FOREIGN_KEYS
128892 | SQLITE_ForeignKeys
128893 #endif
128894 #if defined(SQLITE_REVERSE_UNORDERED_SELECTS)
128895 | SQLITE_ReverseOrder
128896 #endif
128897 ;
128898 sqlite3HashInit(&db->aCollSeq);
128899 #ifndef SQLITE_OMIT_VIRTUALTABLE
128900 sqlite3HashInit(&db->aModule);
128901 #endif
@@ -128929,11 +128939,13 @@
128939 rc = SQLITE_NOMEM;
128940 }
128941 sqlite3Error(db, rc);
128942 goto opendb_out;
128943 }
128944 sqlite3BtreeEnter(db->aDb[0].pBt);
128945 db->aDb[0].pSchema = sqlite3SchemaGet(db, db->aDb[0].pBt);
128946 sqlite3BtreeLeave(db->aDb[0].pBt);
128947 db->aDb[1].pSchema = sqlite3SchemaGet(db, 0);
128948
128949 /* The default safety_level for the main database is 'full'; for the temp
128950 ** database it is 'NONE'. This matches the pager layer defaults.
128951 */
@@ -129283,11 +129295,10 @@
129295
129296 /*
129297 ** Return meta information about a specific column of a database table.
129298 ** See comment in sqlite3.h (sqlite.h.in) for details.
129299 */
 
129300 SQLITE_API int sqlite3_table_column_metadata(
129301 sqlite3 *db, /* Connection handle */
129302 const char *zDbName, /* Database name or NULL */
129303 const char *zTableName, /* Table name */
129304 const char *zColumnName, /* Column name */
@@ -129323,25 +129334,27 @@
129334 pTab = 0;
129335 goto error_out;
129336 }
129337
129338 /* Find the column for which info is requested */
129339 if( zColumnName==0 ){
129340 /* Query for existance of table only */
 
 
 
129341 }else{
129342 for(iCol=0; iCol<pTab->nCol; iCol++){
129343 pCol = &pTab->aCol[iCol];
129344 if( 0==sqlite3StrICmp(pCol->zName, zColumnName) ){
129345 break;
129346 }
129347 }
129348 if( iCol==pTab->nCol ){
129349 if( HasRowid(pTab) && sqlite3IsRowid(zColumnName) ){
129350 iCol = pTab->iPKey;
129351 pCol = iCol>=0 ? &pTab->aCol[iCol] : 0;
129352 }else{
129353 pTab = 0;
129354 goto error_out;
129355 }
129356 }
129357 }
129358
129359 /* The following block stores the meta information that will be returned
129360 ** to the caller in local variables zDataType, zCollSeq, notnull, primarykey
@@ -129390,11 +129403,10 @@
129403 sqlite3DbFree(db, zErrMsg);
129404 rc = sqlite3ApiExit(db, rc);
129405 sqlite3_mutex_leave(db->mutex);
129406 return rc;
129407 }
 
129408
129409 /*
129410 ** Sleep for a little while. Return the amount of time slept.
129411 */
129412 SQLITE_API int sqlite3_sleep(int ms){
129413
+23 -19
--- src/sqlite3.h
+++ src/sqlite3.h
@@ -107,11 +107,11 @@
107107
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
108108
** [sqlite_version()] and [sqlite_source_id()].
109109
*/
110110
#define SQLITE_VERSION "3.8.8"
111111
#define SQLITE_VERSION_NUMBER 3008008
112
-#define SQLITE_SOURCE_ID "2014-12-06 14:56:49 6aeece19a235344be2537e66a3fe08b1febfb5a0"
112
+#define SQLITE_SOURCE_ID "2014-12-10 04:58:43 3528f8dd39acace8eeb7337994c8617313f4b04b"
113113
114114
/*
115115
** CAPI3REF: Run-Time Library Version Numbers
116116
** KEYWORDS: sqlite3_version, sqlite3_sourceid
117117
**
@@ -5155,24 +5155,31 @@
51555155
51565156
51575157
/*
51585158
** CAPI3REF: Extract Metadata About A Column Of A Table
51595159
**
5160
-** ^This routine returns metadata about a specific column of a specific
5161
-** database table accessible using the [database connection] handle
5162
-** passed as the first function argument.
5160
+** ^(The sqlite3_table_column_metadata(X,D,T,C,....) routine returns
5161
+** information about column C of table T in database D
5162
+** on [database connection] X.)^ ^The sqlite3_table_column_metadata()
5163
+** interface returns SQLITE_OK and fills in the non-NULL pointers in
5164
+** the final five arguments with appropriate values if the specified
5165
+** column exists. ^The sqlite3_table_column_metadata() interface returns
5166
+** SQLITE_ERROR and if the specified column does not exist.
5167
+** ^If the column-name parameter to sqlite3_table_column_metadata() is a
5168
+** NULL pointer, then this routine simply checks for the existance of the
5169
+** table and returns SQLITE_OK if the table exists and SQLITE_ERROR if it
5170
+** does not.
51635171
**
51645172
** ^The column is identified by the second, third and fourth parameters to
5165
-** this function. ^The second parameter is either the name of the database
5173
+** this function. ^(The second parameter is either the name of the database
51665174
** (i.e. "main", "temp", or an attached database) containing the specified
5167
-** table or NULL. ^If it is NULL, then all attached databases are searched
5175
+** table or NULL.)^ ^If it is NULL, then all attached databases are searched
51685176
** for the table using the same algorithm used by the database engine to
51695177
** resolve unqualified table references.
51705178
**
51715179
** ^The third and fourth parameters to this function are the table and column
5172
-** name of the desired column, respectively. Neither of these parameters
5173
-** may be NULL.
5180
+** name of the desired column, respectively.
51745181
**
51755182
** ^Metadata is returned by writing to the memory locations passed as the 5th
51765183
** and subsequent parameters to this function. ^Any of these arguments may be
51775184
** NULL, in which case the corresponding element of metadata is omitted.
51785185
**
@@ -5187,36 +5194,33 @@
51875194
** <tr><td> 9th <td> int <td> True if column is [AUTOINCREMENT]
51885195
** </table>
51895196
** </blockquote>)^
51905197
**
51915198
** ^The memory pointed to by the character pointers returned for the
5192
-** declaration type and collation sequence is valid only until the next
5199
+** declaration type and collation sequence is valid until the next
51935200
** call to any SQLite API function.
51945201
**
51955202
** ^If the specified table is actually a view, an [error code] is returned.
51965203
**
5197
-** ^If the specified column is "rowid", "oid" or "_rowid_" and an
5204
+** ^If the specified column is "rowid", "oid" or "_rowid_" and the table
5205
+** is not a [WITHOUT ROWID] table and an
51985206
** [INTEGER PRIMARY KEY] column has been explicitly declared, then the output
51995207
** parameters are set for the explicitly declared column. ^(If there is no
5200
-** explicitly declared [INTEGER PRIMARY KEY] column, then the output
5201
-** parameters are set as follows:
5208
+** [INTEGER PRIMARY KEY] column, then the outputs
5209
+** for the [rowid] are set as follows:
52025210
**
52035211
** <pre>
52045212
** data type: "INTEGER"
52055213
** collation sequence: "BINARY"
52065214
** not null: 0
52075215
** primary key: 1
52085216
** auto increment: 0
52095217
** </pre>)^
52105218
**
5211
-** ^(This function may load one or more schemas from database files. If an
5212
-** error occurs during this process, or if the requested table or column
5213
-** cannot be found, an [error code] is returned and an error message left
5214
-** in the [database connection] (to be retrieved using sqlite3_errmsg()).)^
5215
-**
5216
-** ^This API is only available if the library was compiled with the
5217
-** [SQLITE_ENABLE_COLUMN_METADATA] C-preprocessor symbol defined.
5219
+** ^This function causes all database schemas to be read from disk and
5220
+** parsed, if that has not already been done, and returns an error if
5221
+** any errors are encountered while loading the schema.
52185222
*/
52195223
SQLITE_API int sqlite3_table_column_metadata(
52205224
sqlite3 *db, /* Connection handle */
52215225
const char *zDbName, /* Database name or NULL */
52225226
const char *zTableName, /* Table name */
52235227
--- src/sqlite3.h
+++ src/sqlite3.h
@@ -107,11 +107,11 @@
107 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
108 ** [sqlite_version()] and [sqlite_source_id()].
109 */
110 #define SQLITE_VERSION "3.8.8"
111 #define SQLITE_VERSION_NUMBER 3008008
112 #define SQLITE_SOURCE_ID "2014-12-06 14:56:49 6aeece19a235344be2537e66a3fe08b1febfb5a0"
113
114 /*
115 ** CAPI3REF: Run-Time Library Version Numbers
116 ** KEYWORDS: sqlite3_version, sqlite3_sourceid
117 **
@@ -5155,24 +5155,31 @@
5155
5156
5157 /*
5158 ** CAPI3REF: Extract Metadata About A Column Of A Table
5159 **
5160 ** ^This routine returns metadata about a specific column of a specific
5161 ** database table accessible using the [database connection] handle
5162 ** passed as the first function argument.
 
 
 
 
 
 
 
 
5163 **
5164 ** ^The column is identified by the second, third and fourth parameters to
5165 ** this function. ^The second parameter is either the name of the database
5166 ** (i.e. "main", "temp", or an attached database) containing the specified
5167 ** table or NULL. ^If it is NULL, then all attached databases are searched
5168 ** for the table using the same algorithm used by the database engine to
5169 ** resolve unqualified table references.
5170 **
5171 ** ^The third and fourth parameters to this function are the table and column
5172 ** name of the desired column, respectively. Neither of these parameters
5173 ** may be NULL.
5174 **
5175 ** ^Metadata is returned by writing to the memory locations passed as the 5th
5176 ** and subsequent parameters to this function. ^Any of these arguments may be
5177 ** NULL, in which case the corresponding element of metadata is omitted.
5178 **
@@ -5187,36 +5194,33 @@
5187 ** <tr><td> 9th <td> int <td> True if column is [AUTOINCREMENT]
5188 ** </table>
5189 ** </blockquote>)^
5190 **
5191 ** ^The memory pointed to by the character pointers returned for the
5192 ** declaration type and collation sequence is valid only until the next
5193 ** call to any SQLite API function.
5194 **
5195 ** ^If the specified table is actually a view, an [error code] is returned.
5196 **
5197 ** ^If the specified column is "rowid", "oid" or "_rowid_" and an
 
5198 ** [INTEGER PRIMARY KEY] column has been explicitly declared, then the output
5199 ** parameters are set for the explicitly declared column. ^(If there is no
5200 ** explicitly declared [INTEGER PRIMARY KEY] column, then the output
5201 ** parameters are set as follows:
5202 **
5203 ** <pre>
5204 ** data type: "INTEGER"
5205 ** collation sequence: "BINARY"
5206 ** not null: 0
5207 ** primary key: 1
5208 ** auto increment: 0
5209 ** </pre>)^
5210 **
5211 ** ^(This function may load one or more schemas from database files. If an
5212 ** error occurs during this process, or if the requested table or column
5213 ** cannot be found, an [error code] is returned and an error message left
5214 ** in the [database connection] (to be retrieved using sqlite3_errmsg()).)^
5215 **
5216 ** ^This API is only available if the library was compiled with the
5217 ** [SQLITE_ENABLE_COLUMN_METADATA] C-preprocessor symbol defined.
5218 */
5219 SQLITE_API int sqlite3_table_column_metadata(
5220 sqlite3 *db, /* Connection handle */
5221 const char *zDbName, /* Database name or NULL */
5222 const char *zTableName, /* Table name */
5223
--- src/sqlite3.h
+++ src/sqlite3.h
@@ -107,11 +107,11 @@
107 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
108 ** [sqlite_version()] and [sqlite_source_id()].
109 */
110 #define SQLITE_VERSION "3.8.8"
111 #define SQLITE_VERSION_NUMBER 3008008
112 #define SQLITE_SOURCE_ID "2014-12-10 04:58:43 3528f8dd39acace8eeb7337994c8617313f4b04b"
113
114 /*
115 ** CAPI3REF: Run-Time Library Version Numbers
116 ** KEYWORDS: sqlite3_version, sqlite3_sourceid
117 **
@@ -5155,24 +5155,31 @@
5155
5156
5157 /*
5158 ** CAPI3REF: Extract Metadata About A Column Of A Table
5159 **
5160 ** ^(The sqlite3_table_column_metadata(X,D,T,C,....) routine returns
5161 ** information about column C of table T in database D
5162 ** on [database connection] X.)^ ^The sqlite3_table_column_metadata()
5163 ** interface returns SQLITE_OK and fills in the non-NULL pointers in
5164 ** the final five arguments with appropriate values if the specified
5165 ** column exists. ^The sqlite3_table_column_metadata() interface returns
5166 ** SQLITE_ERROR and if the specified column does not exist.
5167 ** ^If the column-name parameter to sqlite3_table_column_metadata() is a
5168 ** NULL pointer, then this routine simply checks for the existance of the
5169 ** table and returns SQLITE_OK if the table exists and SQLITE_ERROR if it
5170 ** does not.
5171 **
5172 ** ^The column is identified by the second, third and fourth parameters to
5173 ** this function. ^(The second parameter is either the name of the database
5174 ** (i.e. "main", "temp", or an attached database) containing the specified
5175 ** table or NULL.)^ ^If it is NULL, then all attached databases are searched
5176 ** for the table using the same algorithm used by the database engine to
5177 ** resolve unqualified table references.
5178 **
5179 ** ^The third and fourth parameters to this function are the table and column
5180 ** name of the desired column, respectively.
 
5181 **
5182 ** ^Metadata is returned by writing to the memory locations passed as the 5th
5183 ** and subsequent parameters to this function. ^Any of these arguments may be
5184 ** NULL, in which case the corresponding element of metadata is omitted.
5185 **
@@ -5187,36 +5194,33 @@
5194 ** <tr><td> 9th <td> int <td> True if column is [AUTOINCREMENT]
5195 ** </table>
5196 ** </blockquote>)^
5197 **
5198 ** ^The memory pointed to by the character pointers returned for the
5199 ** declaration type and collation sequence is valid until the next
5200 ** call to any SQLite API function.
5201 **
5202 ** ^If the specified table is actually a view, an [error code] is returned.
5203 **
5204 ** ^If the specified column is "rowid", "oid" or "_rowid_" and the table
5205 ** is not a [WITHOUT ROWID] table and an
5206 ** [INTEGER PRIMARY KEY] column has been explicitly declared, then the output
5207 ** parameters are set for the explicitly declared column. ^(If there is no
5208 ** [INTEGER PRIMARY KEY] column, then the outputs
5209 ** for the [rowid] are set as follows:
5210 **
5211 ** <pre>
5212 ** data type: "INTEGER"
5213 ** collation sequence: "BINARY"
5214 ** not null: 0
5215 ** primary key: 1
5216 ** auto increment: 0
5217 ** </pre>)^
5218 **
5219 ** ^This function causes all database schemas to be read from disk and
5220 ** parsed, if that has not already been done, and returns an error if
5221 ** any errors are encountered while loading the schema.
 
 
 
 
5222 */
5223 SQLITE_API int sqlite3_table_column_metadata(
5224 sqlite3 *db, /* Connection handle */
5225 const char *zDbName, /* Database name or NULL */
5226 const char *zTableName, /* Table name */
5227
+1 -2
--- src/undo.c
+++ src/undo.c
@@ -143,12 +143,11 @@
143143
"INSERT INTO vmerge SELECT * FROM undo_vmerge;"
144144
"DELETE FROM undo_vmerge;"
145145
"INSERT INTO undo_vmerge SELECT * FROM undo_vmerge_2;"
146146
"DROP TABLE undo_vmerge_2;"
147147
);
148
- if(db_exists("SELECT 1 FROM \"%w\".sqlite_master"
149
- " WHERE name='undo_stash'", zDb) ){
148
+ if( db_table_exists(zDb, "undo_stash") ){
150149
if( redoFlag ){
151150
db_multi_exec(
152151
"DELETE FROM stash WHERE stashid IN (SELECT stashid FROM undo_stash);"
153152
"DELETE FROM stashfile"
154153
" WHERE stashid NOT IN (SELECT stashid FROM stash);"
155154
--- src/undo.c
+++ src/undo.c
@@ -143,12 +143,11 @@
143 "INSERT INTO vmerge SELECT * FROM undo_vmerge;"
144 "DELETE FROM undo_vmerge;"
145 "INSERT INTO undo_vmerge SELECT * FROM undo_vmerge_2;"
146 "DROP TABLE undo_vmerge_2;"
147 );
148 if(db_exists("SELECT 1 FROM \"%w\".sqlite_master"
149 " WHERE name='undo_stash'", zDb) ){
150 if( redoFlag ){
151 db_multi_exec(
152 "DELETE FROM stash WHERE stashid IN (SELECT stashid FROM undo_stash);"
153 "DELETE FROM stashfile"
154 " WHERE stashid NOT IN (SELECT stashid FROM stash);"
155
--- src/undo.c
+++ src/undo.c
@@ -143,12 +143,11 @@
143 "INSERT INTO vmerge SELECT * FROM undo_vmerge;"
144 "DELETE FROM undo_vmerge;"
145 "INSERT INTO undo_vmerge SELECT * FROM undo_vmerge_2;"
146 "DROP TABLE undo_vmerge_2;"
147 );
148 if( db_table_exists(zDb, "undo_stash") ){
 
149 if( redoFlag ){
150 db_multi_exec(
151 "DELETE FROM stash WHERE stashid IN (SELECT stashid FROM undo_stash);"
152 "DELETE FROM stashfile"
153 " WHERE stashid NOT IN (SELECT stashid FROM stash);"
154

Keyboard Shortcuts

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