aboutsummaryrefslogtreecommitdiffstats
path: root/src/db.c
diff options
context:
space:
mode:
authorNeels Hofmeyr <neels@hofmeyr.de>2017-10-09 17:30:32 +0200
committerNeels Hofmeyr <neels@hofmeyr.de>2017-10-11 22:32:19 +0200
commit9c2bbc840f3678489d744d69a718afacafa60ad3 (patch)
treec9fec3a573a294cac350298d45d9665440cd40cf /src/db.c
parent32633e2b895233892a238095e21b89b12ed94d14 (diff)
add db_subscr_get_by_msisdn() and db_subscr_get_by_id()
Factor out the selected SQL columns as SEL_COLUMNS macro, so that each of the new DB_STMTs will select identical columns: the old DB_STMT_SEL_BY_IMSI as well as the new DB_STMT_SEL_BY_MSISDN and DB_STMT_SEL_BY_ID. Add the new functions db_subscr_get_by_msisdn() and db_subscr_get_by_id() and factor out common parts with db_subscr_get_by_imsi() to static db_sel(). Change-Id: I6d0ddd1b7e3f6b180b4b1b2663c5725d2a4a9428
Diffstat (limited to 'src/db.c')
-rw-r--r--src/db.c19
1 files changed, 18 insertions, 1 deletions
diff --git a/src/db.c b/src/db.c
index 179eba8..5a38d55 100644
--- a/src/db.c
+++ b/src/db.c
@@ -26,8 +26,25 @@
#include "logging.h"
#include "db.h"
+#define SEL_COLUMNS \
+ "id," \
+ "imsi," \
+ "msisdn," \
+ "vlr_number," \
+ "sgsn_number," \
+ "sgsn_address," \
+ "periodic_lu_tmr," \
+ "periodic_rau_tau_tmr," \
+ "nam_cs," \
+ "nam_ps," \
+ "lmsi," \
+ "ms_purged_cs," \
+ "ms_purged_ps"
+
static const char *stmt_sql[] = {
- [DB_STMT_SEL_BY_IMSI] = "SELECT id,imsi,msisdn,vlr_number,sgsn_number,sgsn_address,periodic_lu_tmr,periodic_rau_tau_tmr,nam_cs,nam_ps,lmsi,ms_purged_cs,ms_purged_ps FROM subscriber WHERE imsi = ?",
+ [DB_STMT_SEL_BY_IMSI] = "SELECT " SEL_COLUMNS " FROM subscriber WHERE imsi = ?",
+ [DB_STMT_SEL_BY_MSISDN] = "SELECT " SEL_COLUMNS " FROM subscriber WHERE msisdn = ?",
+ [DB_STMT_SEL_BY_ID] = "SELECT " SEL_COLUMNS " FROM subscriber WHERE id = ?",
[DB_STMT_UPD_VLR_BY_ID] = "UPDATE subscriber SET vlr_number = ? WHERE id = ?",
[DB_STMT_UPD_SGSN_BY_ID] = "UPDATE subscriber SET sgsn_number = ? WHERE id = ?",
[DB_STMT_AUC_BY_IMSI] =