Forráskód Böngészése

pragmas are confusing.

August Mueller 13 éve
szülő
commit
1777d2e981
2 módosított fájl, 19 hozzáadás és 1 törlés
  1. 1 1
      README.markdown
  2. 18 0
      src/fmdb.m

+ 1 - 1
README.markdown

@@ -42,7 +42,7 @@ Before you can interact with the database, it must be opened.  Opening fails if
 	
 ### Executing Updates
 
-Any sort of SQL statement which is not a `SELECT` statement qualifies as an update.  This includes `CREATE`, `PRAGMA`, `UPDATE`, `INSERT`, `ALTER`, `COMMIT`, `BEGIN`, `DETACH`, `DELETE`, `DROP`, `END`, `EXPLAIN`, `VACUUM`, and `REPLACE` statements (plus many more).  Basically, if your SQL statement does not begin with `SELECT`, it is an update statement.
+Any sort of SQL statement which is not a `SELECT` statement qualifies as an update.  This includes `CREATE`, `UPDATE`, `INSERT`, `ALTER`, `COMMIT`, `BEGIN`, `DETACH`, `DELETE`, `DROP`, `END`, `EXPLAIN`, `VACUUM`, and `REPLACE` statements (plus many more).  Basically, if your SQL statement does not begin with `SELECT`, it is an update statement.
 
 Executing updates returns a single value, a `BOOL`.  A return value of `YES` means the update was successfully executed, and a return value of `NO` means that some error was encountered.  You may invoke the `-lastErrorMessage` and `-lastErrorCode` methods to retrieve more information.
 

+ 18 - 0
src/fmdb.m

@@ -69,6 +69,24 @@ int main (int argc, const char * argv[]) {
     FMDBQuickCheck(([db boolForQuery:@"SELECT ? not null", [NSData data]]));
 
     
+    
+    // how do we do pragmas?  Like so:
+    FMResultSet *ps = [db executeQuery:@"PRAGMA journal_mode=delete"];
+    FMDBQuickCheck(![db hadError]);
+    FMDBQuickCheck(ps);
+    FMDBQuickCheck([ps next]);
+    [ps close];
+    
+    // oh, but some pragmas require updates?
+    [db executeUpdate:@"PRAGMA page_size=2048"];
+    FMDBQuickCheck(![db hadError]);
+    
+    // what about a vacuum?
+    [db executeUpdate:@"vacuum"];
+    FMDBQuickCheck(![db hadError]);
+    
+    exit(0);
+    
     // but of course, I don't bother checking the error codes below.
     // Bad programmer, no cookie.