Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(218)

Side by Side Diff: third_party/sqlite/src/src/test_sqllog.c

Issue 2751253002: [sql] Import SQLite 3.17.0. (Closed)
Patch Set: also clang on Linux i386 Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « third_party/sqlite/src/src/test_schema.c ('k') | third_party/sqlite/src/src/test_superlock.c » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 ** 2012 November 26 2 ** 2012 November 26
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 **
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after
306 }else{ 306 }else{
307 zInit = 0; 307 zInit = 0;
308 } 308 }
309 if( zInit==0 ){ 309 if( zInit==0 ){
310 int rc; 310 int rc;
311 sqlite3 *copy = 0; 311 sqlite3 *copy = 0;
312 int iDb; 312 int iDb;
313 313
314 /* Generate a file-name to use for the copy of this database */ 314 /* Generate a file-name to use for the copy of this database */
315 iDb = sqllogglobal.iNextDb++; 315 iDb = sqllogglobal.iNextDb++;
316 zInit = sqlite3_mprintf("%s_%d.db", sqllogglobal.zPrefix, iDb); 316 zInit = sqlite3_mprintf("%s_%02d.db", sqllogglobal.zPrefix, iDb);
317 317
318 /* Create the backup */ 318 /* Create the backup */
319 assert( sqllogglobal.bRec==0 ); 319 assert( sqllogglobal.bRec==0 );
320 sqllogglobal.bRec = 1; 320 sqllogglobal.bRec = 1;
321 rc = sqlite3_open(zInit, &copy); 321 rc = sqlite3_open(zInit, &copy);
322 if( rc==SQLITE_OK ){ 322 if( rc==SQLITE_OK ){
323 sqlite3_backup *pBak; 323 sqlite3_backup *pBak;
324 sqlite3_exec(copy, "PRAGMA synchronous = 0", 0, 0, 0); 324 sqlite3_exec(copy, "PRAGMA synchronous = 0", 0, 0, 0);
325 pBak = sqlite3_backup_init(copy, "main", p->db, zName); 325 pBak = sqlite3_backup_init(copy, "main", p->db, zName);
326 if( pBak ){ 326 if( pBak ){
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
369 if( p->fd==0 ){ 369 if( p->fd==0 ){
370 char *zLog; 370 char *zLog;
371 371
372 /* If it is still NULL, have global.zPrefix point to a copy of 372 /* If it is still NULL, have global.zPrefix point to a copy of
373 ** environment variable $ENVIRONMENT_VARIABLE1_NAME. */ 373 ** environment variable $ENVIRONMENT_VARIABLE1_NAME. */
374 if( sqllogglobal.zPrefix[0]==0 ){ 374 if( sqllogglobal.zPrefix[0]==0 ){
375 FILE *fd; 375 FILE *fd;
376 char *zVar = getenv(ENVIRONMENT_VARIABLE1_NAME); 376 char *zVar = getenv(ENVIRONMENT_VARIABLE1_NAME);
377 if( zVar==0 || strlen(zVar)+10>=(sizeof(sqllogglobal.zPrefix)) ) return; 377 if( zVar==0 || strlen(zVar)+10>=(sizeof(sqllogglobal.zPrefix)) ) return;
378 sqlite3_snprintf(sizeof(sqllogglobal.zPrefix), sqllogglobal.zPrefix, 378 sqlite3_snprintf(sizeof(sqllogglobal.zPrefix), sqllogglobal.zPrefix,
379 "%s/sqllog_%d", zVar, getProcessId()); 379 "%s/sqllog_%05d", zVar, getProcessId());
380 sqlite3_snprintf(sizeof(sqllogglobal.zIdx), sqllogglobal.zIdx, 380 sqlite3_snprintf(sizeof(sqllogglobal.zIdx), sqllogglobal.zIdx,
381 "%s.idx", sqllogglobal.zPrefix); 381 "%s.idx", sqllogglobal.zPrefix);
382 if( getenv(ENVIRONMENT_VARIABLE2_NAME) ){ 382 if( getenv(ENVIRONMENT_VARIABLE2_NAME) ){
383 sqllogglobal.bReuse = atoi(getenv(ENVIRONMENT_VARIABLE2_NAME)); 383 sqllogglobal.bReuse = atoi(getenv(ENVIRONMENT_VARIABLE2_NAME));
384 } 384 }
385 fd = fopen(sqllogglobal.zIdx, "w"); 385 fd = fopen(sqllogglobal.zIdx, "w");
386 if( fd ) fclose(fd); 386 if( fd ) fclose(fd);
387 } 387 }
388 388
389 /* Open the log file */ 389 /* Open the log file */
390 zLog = sqlite3_mprintf("%s_%d.sql", sqllogglobal.zPrefix, p->iLog); 390 zLog = sqlite3_mprintf("%s_%05d.sql", sqllogglobal.zPrefix, p->iLog);
391 p->fd = fopen(zLog, "w"); 391 p->fd = fopen(zLog, "w");
392 sqlite3_free(zLog); 392 sqlite3_free(zLog);
393 if( p->fd==0 ){ 393 if( p->fd==0 ){
394 sqlite3_log(SQLITE_IOERR, "sqllogOpenlog(): Failed to open log file"); 394 sqlite3_log(SQLITE_IOERR, "sqllogOpenlog(): Failed to open log file");
395 } 395 }
396 } 396 }
397 } 397 }
398 398
399 /* 399 /*
400 ** This function is called if the SQLLOG callback is invoked to report 400 ** This function is called if the SQLLOG callback is invoked to report
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
547 if( getenv(ENVIRONMENT_VARIABLE1_NAME) ){ 547 if( getenv(ENVIRONMENT_VARIABLE1_NAME) ){
548 if( SQLITE_OK==sqlite3_config(SQLITE_CONFIG_SQLLOG, testSqllog, 0) ){ 548 if( SQLITE_OK==sqlite3_config(SQLITE_CONFIG_SQLLOG, testSqllog, 0) ){
549 memset(&sqllogglobal, 0, sizeof(sqllogglobal)); 549 memset(&sqllogglobal, 0, sizeof(sqllogglobal));
550 sqllogglobal.bReuse = 1; 550 sqllogglobal.bReuse = 1;
551 if( getenv(ENVIRONMENT_VARIABLE3_NAME) ){ 551 if( getenv(ENVIRONMENT_VARIABLE3_NAME) ){
552 sqllogglobal.bConditional = 1; 552 sqllogglobal.bConditional = 1;
553 } 553 }
554 } 554 }
555 } 555 }
556 } 556 }
OLDNEW
« no previous file with comments | « third_party/sqlite/src/src/test_schema.c ('k') | third_party/sqlite/src/src/test_superlock.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698