Commit fac5730549689c974f7cd14a8a4fec4e6bffbdef

Authored by Silvan Calarco
1 parent 6e5e4496d7
Exists in master

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

Showing 2 changed files with 15 additions and 10 deletions Side-by-side Diff

... ... @@ -44,7 +44,10 @@
44 44 ${LIBIBERTY}
45 45 )
46 46 target_include_directories(distromatic PUBLIC ${RPM_INCLUDE_DIRS})
47   -target_compile_options(distromatic PUBLIC -O2 -g -Wall -std=gnu11 -pedantic ${RPM_CFLAGS_OTHER})
  47 +#
  48 +# NOTE: -fno-toplevel-reorder required to prevent Sqlite3 weird problems
  49 +#
  50 +target_compile_options(distromatic PUBLIC -O2 -fno-toplevel-reorder -g -Wall -std=gnu11 -pedantic ${RPM_CFLAGS_OTHER})
48 51  
49 52 add_executable(distroquery
50 53 distroquery.c
src/backend-sqlite3.c
... ... @@ -216,8 +216,7 @@
216 216 struct providedList* provided;
217 217 int i, thisrep;
218 218  
219   - snprintf(sqlite3_query, PATH_MAX, "provided");
220   - SQLite_init_table(db, sqlite3_query, SQLITE_TABLE_provided);
  219 + SQLite_init_table(db, "provided", SQLITE_TABLE_provided);
221 220 SQLite_begin_transaction(db);
222 221  
223 222 provided = ct->providedlist_idx[arch][0];
224 223  
225 224  
... ... @@ -231,17 +230,20 @@
231 230 }
232 231 }
233 232 if (thisrep) {
234   - snprintf(sqlite3_query, PATH_MAX, "INSERT INTO provided VALUES(%ld,?,%ld,%d);",
  233 + snprintf(sqlite3_query, PATH_MAX, "INSERT INTO provided VALUES(%ld,?,%ld,%d);",
235 234 provided->id,
236 235 provided->flags,
237 236 provided->numproviders);
238   - sqlite3_prepare_v2(db, sqlite3_query, -1, &stmt, NULL);
239   - sqlite3_bind_text(stmt, 1, provided->name, -1, SQLITE_STATIC);
240   - if (sqlite3_step(stmt) != SQLITE_DONE) {
  237 + if (sqlite3_prepare_v3(db, sqlite3_query, -1, 0, &stmt, NULL)) {
  238 + fprintf(stderr, "ERROR: sqlite3_prepare_v2: %s (%s)\n", sqlite3_errmsg(db), sqlite3_query);
  239 + return 1;
  240 + }
  241 + sqlite3_bind_text(stmt, 1, provided->name, -1, SQLITE_STATIC);
  242 + if (sqlite3_step(stmt) != SQLITE_DONE) {
241 243 fprintf(stderr, "ERROR: SQLite: (%s) %s\n", sqlite3_query, sqlite3_errmsg(db));
242   - return 1;
243   - }
244   - sqlite3_finalize(stmt);
  244 + return 3;
  245 + }
  246 + sqlite3_finalize(stmt);
245 247 }
246 248 provided = provided->next;
247 249 }