* Check the table version * 0 means ok, -1 means an error occurred */
| 466 | * 0 means ok, -1 means an error occurred |
| 467 | */ |
| 468 | int db_check_table_version(db_func_t* dbf, db_con_t* dbh, const str* table, const unsigned int version) |
| 469 | { |
| 470 | int ver; |
| 471 | |
| 472 | /* if DB does not support QUERY, return TRUE */ |
| 473 | if (!DB_CAPABILITY(*dbf, DB_CAP_QUERY)) |
| 474 | return 0; |
| 475 | |
| 476 | ver = db_table_version(dbf, dbh, table); |
| 477 | 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 | |
| 484 | LM_ERR("querying version for table %.*s\n", table->len, table->s); |
| 485 | return -1; |
| 486 | } else if (ver != version) { |
| 487 | LM_ERR("invalid version %d for table %.*s found, expected %d\n", |
| 488 | ver, table->len, table->s, version); |
| 489 | return -1; |
| 490 | } |
| 491 | return 0; |
| 492 | } |
| 493 | |
| 494 | /* |
| 495 | * Store name of table that will be used by |
no test coverage detected