diff options
author | 2010-01-03 17:13:45 -0500 | |
---|---|---|
committer | 2010-01-03 17:13:45 -0500 | |
commit | 67085821cfd1d5524b386dee083f877b74e93f2e (patch) | |
tree | c64216bacfaaad2793c146651100f3c289e5daf9 /src/sqlite.sml | |
parent | 60dfbfbc250c197357d84771bdc5aaaa812c573e (diff) |
Database quotas
Diffstat (limited to 'src/sqlite.sml')
-rw-r--r-- | src/sqlite.sml | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/src/sqlite.sml b/src/sqlite.sml index 485e43b4..593db22e 100644 --- a/src/sqlite.sml +++ b/src/sqlite.sml @@ -260,6 +260,8 @@ fun init {dbstring, prepared = ss, tables, views, sequences} = newline, string "sqlite3 *sqlite;", newline, + string "sqlite3_stmt *stmt;", + newline, string "uw_conn *conn;", newline, newline, @@ -269,6 +271,44 @@ fun init {dbstring, prepared = ss, tables, views, sequences} = string "\"Can't open SQLite database.\");", newline, newline, + string "if (uw_database_max < SIZE_MAX) {", + newline, + box [string "char buf[100];", + newline, + newline, + + string "sprintf(buf, \"PRAGMA max_page_count = %llu\", (unsigned long long)(uw_database_max / 1024));", + newline, + newline, + + string "if (sqlite3_prepare_v2(sqlite, buf, -1, &stmt, NULL) != SQLITE_OK) {", + newline, + box [string "sqlite3_close(sqlite);", + newline, + string "uw_error(ctx, FATAL, \"Can't prepare max_page_count query for SQLite database\");", + newline], + string "}", + newline, + newline, + + string "if (sqlite3_step(stmt) != SQLITE_ROW) {", + newline, + box [string "sqlite3_finalize(stmt);", + newline, + string "sqlite3_close(sqlite);", + newline, + string "uw_error(ctx, FATAL, \"Can't set max_page_count parameter for SQLite database\");", + newline], + string "}", + newline, + newline, + + string "sqlite3_finalize(stmt);", + newline], + string "}", + newline, + newline, + string "conn = calloc(1, sizeof(uw_conn));", newline, string "conn->conn = sqlite;", |