Ignore:
Timestamp:
Apr 9, 2013, 6:46:31 PM (7 years ago)
Author:
snc@…
Message:

merge from trunk

Location:
branches/gsoc11-statistics/base
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • branches/gsoc11-statistics/base

  • branches/gsoc11-statistics/base/src/cregistry/entry.c

    r88412 r105085  
    122122    char* query = "INSERT INTO registry.ports "
    123123        "(name, version, revision, variants, epoch) VALUES (?, ?, ?, ?, ?)";
    124     if ((sqlite3_prepare(reg->db, query, -1, &stmt, NULL) == SQLITE_OK)
     124    if ((sqlite3_prepare_v2(reg->db, query, -1, &stmt, NULL) == SQLITE_OK)
    125125            && (sqlite3_bind_text(stmt, 1, name, -1, SQLITE_STATIC)
    126126                == SQLITE_OK)
     
    191191        "AND revision=? AND variants=? AND epoch!=?";
    192192    }
    193     if ((sqlite3_prepare(reg->db, query, -1, &stmt, NULL) == SQLITE_OK)
     193    if ((sqlite3_prepare_v2(reg->db, query, -1, &stmt, NULL) == SQLITE_OK)
    194194            && (sqlite3_bind_text(stmt, 1, name, -1, SQLITE_STATIC)
    195195                == SQLITE_OK)
     
    250250    char* files_query = "DELETE FROM registry.files WHERE id=?";
    251251    char* dependencies_query = "DELETE FROM registry.dependencies WHERE id=?";
    252     if ((sqlite3_prepare(reg->db, ports_query, -1, &ports, NULL) == SQLITE_OK)
     252    if ((sqlite3_prepare_v2(reg->db, ports_query, -1, &ports, NULL) == SQLITE_OK)
    253253            && (sqlite3_bind_int64(ports, 1, entry->id) == SQLITE_OK)
    254             && (sqlite3_prepare(reg->db, files_query, -1, &files, NULL)
     254            && (sqlite3_prepare_v2(reg->db, files_query, -1, &files, NULL)
    255255                == SQLITE_OK)
    256256            && (sqlite3_bind_int64(files, 1, entry->id) == SQLITE_OK)
    257             && (sqlite3_prepare(reg->db, dependencies_query, -1, &dependencies,
     257            && (sqlite3_prepare_v2(reg->db, dependencies_query, -1, &dependencies,
    258258                    NULL) == SQLITE_OK)
    259259            && (sqlite3_bind_int64(dependencies, 1, entry->id) == SQLITE_OK)) {
     
    497497    char* query = "SELECT id FROM registry.files WHERE actual_path=? AND active";
    498498    int lower_bound = 0;
    499     if ((sqlite3_prepare(reg->db, query, -1, &stmt, NULL) == SQLITE_OK)
     499    if ((sqlite3_prepare_v2(reg->db, query, -1, &stmt, NULL) == SQLITE_OK)
    500500            && (sqlite3_bind_text(stmt, 1, path, -1, SQLITE_STATIC)
    501501                == SQLITE_OK)) {
     
    544544    sqlite_int64 result = 0;
    545545    char* query = "SELECT id FROM registry.files WHERE actual_path=? AND active";
    546     if ((sqlite3_prepare(reg->db, query, -1, &stmt, NULL) == SQLITE_OK)
     546    if ((sqlite3_prepare_v2(reg->db, query, -1, &stmt, NULL) == SQLITE_OK)
    547547            && (sqlite3_bind_text(stmt, 1, path, -1, SQLITE_STATIC)
    548548                == SQLITE_OK)) {
     
    581581    query = sqlite3_mprintf("SELECT %q FROM registry.ports WHERE id=%lld", key,
    582582            entry->id);
    583     if (sqlite3_prepare(reg->db, query, -1, &stmt, NULL) == SQLITE_OK) {
     583    if (sqlite3_prepare_v2(reg->db, query, -1, &stmt, NULL) == SQLITE_OK) {
    584584        int r;
    585585        do {
     
    639639    query = sqlite3_mprintf("UPDATE registry.ports SET %q = '%q' WHERE id=%lld",
    640640            key, value, entry->id);
    641     if (sqlite3_prepare(reg->db, query, -1, &stmt, NULL) == SQLITE_OK) {
     641    if (sqlite3_prepare_v2(reg->db, query, -1, &stmt, NULL) == SQLITE_OK) {
    642642        int r;
    643643        do {
     
    687687    char* insert = "INSERT INTO registry.files (id, path, mtime, active) "
    688688        "VALUES (?, ?, 0, 0)";
    689     if ((sqlite3_prepare(reg->db, insert, -1, &stmt, NULL) == SQLITE_OK)
     689    if ((sqlite3_prepare_v2(reg->db, insert, -1, &stmt, NULL) == SQLITE_OK)
    690690            && (sqlite3_bind_int64(stmt, 1, entry->id) == SQLITE_OK)) {
    691691        int i;
     
    739739    sqlite3_stmt* stmt = NULL;
    740740    char* query = "DELETE FROM registry.files WHERE path=? AND id=?";
    741     if ((sqlite3_prepare(reg->db, query, -1, &stmt, NULL) == SQLITE_OK)
     741    if ((sqlite3_prepare_v2(reg->db, query, -1, &stmt, NULL) == SQLITE_OK)
    742742            && (sqlite3_bind_int64(stmt, 2, entry->id) == SQLITE_OK)) {
    743743        int i;
     
    796796    sqlite3_stmt* stmt = NULL;
    797797    char* query = "SELECT path FROM registry.files WHERE id=? ORDER BY path";
    798     if ((sqlite3_prepare(reg->db, query, -1, &stmt, NULL) == SQLITE_OK)
     798    if ((sqlite3_prepare_v2(reg->db, query, -1, &stmt, NULL) == SQLITE_OK)
    799799            && (sqlite3_bind_int64(stmt, 1, entry->id) == SQLITE_OK)) {
    800800        char** result = malloc(10*sizeof(char*));
     
    864864    char* query = "SELECT actual_path FROM registry.files WHERE id=? "
    865865        "AND active ORDER BY actual_path";
    866     if ((sqlite3_prepare(reg->db, query, -1, &stmt, NULL) == SQLITE_OK)
     866    if ((sqlite3_prepare_v2(reg->db, query, -1, &stmt, NULL) == SQLITE_OK)
    867867            && (sqlite3_bind_int64(stmt, 1, entry->id) == SQLITE_OK)) {
    868868        char** result = malloc(10*sizeof(char*));
     
    947947    }
    948948
    949     if (sqlite3_prepare(reg->db, select_query, -1, &select, NULL) == SQLITE_OK){
    950         if ((sqlite3_prepare(reg->db, update_query, -1, &update, NULL)
     949    if (sqlite3_prepare_v2(reg->db, select_query, -1, &select, NULL) == SQLITE_OK){
     950        if ((sqlite3_prepare_v2(reg->db, update_query, -1, &update, NULL)
    951951                == SQLITE_OK)
    952952                && (sqlite3_bind_int64(update, 3, entry->id) == SQLITE_OK)) {
     
    10391039    sqlite3_stmt* stmt = NULL;
    10401040    char* query = "UPDATE registry.files SET active=0 WHERE actual_path=? AND id=?";
    1041     if ((sqlite3_prepare(reg->db, query, -1, &stmt, NULL) == SQLITE_OK)
     1041    if ((sqlite3_prepare_v2(reg->db, query, -1, &stmt, NULL) == SQLITE_OK)
    10421042            && (sqlite3_bind_int64(stmt, 2, entry->id) == SQLITE_OK)) {
    10431043        for (i=0; i<file_count && result; i++) {
     
    11401140    sqlite3_stmt* stmt = NULL;
    11411141    char* query = "INSERT INTO registry.dependencies (id, name) VALUES (?,?)";
    1142     if ((sqlite3_prepare(reg->db, query, -1, &stmt, NULL) == SQLITE_OK)
     1142    if ((sqlite3_prepare_v2(reg->db, query, -1, &stmt, NULL) == SQLITE_OK)
    11431143            && (sqlite3_bind_int64(stmt, 1, entry->id) == SQLITE_OK)
    11441144            && (sqlite3_bind_text(stmt, 2, name, -1, SQLITE_STATIC)
  • branches/gsoc11-statistics/base/src/cregistry/entry.h

    r88412 r105085  
    44 *
    55 * Copyright (c) 2007 Chris Pickel <sfiera@macports.org>
     6 * Copyright (c) 2012 The MacPorts Project
    67 * All rights reserved.
    78 *
  • branches/gsoc11-statistics/base/src/cregistry/file.c

    r88412 r105085  
    109109    int lower_bound = 0;
    110110
    111     if ((sqlite3_prepare(reg->db, query, -1, &stmt, NULL) == SQLITE_OK)
     111    if ((sqlite3_prepare_v2(reg->db, query, -1, &stmt, NULL) == SQLITE_OK)
    112112            && (sqlite3_bind_text(stmt, 1, id, -1, SQLITE_STATIC)
    113113                == SQLITE_OK)
     
    238238    query = sqlite3_mprintf("SELECT %q FROM registry.files WHERE id=%lld "
    239239            "AND path='%q'", key, file->key.id, file->key.path);
    240     if (sqlite3_prepare(reg->db, query, -1, &stmt, NULL) == SQLITE_OK) {
     240    if (sqlite3_prepare_v2(reg->db, query, -1, &stmt, NULL) == SQLITE_OK) {
    241241        int r;
    242242        do {
     
    293293    query = sqlite3_mprintf("UPDATE registry.files SET %q = '%q' WHERE id=%lld "
    294294            "AND path='%q'", key, value, file->key.id, file->key.path);
    295     if (sqlite3_prepare(reg->db, query, -1, &stmt, NULL) == SQLITE_OK) {
     295    if (sqlite3_prepare_v2(reg->db, query, -1, &stmt, NULL) == SQLITE_OK) {
    296296        int r;
    297297        do {
  • branches/gsoc11-statistics/base/src/cregistry/registry.c

    r88412 r105085  
    55 *
    66 * Copyright (c) 2007 Chris Pickel <sfiera@macports.org>
     7 * Copyright (c) 2012 The MacPorts Project
    78 * All rights reserved.
    89 *
     
    118119#endif
    119120
     121        sqlite3_busy_timeout(reg->db, 25);
     122
    120123        if (init_db(reg->db, errPtr)) {
    121124            reg->status = reg_none;
     
    205208        int r;
    206209        do {
    207             r = sqlite3_prepare(reg->db, query, -1, &stmt, NULL);
     210            r = sqlite3_prepare_v2(reg->db, query, -1, &stmt, NULL);
    208211        } while (r == SQLITE_BUSY);
    209212        if (r == SQLITE_OK) {
     
    230233            } while (r == SQLITE_BUSY);
    231234
     235            sqlite3_finalize(stmt);
     236            stmt = NULL;
     237
    232238            if (result) {
    233239                result &= update_db(reg->db, errPtr);
     
    264270        return 0;
    265271    }
    266     if (sqlite3_prepare(reg->db, query, -1, &stmt, NULL) == SQLITE_OK) {
     272    if (sqlite3_prepare_v2(reg->db, query, -1, &stmt, NULL) == SQLITE_OK) {
    267273        int r;
    268274        reg_entry* entry;
     
    361367 */
    362368int reg_start_write(reg_registry* reg, reg_error* errPtr) {
    363     if (reg_start(reg, "BEGIN EXCLUSIVE", errPtr)) {
     369    if (reg_start(reg, "BEGIN IMMEDIATE", errPtr)) {
    364370        reg->status |= reg_transacting | reg_can_write;
    365371        return 1;
     
    372378 * Helper function for `reg_commit` and `reg_rollback`.
    373379 */
    374 static int reg_end(reg_registry* reg, const char* query, reg_error* errPtr) {
     380static int reg_end(reg_registry* reg, const char* query, reg_error* errPtr, int is_rollback) {
    375381    if (!(reg->status & reg_transacting)) {
    376382        reg_throw(errPtr, REG_MISUSE, "couldn't end transaction because no "
     
    384390                return 1;
    385391            }
    386         } while (r == SQLITE_BUSY);
     392        } while (r == SQLITE_BUSY && !is_rollback);
    387393        reg_sqlite_error(reg->db, errPtr, NULL);
    388394        return 0;
     
    399405 */
    400406int reg_commit(reg_registry* reg, reg_error* errPtr) {
    401     if (reg_end(reg, "COMMIT", errPtr)) {
     407    if (reg_end(reg, "COMMIT", errPtr, 0)) {
    402408        reg->status &= ~(reg_transacting | reg_can_write);
    403409        return 1;
     
    416422 */
    417423int reg_rollback(reg_registry* reg, reg_error* errPtr) {
    418     if (reg_end(reg, "ROLLBACK", errPtr)) {
     424    if (reg_end(reg, "ROLLBACK", errPtr, 1)) {
    419425        reg->status &= ~(reg_transacting | reg_can_write);
    420426        return 1;
     
    447453    }
    448454
    449     if (sqlite3_prepare(db, "VACUUM", -1, &stmt, NULL) == SQLITE_OK) {
     455    if (sqlite3_prepare_v2(db, "VACUUM", -1, &stmt, NULL) == SQLITE_OK) {
    450456        int r;
    451457        /* XXX: Busy waiting, consider using sqlite3_busy_handler/timeout */
  • branches/gsoc11-statistics/base/src/cregistry/registry.h

    r88412 r105085  
    55 *
    66 * Copyright (c) 2007 Chris Pickel <sfiera@macports.org>
     7 * Copyright (c) 2012 The MacPorts Project
    78 * All rights reserved.
    89 *
  • branches/gsoc11-statistics/base/src/cregistry/sql.c

    r88412 r105085  
    44 *
    55 * Copyright (c) 2007 Chris Pickel <sfiera@macports.org>
     6 * Copyright (c) 2012 The MacPorts Project
    67 * All rights reserved.
    78 *
     
    5253int do_queries(sqlite3* db, char** queries, reg_error* errPtr) {
    5354    char** query;
     55    sqlite3_stmt* stmt = NULL;
     56    int r = SQLITE_OK;
     57
    5458    for (query = queries; *query != NULL; query++) {
    55         sqlite3_stmt* stmt = NULL;
    56         if ((sqlite3_prepare(db, *query, -1, &stmt, NULL) != SQLITE_OK)
    57                 || (sqlite3_step(stmt) != SQLITE_DONE)) {
     59        if ((r = sqlite3_prepare_v2(db, *query, -1, &stmt, NULL)) != SQLITE_OK) {
     60            sqlite3_finalize(stmt);
     61            break;
     62        }
     63
     64        do {
     65            r = sqlite3_step(stmt);
     66        } while (r == SQLITE_BUSY);
     67
     68        sqlite3_finalize(stmt);
     69
     70        /* Either execution succeeded and r == SQLITE_DONE | SQLITE_ROW, or there was an error */
     71        if (r != SQLITE_DONE && r != SQLITE_ROW) {
     72            /* stop executing statements in case of errors */
     73            break;
     74        }
     75    }
     76
     77    switch (r) {
     78        case SQLITE_OK:
     79        case SQLITE_DONE:
     80        case SQLITE_ROW:
     81            return 1;
     82        default:
     83            /* handle errors */
    5884            reg_sqlite_error(db, errPtr, *query);
    59             if (stmt) {
    60                 sqlite3_finalize(stmt);
    61             }
    6285            return 0;
    63         }
    64         sqlite3_finalize(stmt);
    65     }
    66     return 1;
     86    }
    6787}
    6888
     
    151171
    152172/**
     173 * Tries to ROLLBACK a currently running transaction on the SQLite database.
     174 * Errors are silently ignored to preserve errors that have been set before and
     175 * are probably the root cause of why we did the rollback in the first place.
     176 *
     177 * @param [in] db    database to rollback
     178 * @return           true if success, false on failure
     179 */
     180static int rollback_db(sqlite3* db) {
     181    char* rollback = "ROLLBACK";
     182    sqlite3_stmt* stmt = NULL;
     183
     184    /*puts("Attempting to ROLLBACK...");*/
     185
     186    if (sqlite3_prepare_v2(db, rollback, -1, &stmt, NULL) != SQLITE_OK) {
     187        /*printf("failed prepare: %d: %s\n", sqlite3_errcode(db), sqlite3_errmsg(db));*/
     188        return 0;
     189    }
     190
     191    if (sqlite3_step(stmt) != SQLITE_DONE) {
     192        /*printf("failed step: %d: %s\n", sqlite3_errcode(db), sqlite3_errmsg(db));*/
     193        return 0;
     194    }
     195
     196    /*puts("success.");*/
     197
     198    return 1;
     199}
     200
     201/**
    153202 * Updates the database if necessary. This function queries the current database version
    154203 * from the metadata table and executes SQL to update the schema to newer versions if needed.
     
    161210int update_db(sqlite3* db, reg_error* errPtr) {
    162211    const char* version;
    163     char* query = "SELECT value FROM registry.metadata WHERE key = 'version'";
    164     sqlite3_stmt *stmt = NULL;
    165 
    166     if ((sqlite3_prepare(db, query, -1, &stmt, NULL) != SQLITE_OK)
    167             || (sqlite3_step(stmt) != SQLITE_ROW)) {
    168         goto reg_err_out;
    169     }
    170     if (NULL == (version = (const char *)sqlite3_column_text(stmt, 0))) {
    171         goto reg_err_out;
    172     }
    173     /* can't call rpm_vercomp directly, because it is static, but can call sql_version */
    174     if (sql_version(NULL, strlen(version), version, strlen("1.1"), "1.1") < 0) {
    175         /* conversion necessary, add binary field and index to files table */
    176         static char* version_1_1_queries[] = {
    177             "BEGIN",
    178 
    179             "ALTER TABLE registry.files ADD COLUMN binary BOOL",
    180             "CREATE INDEX registry.file_binary ON files(binary)",
    181 
    182             "UPDATE registry.metadata SET value = '1.100' WHERE key = 'version'",
    183 
    184             "COMMIT",
    185             NULL
    186         };
    187 
    188         if (!do_queries(db, version_1_1_queries, errPtr)) {
    189             goto err_out;
    190         }
    191 
    192         /* TODO: Walk the file tree and set the binary field */
    193     }
     212    int r;
     213    int did_update = 0; /* true, if an update was done and the loop should be run again */
     214    char* q_begin = "BEGIN";
     215    char* q_version = "SELECT value FROM registry.metadata WHERE key = 'version'";
     216    char* query = q_begin;
     217    sqlite3_stmt* stmt = NULL;
     218
     219    do {
     220        did_update = 0;
     221
     222        /* open a transaction to prevent a check-and-change race condition between
     223         * multiple port(1) instances */
     224        if ((r = sqlite3_prepare_v2(db, query, -1, &stmt, NULL)) != SQLITE_OK) {
     225            break;
     226        }
     227
     228        if ((r = sqlite3_step(stmt)) != SQLITE_DONE) {
     229            break;
     230        }
     231
     232        sqlite3_finalize(stmt);
     233        stmt = NULL;
     234
     235        /* query current version number */
     236        query = q_version;
     237        if ((r = sqlite3_prepare_v2(db, query, -1, &stmt, NULL)) != SQLITE_OK) {
     238            break;
     239        }
     240
     241        r = sqlite3_step(stmt);
     242        if (r == SQLITE_DONE) {
     243            /* the version number was not found */
     244            reg_throw(errPtr, REG_INVALID, "Version number in metadata table not found.");
     245            sqlite3_finalize(stmt);
     246            rollback_db(db);
     247            return 0;
     248        }
     249        if (r != SQLITE_ROW) {
     250            /* an error occured querying */
     251            break;
     252        }
     253        if (NULL == (version = (const char *)sqlite3_column_text(stmt, 0))) {
     254            reg_throw(errPtr, REG_INVALID, "Version number in metadata table is NULL.");
     255            sqlite3_finalize(stmt);
     256            rollback_db(db);
     257            return 0;
     258        }
     259
     260        /* we can't call vercmp directly because it's static, but we have
     261         * sql_version, which is basically an alias */
     262        if (sql_version(NULL, -1, version, -1, "1.1") < 0) {
     263            /* we need to update to 1.1, add binary field and index to files
     264             * table */
     265            static char* version_1_1_queries[] = {
     266#if SQLITE_VERSION_NUMBER >= 3002000
     267                "ALTER TABLE registry.files ADD COLUMN binary BOOL",
     268#else
     269                /*
     270                 * SQLite < 3.2.0 doesn't support ALTER TABLE ADD COLUMN
     271                 * Unfortunately, Tiger ships with SQLite < 3.2.0 (#34463)
     272                 * This is taken from http://www.sqlite.org/faq.html#q11
     273                 */
     274
     275                /* Create a temporary table */
     276                "CREATE TEMPORARY TABLE mp_files_backup (id INTEGER, path TEXT, "
     277                    "actual_path TEXT, active INT, mtime DATETIME, md5sum TEXT, editable INT, "
     278                    "FOREIGN KEY(id) REFERENCES ports(id))",
     279
     280                /* Copy all data into the temporary table */
     281                "INSERT INTO mp_files_backup SELECT id, path, actual_path, active, mtime, "
     282                    "md5sum, editable FROM registry.files",
     283
     284                /* Drop the original table and re-create it with the new structure */
     285                "DROP TABLE registry.files",
     286                "CREATE TABLE registry.files (id INTEGER, path TEXT, actual_path TEXT, "
     287                    "active INT, mtime DATETIME, md5sum TEXT, editable INT, binary BOOL, "
     288                    "FOREIGN KEY(id) REFERENCES ports(id))",
     289                "CREATE INDEX registry.file_port ON files(id)",
     290                "CREATE INDEX registry.file_path ON files(path)",
     291                "CREATE INDEX registry.file_actual ON files(actual_path)",
     292
     293                /* Copy all data back from temporary table */
     294                "INSERT INTO registry.files (id, path, actual_path, active, mtime, md5sum, "
     295                    "editable) SELECT id, path, actual_path, active, mtime, md5sum, "
     296                    "editable FROM mp_files_backup",
     297
     298                /* Remove temporary table */
     299                "DROP TABLE mp_files_backup",
     300#endif
     301                "CREATE INDEX registry.file_binary ON files(binary)",
     302
     303                "UPDATE registry.metadata SET value = '1.100' WHERE key = 'version'",
     304
     305                "COMMIT",
     306                NULL
     307            };
     308
     309            /* don't forget to finalize the version query here, or it might
     310             * cause "cannot commit transaction - SQL statements in progress",
     311             * see #32686 */
     312            sqlite3_finalize(stmt);
     313            stmt = NULL;
     314
     315            if (!do_queries(db, version_1_1_queries, errPtr)) {
     316                rollback_db(db);
     317                return 0;
     318            }
     319
     320            did_update = 1;
     321            continue;
     322        }
     323
     324        /* add new versions here, but remember to:
     325         *  - finalize the version query statement and set stmt to NULL
     326         *  - do _not_ use "BEGIN" in your query list, since a transaction has
     327         *    already been started for you
     328         *  - end your query list with "COMMIT", NULL
     329         *  - set did_update = 1 and continue;
     330         */
     331
     332        /* if we arrive here, no update was done and we should end the
     333         * transaction. Using ROLLBACK here causes problems when rolling back
     334         * other transactions later in the program. */
     335        sqlite3_finalize(stmt);
     336        stmt = NULL;
     337        r = sqlite3_exec(db, "COMMIT", NULL, NULL, NULL);
     338    } while (did_update);
     339
    194340    sqlite3_finalize(stmt);
    195     return 1;
    196 
    197 reg_err_out:
    198     reg_sqlite_error(db, errPtr, query);
    199 err_out:
    200     sqlite3_finalize(stmt);
    201     return 0;
     341    switch (r) {
     342        case SQLITE_OK:
     343        case SQLITE_DONE:
     344        case SQLITE_ROW:
     345            return 1;
     346        default:
     347            reg_sqlite_error(db, errPtr, query);
     348            return 0;
     349    }
    202350}
    203351
  • branches/gsoc11-statistics/base/src/cregistry/sql.h

    r88412 r105085  
    44 *
    55 * Copyright (c) 2007 Chris Pickel <sfiera@macports.org>
     6 * Copyright (c) 2012 The MacPorts Project
    67 * All rights reserved.
    78 *
  • branches/gsoc11-statistics/base/src/cregistry/util.c

    r88412 r105085  
    55 *
    66 * Copyright (c) 2007 Chris Pickel <sfiera@macports.org>
     7 * Copyright (c) 2012 The MacPorts Project
    78 * All rights reserved.
    89 *
     
    123124 * @param [out] objects  the objects selected
    124125 * @param [in] fn        a function to convert sqlite3_stmts to the desired type
     126 * @param [inout] data   data passed along to the cast function
    125127 * @param [in] del       a function to delete the desired type of object
    126128 * @param [out] errPtr   on error, a description of the error that occurred
     
    137139        return -1;
    138140    }
    139     if (sqlite3_prepare(reg->db, query, query_len, &stmt, NULL) == SQLITE_OK) {
     141    if (sqlite3_prepare_v2(reg->db, query, query_len, &stmt, NULL) == SQLITE_OK) {
    140142        int r;
    141143        void* row;
Note: See TracChangeset for help on using the changeset viewer.