put SQL only used in hlr-db-tool in hlr_db_tool.c
Change-Id: I3ac327dbcef37472fb13b8689d008e74b83b3bb1
This commit is contained in:
parent
d118efb789
commit
472bb0733d
|
@ -33,7 +33,6 @@ enum stmt_idx {
|
|||
DB_STMT_SET_LAST_LU_SEEN_PS,
|
||||
DB_STMT_EXISTS_BY_IMSI,
|
||||
DB_STMT_EXISTS_BY_MSISDN,
|
||||
DB_STMT_SET_IMPLICIT_LU_BY_IMSI,
|
||||
_NUM_DB_STMT
|
||||
};
|
||||
|
||||
|
|
1
src/db.c
1
src/db.c
|
@ -85,7 +85,6 @@ static const char *stmt_sql[] = {
|
|||
[DB_STMT_SET_LAST_LU_SEEN_PS] = "UPDATE subscriber SET last_lu_seen_ps = datetime($val, 'unixepoch') WHERE id = $subscriber_id",
|
||||
[DB_STMT_EXISTS_BY_IMSI] = "SELECT 1 FROM subscriber WHERE imsi = $imsi",
|
||||
[DB_STMT_EXISTS_BY_MSISDN] = "SELECT 1 FROM subscriber WHERE msisdn = $msisdn",
|
||||
[DB_STMT_SET_IMPLICIT_LU_BY_IMSI] = "UPDATE subscriber SET last_lu_seen = datetime($last_lu, 'unixepoch') WHERE imsi = $imsi",
|
||||
};
|
||||
|
||||
static void sql3_error_log_cb(void *arg, int err_code, const char *msg)
|
||||
|
|
|
@ -230,6 +230,17 @@ static const char *nitb_stmt_sql[] = {
|
|||
|
||||
sqlite3_stmt *nitb_stmt[ARRAY_SIZE(nitb_stmt_sql)] = {};
|
||||
|
||||
enum hlr_db_stmt {
|
||||
HLR_DB_STMT_SET_IMPLICIT_LU_BY_IMSI,
|
||||
};
|
||||
|
||||
static const char *hlr_db_stmt_sql[] = {
|
||||
[HLR_DB_STMT_SET_IMPLICIT_LU_BY_IMSI] =
|
||||
"UPDATE subscriber SET last_lu_seen = datetime($last_lu, 'unixepoch') WHERE imsi = $imsi",
|
||||
};
|
||||
|
||||
sqlite3_stmt *hlr_db_stmt[ARRAY_SIZE(hlr_db_stmt_sql)] = {};
|
||||
|
||||
size_t _dbd_decode_binary(const unsigned char *in, unsigned char *out);
|
||||
|
||||
/*! Set a subscriber's LU timestamp in the HLR database.
|
||||
|
@ -246,7 +257,7 @@ int db_subscr_update_lu_by_imsi(struct db_context *dbc, const char* imsi, const
|
|||
{
|
||||
int rc, ret = 0;
|
||||
|
||||
sqlite3_stmt *stmt = dbc->stmt[DB_STMT_SET_IMPLICIT_LU_BY_IMSI];
|
||||
sqlite3_stmt *stmt = hlr_db_stmt[HLR_DB_STMT_SET_IMPLICIT_LU_BY_IMSI];
|
||||
|
||||
if (!db_bind_text(stmt, "$imsi", imsi))
|
||||
return -EIO;
|
||||
|
@ -424,6 +435,17 @@ int import_nitb_db(void)
|
|||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(hlr_db_stmt_sql); i++) {
|
||||
sql = hlr_db_stmt_sql[i];
|
||||
rc = sqlite3_prepare_v2(g_hlr_db_tool_ctx->dbc->db, hlr_db_stmt_sql[i], -1,
|
||||
&hlr_db_stmt[i], NULL);
|
||||
if (rc != SQLITE_OK) {
|
||||
LOGP(DDB, LOGL_ERROR, "OsmoHLR DB: Unable to prepare SQL statement '%s'\n", sql);
|
||||
ret = -1;
|
||||
goto out_free;
|
||||
}
|
||||
}
|
||||
|
||||
stmt = nitb_stmt[NITB_SELECT_SUBSCR];
|
||||
|
||||
while ((rc = sqlite3_step(stmt)) == SQLITE_ROW) {
|
||||
|
|
Loading…
Reference in New Issue