]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Add missing comments and fix other code issues in the new functions in callback.c.
authordan <dan@noemail.net>
Thu, 14 Feb 2019 15:47:18 +0000 (15:47 +0000)
committerdan <dan@noemail.net>
Thu, 14 Feb 2019 15:47:18 +0000 (15:47 +0000)
FossilOrigin-Name: 441cabb62fe14bbef8b19066941426eeb2de128564ec2bfb762228fdae794447

manifest
manifest.uuid
src/callback.c
test/reuse1.test

index 7b3cde67635c0bbfae462e12245b301b30971337..af3cc459f8837b64359ed30398db7b8ec7f2073a 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Fix\sfor\ssqlite3_table_column_metadata()\son\sREUSE_SCHEMA\sdatabases.
-D 2019-02-13T19:17:30.631
+C Add\smissing\scomments\sand\sfix\sother\scode\sissues\sin\sthe\snew\sfunctions\sin\scallback.c.
+D 2019-02-14T15:47:18.706
 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
 F Makefile.in 56456706c4da271309914c756c9c8ea537685f1c79f8785afa72f968d6810482
@@ -459,7 +459,7 @@ F src/btree.c 18046bf14f0e3fa294ef3f7c2dc30ca7e95f3ac11ec222ad906e40b150051bde
 F src/btree.h 63b94fb38ce571c15eb6a3661815561b501d23d5948b2d1e951fbd7a2d04e8d3
 F src/btreeInt.h cd82f0f08886078bf99b29e1a7045960b1ca5d9d5829c38607e1299c508eaf00
 F src/build.c c6b40555c68a157d85b4fbd0e08842ce87a374aad685341b7b6fa05d87770ffb
-F src/callback.c 341911a87bb310091f8ed9e1c53c1e9c001cae296ae011d88b0c8eb64b5a9b22
+F src/callback.c f928820315b31d2aca6f156a1d4aa61d2ccb62b98095839f3c95a352e5cbd1d7
 F src/complete.c a3634ab1e687055cd002e11b8f43eb75c17da23e
 F src/ctime.c 109e58d00f62e8e71ee1eb5944ac18b90171c928ab2e082e058056e1137cc20b
 F src/date.c ebe1dc7c8a347117bb02570f1a931c62dd78f4a2b1b516f4837d45b7d6426957
@@ -1226,7 +1226,7 @@ F test/reindex.test 44edd3966b474468b823d481eafef0c305022254
 F test/releasetest.tcl 7712811e0f4e2f198ec786cb2e1352b3793d7395f48a3cceef0572d8823eb75e x
 F test/resetdb.test 8062cf10a09d8c048f8de7711e94571c38b38168db0e5877ba7561789e5eeb2b
 F test/resolver01.test f4022acafda7f4d40eca94dbf16bc5fc4ac30ceb
-F test/reuse1.test 5eee2efc7ee559fa9bdd214e35b351d5a949ad466c1671c256fee1f133e7eeea
+F test/reuse1.test f676744eaf744be8b9bd3e781f0eb3ab1c8010b56ebe31291584b24a6d4c50b1
 F test/reuse2.test d9fd3a796db599bbe76554f0f0f635874c7de198205fcd36c4b8261c7b0786a2
 F test/reuse3.test c9cc919586a6005d7ed19cf5ab8eb8c618f35dab5ed5ef8526f37815888c4973
 F test/rollback.test 06680159bc6746d0f26276e339e3ae2f951c64812468308838e0a3362d911eaa
@@ -1808,7 +1808,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
 F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
 F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
-P b102148e71c0102eedbf28d9bc8ea8d9bd742eac45ee7f1b08ece60bcdab5036
-R aede17ab79809dac49b20137e1ac0c75
+P 53220ad7809954eb4118d9127849efa82787f43898af00c9127cd4998a12c619
+R 639533767f9b21a9c0316e043a80b041
 U dan
-Z ec172fa91078d6896dd36c8049445c38
+Z 809b95e78a96f620323c5b19c37c9944
index 0fcf48e27ba15c63aea2e36e40e8595c87726694..be70d9e797b2b77ec6e9ca11f4b59918cb152812 100644 (file)
@@ -1 +1 @@
-53220ad7809954eb4118d9127849efa82787f43898af00c9127cd4998a12c619
\ No newline at end of file
+441cabb62fe14bbef8b19066941426eeb2de128564ec2bfb762228fdae794447
\ No newline at end of file
index 879c3dff3bde068a91c74abe96fef0b6f974cc4a..396a9dab5ecec9879a5a7dc3229ad990fdcfdfd1 100644 (file)
@@ -542,12 +542,16 @@ void sqlite3SchemaClearOrDisconnect(sqlite3 *db, int iDb){
 static SchemaPool *SQLITE_WSD schemaPoolList = 0;
 
 #ifdef SQLITE_TEST
+/*
+** Return a pointer to the head of the linked list of SchemaPool objects.
+** This is used by the virtual table in file test_schemapool.c.
+*/
 SchemaPool *sqlite3SchemaPoolList(void){ return schemaPoolList; }
 #endif
 
 /*
-** Check that the schema of db iDb is writable (either because it is the temp
-** db schema or because the db handle was opened without
+** Check that the schema of db iDb is writable (either because it is the 
+** temp db schema or because the db handle was opened without
 ** SQLITE_OPEN_REUSE_SCHEMA). If so, do nothing. Otherwise, leave an 
 ** error in the Parse object.
 */
@@ -559,11 +563,24 @@ void sqlite3SchemaWritable(Parse *pParse, int iDb){
   }
 }
 
