Changeset 3406

Show
Ignore:
Timestamp:
11/23/06 15:01:22 (2 years ago)
Author:
timothy
Message:

Disabling the SQL logging by default.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/Models/JVSQLChatTranscript.m

    r3346 r3406  
    88#import <sys/stat.h> 
    99#import <unistd.h> 
     10 
     11#define DEBUG_SQL 0 
    1012 
    1113@interface JVSQLChatTranscript (JVSQLChatTranscriptPrivate) 
     
    351353                sqlite3_stmt *compiledMsgQuery = NULL; 
    352354                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 ) ); 
    354356                        sqlite3_exec( _database, "ROLLBACK TRANSACTION", NULL, NULL, NULL ); 
    355357                        return nil; 
     
    370372                sqlite3_step( compiledMsgQuery ); 
    371373                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 ) ); 
    373375                        sqlite3_exec( _database, "ROLLBACK TRANSACTION", NULL, NULL, NULL ); 
    374376                        return nil; 
     
    377379                messageIdentifier = sqlite3_last_insert_rowid( _database ); 
    378380                if( ! messageIdentifier ) { 
    379                         if( NSDebugEnabled ) NSLog( @"SQL ERROR: %s", sqlite3_errmsg( _database ) ); 
     381                        if( DEBUG_SQL ) NSLog( @"SQL ERROR: %s", sqlite3_errmsg( _database ) ); 
    380382                        sqlite3_exec( _database, "ROLLBACK TRANSACTION", NULL, NULL, NULL ); 
    381383                        return nil; 
     
    383385 
    384386                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 ) ); 
    386388                        sqlite3_exec( _database, "ROLLBACK TRANSACTION", NULL, NULL, NULL ); 
    387389                        return nil; 
     
    439441                sqlite3_stmt *compiledQuery = NULL; 
    440442                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 ) ); 
    442444                        sqlite3_exec( _database, "ROLLBACK TRANSACTION", NULL, NULL, NULL ); 
    443445                        return nil; 
     
    453455                sqlite3_step( compiledQuery ); 
    454456                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 ) ); 
    456458                        sqlite3_exec( _database, "ROLLBACK TRANSACTION", NULL, NULL, NULL ); 
    457459                        return nil; 
     
    460462                eventIdentifier = sqlite3_last_insert_rowid( _database ); 
    461463                if( ! eventIdentifier ) { 
    462                         if( NSDebugEnabled ) NSLog( @"SQL ERROR: %s", sqlite3_errmsg( _database ) ); 
     464                        if( DEBUG_SQL ) NSLog( @"SQL ERROR: %s", sqlite3_errmsg( _database ) ); 
    463465                        sqlite3_exec( _database, "ROLLBACK TRANSACTION", NULL, NULL, NULL ); 
    464466                        return nil; 
     
    467469                query = "INSERT INTO attribute (entity, link, identifier, value, type) VALUES (?, ?, ?, ?, ?)"; 
    468470                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 ) ); 
    470472                        sqlite3_exec( _database, "ROLLBACK TRANSACTION", NULL, NULL, NULL ); 
    471473                        return nil; 
     
    511513 
    512514                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 ) ); 
    514516                        sqlite3_exec( _database, "ROLLBACK TRANSACTION", NULL, NULL, NULL ); 
    515517                        return nil; 
     
    517519 
    518520                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 ) ); 
    520522                        sqlite3_exec( _database, "ROLLBACK TRANSACTION", NULL, NULL, NULL ); 
    521523                        return nil; 
     
    612614 
    613615        @synchronized( self ) { 
    614                 if( NSDebugEnabled ) sqlite3_trace( _database, _printSQL, NULL ); 
     616                if( DEBUG_SQL ) sqlite3_trace( _database, _printSQL, NULL ); 
    615617                sqlite3_busy_timeout( _database, 2500 ); // 2.5 seconds 
    616618                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 ) ); 
    618620                        sqlite3_exec( _database, "ROLLBACK TRANSACTION", NULL, NULL, NULL ); 
    619621                        return NO; 
     
    688690                sqlite3_stmt *compiledQuery = NULL; 
    689691                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 ) ); 
    691693                        sqlite3_exec( _database, "ROLLBACK TRANSACTION", NULL, NULL, NULL ); 
    692694                        return 0; 
     
    703705                sqlite3_step( compiledQuery ); 
    704706                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 ) ); 
    706708                        sqlite3_exec( _database, "ROLLBACK TRANSACTION", NULL, NULL, NULL ); 
    707709                        return 0; 
     
    710712                userIdentifier = sqlite3_last_insert_rowid( _database ); 
    711713                if( ! userIdentifier ) { 
    712                         if( NSDebugEnabled ) NSLog( @"SQL ERROR: %s", sqlite3_errmsg( _database ) ); 
     714                        if( DEBUG_SQL ) NSLog( @"SQL ERROR: %s", sqlite3_errmsg( _database ) ); 
    713715                        sqlite3_exec( _database, "ROLLBACK TRANSACTION", NULL, NULL, NULL ); 
    714716                        return 0;