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}
)
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
distroquery.c

View File

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