aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/osmocom/hlr/db.h1
-rw-r--r--src/db.c1
-rw-r--r--src/hlr_db_tool.c24
3 files changed, 23 insertions, 3 deletions
diff --git a/include/osmocom/hlr/db.h b/include/osmocom/hlr/db.h
index 176a097..ca336a0 100644
--- a/include/osmocom/hlr/db.h
+++ b/include/osmocom/hlr/db.h
@@ -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
};
diff --git a/src/db.c b/src/db.c
index fb7c2d5..5ec20e2 100644
--- a/src/db.c
+++ b/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)
diff --git a/src/hlr_db_tool.c b/src/hlr_db_tool.c
index e9733a0..eb44744 100644
--- a/src/hlr_db_tool.c
+++ b/src/hlr_db_tool.c
@@ -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) {