Changeset 3406
- Timestamp:
- 11/23/06 15:01:22 (2 years ago)
- Files:
-
- trunk/Models/JVSQLChatTranscript.m (modified) (15 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/Models/JVSQLChatTranscript.m
r3346 r3406 8 8 #import <sys/stat.h> 9 9 #import <unistd.h> 10 11 #define DEBUG_SQL 0 10 12 11 13 @interface JVSQLChatTranscript (JVSQLChatTranscriptPrivate) … … 351 353 sqlite3_stmt *compiledMsgQuery = NULL; 352 354 if( sqlite3_prepare( _database, msgQuery, -1, &compiledMsgQuery, NULL ) != SQLITE_OK ) { 353 if( NSDebugEnabled) NSLog( @"SQL ERROR: %s", sqlite3_errmsg( _database ) );355 if( DEBUG_SQL ) NSLog( @"SQL ERROR: %s", sqlite3_errmsg( _database ) ); 354 356 sqlite3_exec( _database, "ROLLBACK TRANSACTION", NULL, NULL, NULL ); 355 357 return nil; … … 370 372 sqlite3_step( compiledMsgQuery ); 371 373 if( sqlite3_finalize( compiledMsgQuery ) != SQLITE_OK ) { 372 if( NSDebugEnabled) NSLog( @"SQL ERROR: %s", sqlite3_errmsg( _database ) );374 if( DEBUG_SQL ) NSLog( @"SQL ERROR: %s", sqlite3_errmsg( _database ) ); 373 375 sqlite3_exec( _database, "ROLLBACK TRANSACTION", NULL, NULL, NULL ); 374 376 return nil; … … 377 379 messageIdentifier = sqlite3_last_insert_rowid( _database ); 378 380 if( ! messageIdentifier ) { 379 if( NSDebugEnabled) NSLog( @"SQL ERROR: %s", sqlite3_errmsg( _database ) );381 if( DEBUG_SQL ) NSLog( @"SQL ERROR: %s", sqlite3_errmsg( _database ) ); 380 382 sqlite3_exec( _database, "ROLLBACK TRANSACTION", NULL, NULL, NULL ); 381 383 return nil; … … 383 385 384 386 if( sqlite3_exec( _database, "COMMIT TRANSACTION", NULL, NULL, NULL ) != SQLITE_OK ) { 385 if( NSDebugEnabled) NSLog( @"SQL ERROR: %s", sqlite3_errmsg( _database ) );387 if( DEBUG_SQL ) NSLog( @"SQL ERROR: %s", sqlite3_errmsg( _database ) ); 386 388 sqlite3_exec( _database, "ROLLBACK TRANSACTION", NULL, NULL, NULL ); 387 389 return nil; … … 439 441 sqlite3_stmt *compiledQuery = NULL; 440 442 if( sqlite3_prepare( _database, query, -1, &compiledQuery, NULL ) != SQLITE_OK ) { 441 if( NSDebugEnabled) NSLog( @"SQL ERROR: %s", sqlite3_errmsg( _database ) );443 if( DEBUG_SQL ) NSLog( @"SQL ERROR: %s", sqlite3_errmsg( _database ) ); 442 444 sqlite3_exec( _database, "ROLLBACK TRANSACTION", NULL, NULL, NULL ); 443 445 return nil; … … 453 455 sqlite3_step( compiledQuery ); 454 456 if( sqlite3_finalize( compiledQuery ) != SQLITE_OK ) { 455 if( NSDebugEnabled) NSLog( @"SQL ERROR: %s", sqlite3_errmsg( _database ) );457 if( DEBUG_SQL ) NSLog( @"SQL ERROR: %s", sqlite3_errmsg( _database ) ); 456 458 sqlite3_exec( _database, "ROLLBACK TRANSACTION", NULL, NULL, NULL ); 457 459 return nil; … … 460 462 eventIdentifier = sqlite3_last_insert_rowid( _database ); 461 463 if( ! eventIdentifier ) { 462 if( NSDebugEnabled) NSLog( @"SQL ERROR: %s", sqlite3_errmsg( _database ) );464 if( DEBUG_SQL ) NSLog( @"SQL ERROR: %s", sqlite3_errmsg( _database ) ); 463 465 sqlite3_exec( _database, "ROLLBACK TRANSACTION", NULL, NULL, NULL ); 464 466 return nil; … … 467 469 query = "INSERT INTO attribute (entity, link, identifier, value, type) VALUES (?, ?, ?, ?, ?)"; 468 470 if( sqlite3_prepare( _database, query, -1, &compiledQuery, NULL ) != SQLITE_OK ) { 469 if( NSDebugEnabled) NSLog( @"SQL ERROR: %s", sqlite3_errmsg( _database ) );471 if( DEBUG_SQL ) NSLog( @"SQL ERROR: %s", sqlite3_errmsg( _database ) ); 470 472 sqlite3_exec( _database, "ROLLBACK TRANSACTION", NULL, NULL, NULL ); 471 473 return nil; … … 511 513 512 514 if( sqlite3_finalize( compiledQuery ) != SQLITE_OK ) { 513 if( NSDebugEnabled) NSLog( @"SQL ERROR: %s", sqlite3_errmsg( _database ) );515 if( DEBUG_SQL ) NSLog( @"SQL ERROR: %s", sqlite3_errmsg( _database ) ); 514 516 sqlite3_exec( _database, "ROLLBACK TRANSACTION", NULL, NULL, NULL ); 515 517 return nil; … … 517 519 518 520 if( sqlite3_exec( _database, "COMMIT TRANSACTION", NULL, NULL, NULL ) != SQLITE_OK ) { 519 if( NSDebugEnabled) NSLog( @"SQL ERROR: %s", sqlite3_errmsg( _database ) );521 if( DEBUG_SQL ) NSLog( @"SQL ERROR: %s", sqlite3_errmsg( _database ) ); 520 522 sqlite3_exec( _database, "ROLLBACK TRANSACTION", NULL, NULL, NULL ); 521 523 return nil; … … 612 614 613 615 @synchronized( self ) { 614 if( NSDebugEnabled) sqlite3_trace( _database, _printSQL, NULL );616 if( DEBUG_SQL ) sqlite3_trace( _database, _printSQL, NULL ); 615 617 sqlite3_busy_timeout( _database, 2500 ); // 2.5 seconds 616 618 if( sqlite3_exec( _database, [setup UTF8String], NULL, NULL, NULL ) != SQLITE_OK ) { 617 if( NSDebugEnabled) NSLog( @"SQL ERROR: %s", sqlite3_errmsg( _database ) );619 if( DEBUG_SQL ) NSLog( @"SQL ERROR: %s", sqlite3_errmsg( _database ) ); 618 620 sqlite3_exec( _database, "ROLLBACK TRANSACTION", NULL, NULL, NULL ); 619 621 return NO; … … 688 690 sqlite3_stmt *compiledQuery = NULL; 689 691 if( sqlite3_prepare( _database, query, -1, &compiledQuery, NULL ) != SQLITE_OK ) { 690 if( NSDebugEnabled) NSLog( @"SQL ERROR: %s", sqlite3_errmsg( _database ) );692 if( DEBUG_SQL ) NSLog( @"SQL ERROR: %s", sqlite3_errmsg( _database ) ); 691 693 sqlite3_exec( _database, "ROLLBACK TRANSACTION", NULL, NULL, NULL ); 692 694 return 0; … … 703 705 sqlite3_step( compiledQuery ); 704 706 if( sqlite3_finalize( compiledQuery ) != SQLITE_OK ) { 705 if( NSDebugEnabled) NSLog( @"SQL ERROR: %s", sqlite3_errmsg( _database ) );707 if( DEBUG_SQL ) NSLog( @"SQL ERROR: %s", sqlite3_errmsg( _database ) ); 706 708 sqlite3_exec( _database, "ROLLBACK TRANSACTION", NULL, NULL, NULL ); 707 709 return 0; … … 710 712 userIdentifier = sqlite3_last_insert_rowid( _database ); 711 713 if( ! userIdentifier ) { 712 if( NSDebugEnabled) NSLog( @"SQL ERROR: %s", sqlite3_errmsg( _database ) );714 if( DEBUG_SQL ) NSLog( @"SQL ERROR: %s", sqlite3_errmsg( _database ) ); 713 715 sqlite3_exec( _database, "ROLLBACK TRANSACTION", NULL, NULL, NULL ); 714 716 return 0;
