Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Enhance the virtual table in test_schemapool.c so that it can be used to check that SHARED_SCHEMA connections are not allocating and freeing schemas when they should not be. |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | reuse-schema |
Files: | files | file ages | folders |
SHA3-256: |
cb236cb98564b870317ba3e481a3c7d7 |
User & Date: | dan 2019-02-15 19:36:47.869 |
Context
2019-02-18
| ||
18:16 | Ensure that creating temp schema items does not cause an OPEN_SHARABLE_SCHEMA connection to load all schemas into memory. (check-in: 88cbf54eee user: dan tags: reuse-schema) | |
2019-02-15
| ||
19:36 | Enhance the virtual table in test_schemapool.c so that it can be used to check that SHARED_SCHEMA connections are not allocating and freeing schemas when they should not be. (check-in: cb236cb985 user: dan tags: reuse-schema) | |
19:00 | Fix a problem with eponymous virtual tables and SHARED_SCHEMA databases. Also, after preparing statements that require all database schemas (REINDEX, ANALYZE, CREATE, DROP and some PRAGMA statements), do not allow the database connection to return more than one schema to each schema-pool. (check-in: ecf6251ec0 user: dan tags: reuse-schema) | |
Changes
Changes to src/callback.c.
︙ | |||
29 30 31 32 33 34 35 36 37 38 39 40 41 42 | 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 | + | ** SchemaPool. DB_SchemaLoaded flag is set. ** ** 3) pSPool!=0, pSchema points to the SchemaPool's static object ** (SchemaPool.sSchema). */ struct SchemaPool { int nRef; /* Number of pointers to this object */ int nDelete; /* Schema objects deleted by ReleaseAll() */ u64 cksum; /* Checksum for this Schema contents */ Schema *pSchema; /* Linked list of Schema objects */ Schema sSchema; /* The single dummy schema object */ SchemaPool *pNext; /* Next element in schemaPoolList */ }; #ifdef SQLITE_DEBUG |
︙ | |||
618 619 620 621 622 623 624 625 626 627 628 629 630 631 | 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 | + | ** at least one other copy of the schema being released, delete it instead ** of returning it to the schema-pool. */ if( db->mDbFlags & DBFLAG_FreeSchema ){ int i; for(i=0; i<db->nDb; i++){ Db *p = &db->aDb[i]; if( p!=pDb && p->pSchema!=&pSPool->sSchema && pDb->pSPool==p->pSPool ){ pSPool->nDelete++; schemaDelete(pRelease); return; } } } pRelease->pNext = pDb->pSPool->pSchema; |
︙ |
Changes to src/test_schemapool.c.
︙ | |||
25 26 27 28 29 30 31 | 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 | - + + + + | /* The code in this file defines a sqlite3 virtual-table module with ** the following schema. */ #define SCHEMAPOOL_SCHEMA \ "CREATE TABLE x(" \ " cksum INTEGER, " \ " nref INTEGER, " \ |
︙ | |||
102 103 104 105 106 107 108 | 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 | - - + + | } /* ** Retrieve a column of data. */ static int schemaPoolColumn(sqlite3_vtab_cursor *cur, sqlite3_context *ctx, int i){ schemapool_cursor *pCur = (schemapool_cursor*)cur; |
︙ | |||
132 133 134 135 136 137 138 139 140 141 142 143 144 145 | 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 | + | schemapool_cursor *pCur = (schemapool_cursor*)cur; pCur->iRow++; return SQLITE_OK; } struct SchemaPool { int nRef; /* Number of pointers to this object */ int nDelete; /* Schema objects deleted by ReleaseAll() */ u64 cksum; /* Checksum for this Schema contents */ Schema *pSchema; /* Linked list of Schema objects */ Schema sSchema; /* The single dummy schema object */ SchemaPool *pNext; /* Next element in schemaPoolList */ }; extern SchemaPool *sqlite3SchemaPoolList(void); |
︙ | |||
161 162 163 164 165 166 167 | 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 | + - + - - - + + + + | for(pSPool = sqlite3SchemaPoolList(); pSPool; pSPool=pSPool->pNext){ pCur->nRow++; } if( pCur->nRow ){ int iRow = 0; int nByte = SCHEMAPOOL_NFIELD * pCur->nRow * sizeof(i64); |
︙ |
Changes to test/reuse2.test.
︙ | |||
70 71 72 73 74 75 76 | 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 | - - + + + - - + + + - - + + + - - + + + - - + + + - - + + + - - + + + | } {} do_execsql_test -db db1 3.2.1 { SELECT * FROM t1 } do_execsql_test -db db2 3.2.2 { SELECT * FROM t1 } register_schemapool_module db do_execsql_test 3.3 { |
︙ | |||
130 131 132 133 134 135 136 | 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 | - + + - + + - - + + + - - + + + - - + + + - - + + + - - + + + - + + - + - + + - + - + + - + - + + - + - + + - + - - + + + | } sqlite3 db test.db sqlite3 db2 test.db -shared-schema 1 } {} register_schemapool_module db do_execsql_test 4.0.3 { |
︙ | |||
265 266 267 268 269 270 271 | 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 | - + + - + - - + + + - - + + + - - - + + + | forcecopy test.db test.db${i} sqlite3 db test.db${i} db eval { INSERT INTO bbb VALUES(123, 'database_' || $i) } db close db2 eval "ATTACH 'test.db${i}' AS db${i}" } execsql { |
Changes to test/reuse3.test.
︙ | |||
152 153 154 155 156 157 158 | 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 | + - - + + + + + - - - + + + | for {set i 1} {$i < 5} {incr i} { forcedelete test.db${i} test.db${i}-wal test.db${i}-journal forcecopy test.db test.db${i} execsql "ATTACH 'test.db${i}' AS db${i}" } register_schemapool_module db set {} {} execsql { |