| OLD | NEW |
| 1 /* | 1 /* |
| 2 ** 2001 September 15 | 2 ** 2001 September 15 |
| 3 ** | 3 ** |
| 4 ** The author disclaims copyright to this source code. In place of | 4 ** The author disclaims copyright to this source code. In place of |
| 5 ** a legal notice, here is a blessing: | 5 ** a legal notice, here is a blessing: |
| 6 ** | 6 ** |
| 7 ** May you do good and not evil. | 7 ** May you do good and not evil. |
| 8 ** May you find forgiveness for yourself and forgive others. | 8 ** May you find forgiveness for yourself and forgive others. |
| 9 ** May you share freely, never taking more than you give. | 9 ** May you share freely, never taking more than you give. |
| 10 ** | 10 ** |
| 11 ************************************************************************* | 11 ************************************************************************* |
| 12 ** Code for testing the pager.c module in SQLite. This code | 12 ** Code for testing the pager.c module in SQLite. This code |
| 13 ** is not included in the SQLite library. It is used for automated | 13 ** is not included in the SQLite library. It is used for automated |
| 14 ** testing of the SQLite library. | 14 ** testing of the SQLite library. |
| 15 */ | 15 */ |
| 16 #include "sqliteInt.h" | 16 #include "sqliteInt.h" |
| 17 #include "tcl.h" | 17 #if defined(INCLUDE_SQLITE_TCL_H) |
| 18 # include "sqlite_tcl.h" |
| 19 #else |
| 20 # include "tcl.h" |
| 21 #endif |
| 18 #include <stdlib.h> | 22 #include <stdlib.h> |
| 19 #include <string.h> | 23 #include <string.h> |
| 20 #include <ctype.h> | 24 #include <ctype.h> |
| 21 | 25 |
| 22 extern const char *sqlite3ErrName(int); | 26 extern const char *sqlite3ErrName(int); |
| 23 | 27 |
| 24 /* | 28 /* |
| 25 ** Page size and reserved size used for testing. | 29 ** Page size and reserved size used for testing. |
| 26 */ | 30 */ |
| 27 static int test_pagesize = 1024; | 31 static int test_pagesize = 1024; |
| 28 | 32 |
| 29 /* | 33 /* |
| 30 ** Dummy page reinitializer | 34 ** Dummy page reinitializer |
| 31 */ | 35 */ |
| 32 static void pager_test_reiniter(DbPage *pNotUsed){ | 36 static void pager_test_reiniter(DbPage *pNotUsed){ |
| 33 return; | 37 return; |
| 34 } | 38 } |
| 35 | 39 |
| 36 /* | 40 /* |
| 37 ** Usage: pager_open FILENAME N-PAGE | 41 ** Usage: pager_open FILENAME N-PAGE |
| 38 ** | 42 ** |
| 39 ** Open a new pager | 43 ** Open a new pager |
| 40 */ | 44 */ |
| 41 static int pager_open( | 45 static int SQLITE_TCLAPI pager_open( |
| 42 void *NotUsed, | 46 void *NotUsed, |
| 43 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ | 47 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ |
| 44 int argc, /* Number of arguments */ | 48 int argc, /* Number of arguments */ |
| 45 const char **argv /* Text of each argument */ | 49 const char **argv /* Text of each argument */ |
| 46 ){ | 50 ){ |
| 47 u32 pageSize; | 51 u32 pageSize; |
| 48 Pager *pPager; | 52 Pager *pPager; |
| 49 int nPage; | 53 int nPage; |
| 50 int rc; | 54 int rc; |
| 51 char zBuf[100]; | 55 char zBuf[100]; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 68 sqlite3_snprintf(sizeof(zBuf),zBuf,"%p",pPager); | 72 sqlite3_snprintf(sizeof(zBuf),zBuf,"%p",pPager); |
| 69 Tcl_AppendResult(interp, zBuf, 0); | 73 Tcl_AppendResult(interp, zBuf, 0); |
| 70 return TCL_OK; | 74 return TCL_OK; |
| 71 } | 75 } |
| 72 | 76 |
| 73 /* | 77 /* |
| 74 ** Usage: pager_close ID | 78 ** Usage: pager_close ID |
| 75 ** | 79 ** |
| 76 ** Close the given pager. | 80 ** Close the given pager. |
| 77 */ | 81 */ |
| 78 static int pager_close( | 82 static int SQLITE_TCLAPI pager_close( |
| 79 void *NotUsed, | 83 void *NotUsed, |
| 80 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ | 84 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ |
| 81 int argc, /* Number of arguments */ | 85 int argc, /* Number of arguments */ |
| 82 const char **argv /* Text of each argument */ | 86 const char **argv /* Text of each argument */ |
| 83 ){ | 87 ){ |
| 84 Pager *pPager; | 88 Pager *pPager; |
| 85 int rc; | 89 int rc; |
| 86 if( argc!=2 ){ | 90 if( argc!=2 ){ |
| 87 Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], | 91 Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], |
| 88 " ID\"", 0); | 92 " ID\"", 0); |
| 89 return TCL_ERROR; | 93 return TCL_ERROR; |
| 90 } | 94 } |
| 91 pPager = sqlite3TestTextToPtr(argv[1]); | 95 pPager = sqlite3TestTextToPtr(argv[1]); |
| 92 rc = sqlite3PagerClose(pPager); | 96 rc = sqlite3PagerClose(pPager, 0); |
| 93 if( rc!=SQLITE_OK ){ | 97 if( rc!=SQLITE_OK ){ |
| 94 Tcl_AppendResult(interp, sqlite3ErrName(rc), 0); | 98 Tcl_AppendResult(interp, sqlite3ErrName(rc), 0); |
| 95 return TCL_ERROR; | 99 return TCL_ERROR; |
| 96 } | 100 } |
| 97 return TCL_OK; | 101 return TCL_OK; |
| 98 } | 102 } |
| 99 | 103 |
| 100 /* | 104 /* |
| 101 ** Usage: pager_rollback ID | 105 ** Usage: pager_rollback ID |
| 102 ** | 106 ** |
| 103 ** Rollback changes | 107 ** Rollback changes |
| 104 */ | 108 */ |
| 105 static int pager_rollback( | 109 static int SQLITE_TCLAPI pager_rollback( |
| 106 void *NotUsed, | 110 void *NotUsed, |
| 107 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ | 111 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ |
| 108 int argc, /* Number of arguments */ | 112 int argc, /* Number of arguments */ |
| 109 const char **argv /* Text of each argument */ | 113 const char **argv /* Text of each argument */ |
| 110 ){ | 114 ){ |
| 111 Pager *pPager; | 115 Pager *pPager; |
| 112 int rc; | 116 int rc; |
| 113 if( argc!=2 ){ | 117 if( argc!=2 ){ |
| 114 Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], | 118 Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], |
| 115 " ID\"", 0); | 119 " ID\"", 0); |
| 116 return TCL_ERROR; | 120 return TCL_ERROR; |
| 117 } | 121 } |
| 118 pPager = sqlite3TestTextToPtr(argv[1]); | 122 pPager = sqlite3TestTextToPtr(argv[1]); |
| 119 rc = sqlite3PagerRollback(pPager); | 123 rc = sqlite3PagerRollback(pPager); |
| 120 if( rc!=SQLITE_OK ){ | 124 if( rc!=SQLITE_OK ){ |
| 121 Tcl_AppendResult(interp, sqlite3ErrName(rc), 0); | 125 Tcl_AppendResult(interp, sqlite3ErrName(rc), 0); |
| 122 return TCL_ERROR; | 126 return TCL_ERROR; |
| 123 } | 127 } |
| 124 return TCL_OK; | 128 return TCL_OK; |
| 125 } | 129 } |
| 126 | 130 |
| 127 /* | 131 /* |
| 128 ** Usage: pager_commit ID | 132 ** Usage: pager_commit ID |
| 129 ** | 133 ** |
| 130 ** Commit all changes | 134 ** Commit all changes |
| 131 */ | 135 */ |
| 132 static int pager_commit( | 136 static int SQLITE_TCLAPI pager_commit( |
| 133 void *NotUsed, | 137 void *NotUsed, |
| 134 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ | 138 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ |
| 135 int argc, /* Number of arguments */ | 139 int argc, /* Number of arguments */ |
| 136 const char **argv /* Text of each argument */ | 140 const char **argv /* Text of each argument */ |
| 137 ){ | 141 ){ |
| 138 Pager *pPager; | 142 Pager *pPager; |
| 139 int rc; | 143 int rc; |
| 140 if( argc!=2 ){ | 144 if( argc!=2 ){ |
| 141 Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], | 145 Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], |
| 142 " ID\"", 0); | 146 " ID\"", 0); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 154 return TCL_ERROR; | 158 return TCL_ERROR; |
| 155 } | 159 } |
| 156 return TCL_OK; | 160 return TCL_OK; |
| 157 } | 161 } |
| 158 | 162 |
| 159 /* | 163 /* |
| 160 ** Usage: pager_stmt_begin ID | 164 ** Usage: pager_stmt_begin ID |
| 161 ** | 165 ** |
| 162 ** Start a new checkpoint. | 166 ** Start a new checkpoint. |
| 163 */ | 167 */ |
| 164 static int pager_stmt_begin( | 168 static int SQLITE_TCLAPI pager_stmt_begin( |
| 165 void *NotUsed, | 169 void *NotUsed, |
| 166 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ | 170 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ |
| 167 int argc, /* Number of arguments */ | 171 int argc, /* Number of arguments */ |
| 168 const char **argv /* Text of each argument */ | 172 const char **argv /* Text of each argument */ |
| 169 ){ | 173 ){ |
| 170 Pager *pPager; | 174 Pager *pPager; |
| 171 int rc; | 175 int rc; |
| 172 if( argc!=2 ){ | 176 if( argc!=2 ){ |
| 173 Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], | 177 Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], |
| 174 " ID\"", 0); | 178 " ID\"", 0); |
| 175 return TCL_ERROR; | 179 return TCL_ERROR; |
| 176 } | 180 } |
| 177 pPager = sqlite3TestTextToPtr(argv[1]); | 181 pPager = sqlite3TestTextToPtr(argv[1]); |
| 178 rc = sqlite3PagerOpenSavepoint(pPager, 1); | 182 rc = sqlite3PagerOpenSavepoint(pPager, 1); |
| 179 if( rc!=SQLITE_OK ){ | 183 if( rc!=SQLITE_OK ){ |
| 180 Tcl_AppendResult(interp, sqlite3ErrName(rc), 0); | 184 Tcl_AppendResult(interp, sqlite3ErrName(rc), 0); |
| 181 return TCL_ERROR; | 185 return TCL_ERROR; |
| 182 } | 186 } |
| 183 return TCL_OK; | 187 return TCL_OK; |
| 184 } | 188 } |
| 185 | 189 |
| 186 /* | 190 /* |
| 187 ** Usage: pager_stmt_rollback ID | 191 ** Usage: pager_stmt_rollback ID |
| 188 ** | 192 ** |
| 189 ** Rollback changes to a checkpoint | 193 ** Rollback changes to a checkpoint |
| 190 */ | 194 */ |
| 191 static int pager_stmt_rollback( | 195 static int SQLITE_TCLAPI pager_stmt_rollback( |
| 192 void *NotUsed, | 196 void *NotUsed, |
| 193 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ | 197 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ |
| 194 int argc, /* Number of arguments */ | 198 int argc, /* Number of arguments */ |
| 195 const char **argv /* Text of each argument */ | 199 const char **argv /* Text of each argument */ |
| 196 ){ | 200 ){ |
| 197 Pager *pPager; | 201 Pager *pPager; |
| 198 int rc; | 202 int rc; |
| 199 if( argc!=2 ){ | 203 if( argc!=2 ){ |
| 200 Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], | 204 Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], |
| 201 " ID\"", 0); | 205 " ID\"", 0); |
| 202 return TCL_ERROR; | 206 return TCL_ERROR; |
| 203 } | 207 } |
| 204 pPager = sqlite3TestTextToPtr(argv[1]); | 208 pPager = sqlite3TestTextToPtr(argv[1]); |
| 205 rc = sqlite3PagerSavepoint(pPager, SAVEPOINT_ROLLBACK, 0); | 209 rc = sqlite3PagerSavepoint(pPager, SAVEPOINT_ROLLBACK, 0); |
| 206 sqlite3PagerSavepoint(pPager, SAVEPOINT_RELEASE, 0); | 210 sqlite3PagerSavepoint(pPager, SAVEPOINT_RELEASE, 0); |
| 207 if( rc!=SQLITE_OK ){ | 211 if( rc!=SQLITE_OK ){ |
| 208 Tcl_AppendResult(interp, sqlite3ErrName(rc), 0); | 212 Tcl_AppendResult(interp, sqlite3ErrName(rc), 0); |
| 209 return TCL_ERROR; | 213 return TCL_ERROR; |
| 210 } | 214 } |
| 211 return TCL_OK; | 215 return TCL_OK; |
| 212 } | 216 } |
| 213 | 217 |
| 214 /* | 218 /* |
| 215 ** Usage: pager_stmt_commit ID | 219 ** Usage: pager_stmt_commit ID |
| 216 ** | 220 ** |
| 217 ** Commit changes to a checkpoint | 221 ** Commit changes to a checkpoint |
| 218 */ | 222 */ |
| 219 static int pager_stmt_commit( | 223 static int SQLITE_TCLAPI pager_stmt_commit( |
| 220 void *NotUsed, | 224 void *NotUsed, |
| 221 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ | 225 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ |
| 222 int argc, /* Number of arguments */ | 226 int argc, /* Number of arguments */ |
| 223 const char **argv /* Text of each argument */ | 227 const char **argv /* Text of each argument */ |
| 224 ){ | 228 ){ |
| 225 Pager *pPager; | 229 Pager *pPager; |
| 226 int rc; | 230 int rc; |
| 227 if( argc!=2 ){ | 231 if( argc!=2 ){ |
| 228 Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], | 232 Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], |
| 229 " ID\"", 0); | 233 " ID\"", 0); |
| 230 return TCL_ERROR; | 234 return TCL_ERROR; |
| 231 } | 235 } |
| 232 pPager = sqlite3TestTextToPtr(argv[1]); | 236 pPager = sqlite3TestTextToPtr(argv[1]); |
| 233 rc = sqlite3PagerSavepoint(pPager, SAVEPOINT_RELEASE, 0); | 237 rc = sqlite3PagerSavepoint(pPager, SAVEPOINT_RELEASE, 0); |
| 234 if( rc!=SQLITE_OK ){ | 238 if( rc!=SQLITE_OK ){ |
| 235 Tcl_AppendResult(interp, sqlite3ErrName(rc), 0); | 239 Tcl_AppendResult(interp, sqlite3ErrName(rc), 0); |
| 236 return TCL_ERROR; | 240 return TCL_ERROR; |
| 237 } | 241 } |
| 238 return TCL_OK; | 242 return TCL_OK; |
| 239 } | 243 } |
| 240 | 244 |
| 241 /* | 245 /* |
| 242 ** Usage: pager_stats ID | 246 ** Usage: pager_stats ID |
| 243 ** | 247 ** |
| 244 ** Return pager statistics. | 248 ** Return pager statistics. |
| 245 */ | 249 */ |
| 246 static int pager_stats( | 250 static int SQLITE_TCLAPI pager_stats( |
| 247 void *NotUsed, | 251 void *NotUsed, |
| 248 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ | 252 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ |
| 249 int argc, /* Number of arguments */ | 253 int argc, /* Number of arguments */ |
| 250 const char **argv /* Text of each argument */ | 254 const char **argv /* Text of each argument */ |
| 251 ){ | 255 ){ |
| 252 Pager *pPager; | 256 Pager *pPager; |
| 253 int i, *a; | 257 int i, *a; |
| 254 if( argc!=2 ){ | 258 if( argc!=2 ){ |
| 255 Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], | 259 Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], |
| 256 " ID\"", 0); | 260 " ID\"", 0); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 269 Tcl_AppendElement(interp, zBuf); | 273 Tcl_AppendElement(interp, zBuf); |
| 270 } | 274 } |
| 271 return TCL_OK; | 275 return TCL_OK; |
| 272 } | 276 } |
| 273 | 277 |
| 274 /* | 278 /* |
| 275 ** Usage: pager_pagecount ID | 279 ** Usage: pager_pagecount ID |
| 276 ** | 280 ** |
| 277 ** Return the size of the database file. | 281 ** Return the size of the database file. |
| 278 */ | 282 */ |
| 279 static int pager_pagecount( | 283 static int SQLITE_TCLAPI pager_pagecount( |
| 280 void *NotUsed, | 284 void *NotUsed, |
| 281 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ | 285 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ |
| 282 int argc, /* Number of arguments */ | 286 int argc, /* Number of arguments */ |
| 283 const char **argv /* Text of each argument */ | 287 const char **argv /* Text of each argument */ |
| 284 ){ | 288 ){ |
| 285 Pager *pPager; | 289 Pager *pPager; |
| 286 char zBuf[100]; | 290 char zBuf[100]; |
| 287 int nPage; | 291 int nPage; |
| 288 if( argc!=2 ){ | 292 if( argc!=2 ){ |
| 289 Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], | 293 Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], |
| 290 " ID\"", 0); | 294 " ID\"", 0); |
| 291 return TCL_ERROR; | 295 return TCL_ERROR; |
| 292 } | 296 } |
| 293 pPager = sqlite3TestTextToPtr(argv[1]); | 297 pPager = sqlite3TestTextToPtr(argv[1]); |
| 294 sqlite3PagerPagecount(pPager, &nPage); | 298 sqlite3PagerPagecount(pPager, &nPage); |
| 295 sqlite3_snprintf(sizeof(zBuf), zBuf, "%d", nPage); | 299 sqlite3_snprintf(sizeof(zBuf), zBuf, "%d", nPage); |
| 296 Tcl_AppendResult(interp, zBuf, 0); | 300 Tcl_AppendResult(interp, zBuf, 0); |
| 297 return TCL_OK; | 301 return TCL_OK; |
| 298 } | 302 } |
| 299 | 303 |
| 300 /* | 304 /* |
| 301 ** Usage: page_get ID PGNO | 305 ** Usage: page_get ID PGNO |
| 302 ** | 306 ** |
| 303 ** Return a pointer to a page from the database. | 307 ** Return a pointer to a page from the database. |
| 304 */ | 308 */ |
| 305 static int page_get( | 309 static int SQLITE_TCLAPI page_get( |
| 306 void *NotUsed, | 310 void *NotUsed, |
| 307 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ | 311 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ |
| 308 int argc, /* Number of arguments */ | 312 int argc, /* Number of arguments */ |
| 309 const char **argv /* Text of each argument */ | 313 const char **argv /* Text of each argument */ |
| 310 ){ | 314 ){ |
| 311 Pager *pPager; | 315 Pager *pPager; |
| 312 char zBuf[100]; | 316 char zBuf[100]; |
| 313 DbPage *pPage = 0; | 317 DbPage *pPage = 0; |
| 314 int pgno; | 318 int pgno; |
| 315 int rc; | 319 int rc; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 332 Tcl_AppendResult(interp, zBuf, 0); | 336 Tcl_AppendResult(interp, zBuf, 0); |
| 333 return TCL_OK; | 337 return TCL_OK; |
| 334 } | 338 } |
| 335 | 339 |
| 336 /* | 340 /* |
| 337 ** Usage: page_lookup ID PGNO | 341 ** Usage: page_lookup ID PGNO |
| 338 ** | 342 ** |
| 339 ** Return a pointer to a page if the page is already in cache. | 343 ** Return a pointer to a page if the page is already in cache. |
| 340 ** If not in cache, return an empty string. | 344 ** If not in cache, return an empty string. |
| 341 */ | 345 */ |
| 342 static int page_lookup( | 346 static int SQLITE_TCLAPI page_lookup( |
| 343 void *NotUsed, | 347 void *NotUsed, |
| 344 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ | 348 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ |
| 345 int argc, /* Number of arguments */ | 349 int argc, /* Number of arguments */ |
| 346 const char **argv /* Text of each argument */ | 350 const char **argv /* Text of each argument */ |
| 347 ){ | 351 ){ |
| 348 Pager *pPager; | 352 Pager *pPager; |
| 349 char zBuf[100]; | 353 char zBuf[100]; |
| 350 DbPage *pPage; | 354 DbPage *pPage; |
| 351 int pgno; | 355 int pgno; |
| 352 if( argc!=3 ){ | 356 if( argc!=3 ){ |
| 353 Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], | 357 Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], |
| 354 " ID PGNO\"", 0); | 358 " ID PGNO\"", 0); |
| 355 return TCL_ERROR; | 359 return TCL_ERROR; |
| 356 } | 360 } |
| 357 pPager = sqlite3TestTextToPtr(argv[1]); | 361 pPager = sqlite3TestTextToPtr(argv[1]); |
| 358 if( Tcl_GetInt(interp, argv[2], &pgno) ) return TCL_ERROR; | 362 if( Tcl_GetInt(interp, argv[2], &pgno) ) return TCL_ERROR; |
| 359 pPage = sqlite3PagerLookup(pPager, pgno); | 363 pPage = sqlite3PagerLookup(pPager, pgno); |
| 360 if( pPage ){ | 364 if( pPage ){ |
| 361 sqlite3_snprintf(sizeof(zBuf),zBuf,"%p",pPage); | 365 sqlite3_snprintf(sizeof(zBuf),zBuf,"%p",pPage); |
| 362 Tcl_AppendResult(interp, zBuf, 0); | 366 Tcl_AppendResult(interp, zBuf, 0); |
| 363 } | 367 } |
| 364 return TCL_OK; | 368 return TCL_OK; |
| 365 } | 369 } |
| 366 | 370 |
| 367 /* | 371 /* |
| 368 ** Usage: pager_truncate ID PGNO | 372 ** Usage: pager_truncate ID PGNO |
| 369 */ | 373 */ |
| 370 static int pager_truncate( | 374 static int SQLITE_TCLAPI pager_truncate( |
| 371 void *NotUsed, | 375 void *NotUsed, |
| 372 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ | 376 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ |
| 373 int argc, /* Number of arguments */ | 377 int argc, /* Number of arguments */ |
| 374 const char **argv /* Text of each argument */ | 378 const char **argv /* Text of each argument */ |
| 375 ){ | 379 ){ |
| 376 Pager *pPager; | 380 Pager *pPager; |
| 377 int pgno; | 381 int pgno; |
| 378 if( argc!=3 ){ | 382 if( argc!=3 ){ |
| 379 Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], | 383 Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], |
| 380 " ID PGNO\"", 0); | 384 " ID PGNO\"", 0); |
| 381 return TCL_ERROR; | 385 return TCL_ERROR; |
| 382 } | 386 } |
| 383 pPager = sqlite3TestTextToPtr(argv[1]); | 387 pPager = sqlite3TestTextToPtr(argv[1]); |
| 384 if( Tcl_GetInt(interp, argv[2], &pgno) ) return TCL_ERROR; | 388 if( Tcl_GetInt(interp, argv[2], &pgno) ) return TCL_ERROR; |
| 385 sqlite3PagerTruncateImage(pPager, pgno); | 389 sqlite3PagerTruncateImage(pPager, pgno); |
| 386 return TCL_OK; | 390 return TCL_OK; |
| 387 } | 391 } |
| 388 | 392 |
| 389 | 393 |
| 390 /* | 394 /* |
| 391 ** Usage: page_unref PAGE | 395 ** Usage: page_unref PAGE |
| 392 ** | 396 ** |
| 393 ** Drop a pointer to a page. | 397 ** Drop a pointer to a page. |
| 394 */ | 398 */ |
| 395 static int page_unref( | 399 static int SQLITE_TCLAPI page_unref( |
| 396 void *NotUsed, | 400 void *NotUsed, |
| 397 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ | 401 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ |
| 398 int argc, /* Number of arguments */ | 402 int argc, /* Number of arguments */ |
| 399 const char **argv /* Text of each argument */ | 403 const char **argv /* Text of each argument */ |
| 400 ){ | 404 ){ |
| 401 DbPage *pPage; | 405 DbPage *pPage; |
| 402 if( argc!=2 ){ | 406 if( argc!=2 ){ |
| 403 Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], | 407 Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], |
| 404 " PAGE\"", 0); | 408 " PAGE\"", 0); |
| 405 return TCL_ERROR; | 409 return TCL_ERROR; |
| 406 } | 410 } |
| 407 pPage = (DbPage *)sqlite3TestTextToPtr(argv[1]); | 411 pPage = (DbPage *)sqlite3TestTextToPtr(argv[1]); |
| 408 sqlite3PagerUnref(pPage); | 412 sqlite3PagerUnref(pPage); |
| 409 return TCL_OK; | 413 return TCL_OK; |
| 410 } | 414 } |
| 411 | 415 |
| 412 /* | 416 /* |
| 413 ** Usage: page_read PAGE | 417 ** Usage: page_read PAGE |
| 414 ** | 418 ** |
| 415 ** Return the content of a page | 419 ** Return the content of a page |
| 416 */ | 420 */ |
| 417 static int page_read( | 421 static int SQLITE_TCLAPI page_read( |
| 418 void *NotUsed, | 422 void *NotUsed, |
| 419 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ | 423 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ |
| 420 int argc, /* Number of arguments */ | 424 int argc, /* Number of arguments */ |
| 421 const char **argv /* Text of each argument */ | 425 const char **argv /* Text of each argument */ |
| 422 ){ | 426 ){ |
| 423 char zBuf[100]; | 427 char zBuf[100]; |
| 424 DbPage *pPage; | 428 DbPage *pPage; |
| 425 if( argc!=2 ){ | 429 if( argc!=2 ){ |
| 426 Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], | 430 Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], |
| 427 " PAGE\"", 0); | 431 " PAGE\"", 0); |
| 428 return TCL_ERROR; | 432 return TCL_ERROR; |
| 429 } | 433 } |
| 430 pPage = sqlite3TestTextToPtr(argv[1]); | 434 pPage = sqlite3TestTextToPtr(argv[1]); |
| 431 memcpy(zBuf, sqlite3PagerGetData(pPage), sizeof(zBuf)); | 435 memcpy(zBuf, sqlite3PagerGetData(pPage), sizeof(zBuf)); |
| 432 Tcl_AppendResult(interp, zBuf, 0); | 436 Tcl_AppendResult(interp, zBuf, 0); |
| 433 return TCL_OK; | 437 return TCL_OK; |
| 434 } | 438 } |
| 435 | 439 |
| 436 /* | 440 /* |
| 437 ** Usage: page_number PAGE | 441 ** Usage: page_number PAGE |
| 438 ** | 442 ** |
| 439 ** Return the page number for a page. | 443 ** Return the page number for a page. |
| 440 */ | 444 */ |
| 441 static int page_number( | 445 static int SQLITE_TCLAPI page_number( |
| 442 void *NotUsed, | 446 void *NotUsed, |
| 443 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ | 447 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ |
| 444 int argc, /* Number of arguments */ | 448 int argc, /* Number of arguments */ |
| 445 const char **argv /* Text of each argument */ | 449 const char **argv /* Text of each argument */ |
| 446 ){ | 450 ){ |
| 447 char zBuf[100]; | 451 char zBuf[100]; |
| 448 DbPage *pPage; | 452 DbPage *pPage; |
| 449 if( argc!=2 ){ | 453 if( argc!=2 ){ |
| 450 Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], | 454 Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], |
| 451 " PAGE\"", 0); | 455 " PAGE\"", 0); |
| 452 return TCL_ERROR; | 456 return TCL_ERROR; |
| 453 } | 457 } |
| 454 pPage = (DbPage *)sqlite3TestTextToPtr(argv[1]); | 458 pPage = (DbPage *)sqlite3TestTextToPtr(argv[1]); |
| 455 sqlite3_snprintf(sizeof(zBuf), zBuf, "%d", sqlite3PagerPagenumber(pPage)); | 459 sqlite3_snprintf(sizeof(zBuf), zBuf, "%d", sqlite3PagerPagenumber(pPage)); |
| 456 Tcl_AppendResult(interp, zBuf, 0); | 460 Tcl_AppendResult(interp, zBuf, 0); |
| 457 return TCL_OK; | 461 return TCL_OK; |
| 458 } | 462 } |
| 459 | 463 |
| 460 /* | 464 /* |
| 461 ** Usage: page_write PAGE DATA | 465 ** Usage: page_write PAGE DATA |
| 462 ** | 466 ** |
| 463 ** Write something into a page. | 467 ** Write something into a page. |
| 464 */ | 468 */ |
| 465 static int page_write( | 469 static int SQLITE_TCLAPI page_write( |
| 466 void *NotUsed, | 470 void *NotUsed, |
| 467 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ | 471 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ |
| 468 int argc, /* Number of arguments */ | 472 int argc, /* Number of arguments */ |
| 469 const char **argv /* Text of each argument */ | 473 const char **argv /* Text of each argument */ |
| 470 ){ | 474 ){ |
| 471 DbPage *pPage; | 475 DbPage *pPage; |
| 472 char *pData; | 476 char *pData; |
| 473 int rc; | 477 int rc; |
| 474 if( argc!=3 ){ | 478 if( argc!=3 ){ |
| 475 Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], | 479 Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], |
| (...skipping 15 matching lines...) Expand all Loading... |
| 491 #ifndef SQLITE_OMIT_DISKIO | 495 #ifndef SQLITE_OMIT_DISKIO |
| 492 /* | 496 /* |
| 493 ** Usage: fake_big_file N FILENAME | 497 ** Usage: fake_big_file N FILENAME |
| 494 ** | 498 ** |
| 495 ** Write a few bytes at the N megabyte point of FILENAME. This will | 499 ** Write a few bytes at the N megabyte point of FILENAME. This will |
| 496 ** create a large file. If the file was a valid SQLite database, then | 500 ** create a large file. If the file was a valid SQLite database, then |
| 497 ** the next time the database is opened, SQLite will begin allocating | 501 ** the next time the database is opened, SQLite will begin allocating |
| 498 ** new pages after N. If N is 2096 or bigger, this will test the | 502 ** new pages after N. If N is 2096 or bigger, this will test the |
| 499 ** ability of SQLite to write to large files. | 503 ** ability of SQLite to write to large files. |
| 500 */ | 504 */ |
| 501 static int fake_big_file( | 505 static int SQLITE_TCLAPI fake_big_file( |
| 502 void *NotUsed, | 506 void *NotUsed, |
| 503 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ | 507 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ |
| 504 int argc, /* Number of arguments */ | 508 int argc, /* Number of arguments */ |
| 505 const char **argv /* Text of each argument */ | 509 const char **argv /* Text of each argument */ |
| 506 ){ | 510 ){ |
| 507 sqlite3_vfs *pVfs; | 511 sqlite3_vfs *pVfs; |
| 508 sqlite3_file *fd = 0; | 512 sqlite3_file *fd = 0; |
| 509 int rc; | 513 int rc; |
| 510 int n; | 514 int n; |
| 511 i64 offset; | 515 i64 offset; |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 544 return TCL_OK; | 548 return TCL_OK; |
| 545 } | 549 } |
| 546 #endif | 550 #endif |
| 547 | 551 |
| 548 | 552 |
| 549 /* | 553 /* |
| 550 ** test_control_pending_byte PENDING_BYTE | 554 ** test_control_pending_byte PENDING_BYTE |
| 551 ** | 555 ** |
| 552 ** Set the PENDING_BYTE using the sqlite3_test_control() interface. | 556 ** Set the PENDING_BYTE using the sqlite3_test_control() interface. |
| 553 */ | 557 */ |
| 554 static int testPendingByte( | 558 static int SQLITE_TCLAPI testPendingByte( |
| 555 void *NotUsed, | 559 void *NotUsed, |
| 556 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ | 560 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ |
| 557 int argc, /* Number of arguments */ | 561 int argc, /* Number of arguments */ |
| 558 const char **argv /* Text of each argument */ | 562 const char **argv /* Text of each argument */ |
| 559 ){ | 563 ){ |
| 560 int pbyte; | 564 int pbyte; |
| 561 int rc; | 565 int rc; |
| 562 if( argc!=2 ){ | 566 if( argc!=2 ){ |
| 563 Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], | 567 Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], |
| 564 " PENDING-BYTE\"", (void*)0); | 568 " PENDING-BYTE\"", (void*)0); |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 609 return rc; | 613 return rc; |
| 610 } | 614 } |
| 611 | 615 |
| 612 /* | 616 /* |
| 613 ** sqlite3_test_control_fault_install SCRIPT | 617 ** sqlite3_test_control_fault_install SCRIPT |
| 614 ** | 618 ** |
| 615 ** Arrange to invoke SCRIPT with the integer argument to sqlite3FaultSim() | 619 ** Arrange to invoke SCRIPT with the integer argument to sqlite3FaultSim() |
| 616 ** appended, whenever sqlite3FaultSim() is called. Or, if SCRIPT is the | 620 ** appended, whenever sqlite3FaultSim() is called. Or, if SCRIPT is the |
| 617 ** empty string, cancel the sqlite3FaultSim() callback. | 621 ** empty string, cancel the sqlite3FaultSim() callback. |
| 618 */ | 622 */ |
| 619 static int faultInstallCmd( | 623 static int SQLITE_TCLAPI faultInstallCmd( |
| 620 void *NotUsed, | 624 void *NotUsed, |
| 621 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ | 625 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ |
| 622 int argc, /* Number of arguments */ | 626 int argc, /* Number of arguments */ |
| 623 const char **argv /* Text of each argument */ | 627 const char **argv /* Text of each argument */ |
| 624 ){ | 628 ){ |
| 625 const char *zScript; | 629 const char *zScript; |
| 626 int nScript; | 630 int nScript; |
| 627 int rc; | 631 int rc; |
| 628 if( argc!=1 && argc!=2 ){ | 632 if( argc!=1 && argc!=2 ){ |
| 629 Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], | 633 Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], |
| (...skipping 22 matching lines...) Expand all Loading... |
| 652 Tcl_SetObjResult(interp, Tcl_NewIntObj(rc)); | 656 Tcl_SetObjResult(interp, Tcl_NewIntObj(rc)); |
| 653 return SQLITE_OK; | 657 return SQLITE_OK; |
| 654 } | 658 } |
| 655 | 659 |
| 656 /* | 660 /* |
| 657 ** sqlite3BitvecBuiltinTest SIZE PROGRAM | 661 ** sqlite3BitvecBuiltinTest SIZE PROGRAM |
| 658 ** | 662 ** |
| 659 ** Invoke the SQLITE_TESTCTRL_BITVEC_TEST operator on test_control. | 663 ** Invoke the SQLITE_TESTCTRL_BITVEC_TEST operator on test_control. |
| 660 ** See comments on sqlite3BitvecBuiltinTest() for additional information. | 664 ** See comments on sqlite3BitvecBuiltinTest() for additional information. |
| 661 */ | 665 */ |
| 662 static int testBitvecBuiltinTest( | 666 static int SQLITE_TCLAPI testBitvecBuiltinTest( |
| 663 void *NotUsed, | 667 void *NotUsed, |
| 664 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ | 668 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ |
| 665 int argc, /* Number of arguments */ | 669 int argc, /* Number of arguments */ |
| 666 const char **argv /* Text of each argument */ | 670 const char **argv /* Text of each argument */ |
| 667 ){ | 671 ){ |
| 668 int sz, rc; | 672 int sz, rc; |
| 669 int nProg = 0; | 673 int nProg = 0; |
| 670 int aProg[100]; | 674 int aProg[100]; |
| 671 const char *z; | 675 const char *z; |
| 672 if( argc!=3 ){ | 676 if( argc!=3 ){ |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 739 Tcl_LinkVar(interp, "sqlite_diskfull_pending", | 743 Tcl_LinkVar(interp, "sqlite_diskfull_pending", |
| 740 (char*)&sqlite3_diskfull_pending, TCL_LINK_INT); | 744 (char*)&sqlite3_diskfull_pending, TCL_LINK_INT); |
| 741 Tcl_LinkVar(interp, "sqlite_diskfull", | 745 Tcl_LinkVar(interp, "sqlite_diskfull", |
| 742 (char*)&sqlite3_diskfull, TCL_LINK_INT); | 746 (char*)&sqlite3_diskfull, TCL_LINK_INT); |
| 743 #ifndef SQLITE_OMIT_WSD | 747 #ifndef SQLITE_OMIT_WSD |
| 744 Tcl_LinkVar(interp, "sqlite_pending_byte", | 748 Tcl_LinkVar(interp, "sqlite_pending_byte", |
| 745 (char*)&sqlite3PendingByte, TCL_LINK_INT | TCL_LINK_READ_ONLY); | 749 (char*)&sqlite3PendingByte, TCL_LINK_INT | TCL_LINK_READ_ONLY); |
| 746 #endif | 750 #endif |
| 747 return TCL_OK; | 751 return TCL_OK; |
| 748 } | 752 } |
| OLD | NEW |