Skip to content

Commit 4b13a13

Browse files
committed
DB version check: Minor improvements
* improve error reporting when table is not present in 'version': "invalid version 0 for table clusterer found, expected 4" (???) vs. "'clusterer' entry not found in version table, expected ver 4" * add a way of checking if the table does not exist, programmatically
1 parent bbfa2b0 commit 4b13a13

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

db/db.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -433,7 +433,7 @@ int db_table_version(const db_func_t* dbf, db_con_t* connection, const str* tabl
433433
if (RES_ROW_N(res) == 0) {
434434
LM_DBG("no row for table %.*s found\n",
435435
table->len, ZSW(table->s));
436-
return 0;
436+
return -2;
437437
}
438438

439439
if (RES_ROW_N(res) != 1) {
@@ -475,6 +475,12 @@ int db_check_table_version(db_func_t* dbf, db_con_t* dbh, const str* table, cons
475475

476476
ver = db_table_version(dbf, dbh, table);
477477
if (ver < 0) {
478+
if (ver == -2) {
479+
LM_ERR("'%.*s' record not found in '%s' table, expected ver %d\n",
480+
table->len, table->s, db_version_table, version);
481+
return -2;
482+
}
483+
478484
LM_ERR("querying version for table %.*s\n", table->len, table->s);
479485
return -1;
480486
} else if (ver != version) {

0 commit comments

Comments
 (0)