Fix Sqlite3 weird problem by adding compile option -fno-toplevel-reorder

This commit is contained in:
Silvan Calarco 2020-06-20 14:37:50 +02:00
parent 6e5e4496d7
commit fac5730549
2 changed files with 15 additions and 10 deletions

View File

@ -44,7 +44,10 @@ target_link_libraries(distromatic
${LIBIBERTY} ${LIBIBERTY}
) )
target_include_directories(distromatic PUBLIC ${RPM_INCLUDE_DIRS}) target_include_directories(distromatic PUBLIC ${RPM_INCLUDE_DIRS})
target_compile_options(distromatic PUBLIC -O2 -g -Wall -std=gnu11 -pedantic ${RPM_CFLAGS_OTHER}) #
# NOTE: -fno-toplevel-reorder required to prevent Sqlite3 weird problems
#
target_compile_options(distromatic PUBLIC -O2 -fno-toplevel-reorder -g -Wall -std=gnu11 -pedantic ${RPM_CFLAGS_OTHER})
add_executable(distroquery add_executable(distroquery
distroquery.c distroquery.c

View File

@ -216,8 +216,7 @@ int generateSQLite_provided(struct configTag* ct, sqlite3 *db, int arch) {
struct providedList* provided; struct providedList* provided;
int i, thisrep; int i, thisrep;
snprintf(sqlite3_query, PATH_MAX, "provided"); SQLite_init_table(db, "provided", SQLITE_TABLE_provided);
SQLite_init_table(db, sqlite3_query, SQLITE_TABLE_provided);
SQLite_begin_transaction(db); SQLite_begin_transaction(db);
provided = ct->providedlist_idx[arch][0]; provided = ct->providedlist_idx[arch][0];
@ -231,17 +230,20 @@ int generateSQLite_provided(struct configTag* ct, sqlite3 *db, int arch) {
} }
} }
if (thisrep) { if (thisrep) {
snprintf(sqlite3_query, PATH_MAX, "INSERT INTO provided VALUES(%ld,?,%ld,%d);", snprintf(sqlite3_query, PATH_MAX, "INSERT INTO provided VALUES(%ld,?,%ld,%d);",
provided->id, provided->id,
provided->flags, provided->flags,
provided->numproviders); provided->numproviders);
sqlite3_prepare_v2(db, sqlite3_query, -1, &stmt, NULL); if (sqlite3_prepare_v3(db, sqlite3_query, -1, 0, &stmt, NULL)) {
sqlite3_bind_text(stmt, 1, provided->name, -1, SQLITE_STATIC); fprintf(stderr, "ERROR: sqlite3_prepare_v2: %s (%s)\n", sqlite3_errmsg(db), sqlite3_query);
if (sqlite3_step(stmt) != SQLITE_DONE) { return 1;
}
sqlite3_bind_text(stmt, 1, provided->name, -1, SQLITE_STATIC);
if (sqlite3_step(stmt) != SQLITE_DONE) {
fprintf(stderr, "ERROR: SQLite: (%s) %s\n", sqlite3_query, sqlite3_errmsg(db)); fprintf(stderr, "ERROR: SQLite: (%s) %s\n", sqlite3_query, sqlite3_errmsg(db));
return 1; return 3;
} }
sqlite3_finalize(stmt); sqlite3_finalize(stmt);
} }
provided = provided->next; provided = provided->next;
} }