+/*
+** The schema object passed as the only argument was allocated using
+** sqlite3_malloc() and then populated using the usual mechanism. This
+** function frees both the Schema object and its contents.
+*/
 static void schemaDelete(Schema *pSchema){
   sqlite3SchemaClear((void*)pSchema);
   sqlite3_free(pSchema);
 }
 
+/*
+** When this function is called, the database connection Db must be
+** using a schema-pool (Db.pSPool!=0) and must currently have Db.pSchema
+** set to point to a populated schema object checked out from the 
+** schema-pool. It is also assumed that the STATIC_MASTER mutex is held.
+** This function returns the Schema object to the schema-pool and sets
+** Db.pSchema to point to the schema-pool's static, empty, Schema object.
+*/
 static void schemaRelease(Db *pDb){
   assert( pDb->pSPool && pDb->pSchema );
   assert( pDb->pSchema->schemaFlags & DB_SchemaLoaded );
@@ -581,6 +598,9 @@ static void schemaRelease(Db *pDb){
 ** with SQLITE_OPEN_REUSE_SCHEMA, has just been parsed. This function either
 ** finds a matching SchemaPool object on the global list (schemaPoolList) or
 ** else allocates a new one and sets the Db.pSPool variable accordingly.
+**
+** SQLITE_OK is returned if no error occurs, or an SQLite error code 
+** (SQLITE_NOMEM) otherwise.
 */
 int sqlite3SchemaConnect(sqlite3 *db, int iDb, u64 cksum){
   Schema *pSchema = db->aDb[iDb].pSchema;
@@ -629,6 +649,21 @@ int sqlite3SchemaConnect(sqlite3 *db, int iDb, u64 cksum){
   return (p ? SQLITE_OK : SQLITE_NOMEM);
 }
 
+/*
+** If parameter iDb is 1 (the temp db), or if connection handle db was not
+** opened with the SQLITE_OPEN_REUSE_SCHEMA flag, this function is a no-op.
+** Otherwise, it disconnects from the schema-pool associated with database
+** iDb, assuming it is connected.
+**
+** If parameter bNew is true, then Db.pSchema is set to point to a new, empty,
+** Schema object obtained from sqlite3_malloc(). Or, if bNew is false, then
+** Db.pSchema is set to NULL before returning.
+**
+** If the bNew parameter is true, then this function may allocate memory. 
+** If the allocation attempt fails, then SQLITE_NOMEM is returned and the
+** schema-pool is not disconnected from. Or, if no OOM error occurs, 
+** SQLITE_OK is returned.
+*/
 int sqlite3SchemaDisconnect(sqlite3 *db, int iDb, int bNew){
   int rc = SQLITE_OK;
   if( IsReuseSchema(db) && iDb!=1 ){
@@ -704,6 +739,11 @@ Schema *sqlite3SchemaExtract(SchemaPool *pSPool){
   return pRet;
 }
 
+/*
+** Return all sharable schemas held by database handle db back to their
+** respective schema-pools. Db.pSchema variables are left pointing to
+** the static, empty, Schema object owned by each schema-pool.
+*/
 void sqlite3SchemaReleaseAll(sqlite3 *db){
   int i;
   assert_schema_state_ok(db);
@@ -719,6 +759,11 @@ void sqlite3SchemaReleaseAll(sqlite3 *db){
   sqlite3_mutex_leave( sqlite3_mutex_alloc(SQLITE_MUTEX_STATIC_MASTER) );
 }
 
+/*
+** Release any sharable schema held by connection iDb of database handle
+** db. Db.pSchema is left pointing to the static, empty, Schema object
+** owned by the schema-pool.
+*/
 void sqlite3SchemaRelease(sqlite3 *db, int iDb){
   Db *pDb = &db->aDb[iDb];
   assert( iDb!=1 );
@@ -731,8 +776,11 @@ void sqlite3SchemaRelease(sqlite3 *db, int iDb){
 }
 
 /*
-** Find and return the schema associated with a BTree.  Create
-** a new one if necessary.
+** In most cases, this function finds and returns the schema associated 
+** with BTree handle pBt, creating a new one if necessary. However, if
+** the database handle was opened with the SQLITE_OPEN_REUSE_SCHEMA flag
+** specified, a new, empty, Schema object in memory obtained by 
+** sqlite3_malloc() is always returned.
 */
 Schema *sqlite3SchemaGet(sqlite3 *db, Btree *pBt){
   Schema *p;
index 801c4c4ada47312570c86342fd50815b59284c8e..eec75113d9ffa6299ebd8f68474f97b10b93718c 100644 (file)
@@ -88,6 +88,7 @@ foreach {tn sql} {
   8  { DROP TABLE t1 }
   9  { DROP TRIGGER tr1 }
   10 { ANALYZE }
+  11 { ALTER TABLE t1 RENAME z TO zzz }
 } {
   do_catchsql_test 1.5.$tn $sql {1 {attempt to modify read-only schema}}
 }