db_hlr.c: add db_subscr_exists_by_msisdn()

Check if a subscriber exists without generating an error log entry if
it does not. This is cheaper than db_subscr_get_by_msisdn(), as it
does not fetch the subscriber entry.

subscriber-create-on-demand will use this function to generate
a random unique MSISDN for new subscribers.

Related: OS#2542
Change-Id: Ibfbc408c966197682ba2b12d166ade4bfeb7abc2
diff --git a/tests/db/db_test.c b/tests/db/db_test.c
index 217a8c5..fdd62c5 100644
--- a/tests/db/db_test.c
+++ b/tests/db/db_test.c
@@ -294,6 +294,11 @@
 	ASSERT_SEL(imsi, imsi0, 0);
 	ASSERT_SEL(msisdn, "5432101234567891", -ENOENT);
 
+	comment("Check if subscriber exists (by MSISDN)");
+
+	ASSERT_RC(db_subscr_exists_by_msisdn(dbc, "543210123456789"), 0);
+	ASSERT_RC(db_subscr_exists_by_msisdn(dbc, "5432101234567891"), -ENOENT);
+
 	comment("Set MSISDN on non-existent / invalid IMSI");
 
 	ASSERT_RC(db_subscr_update_msisdn_by_imsi(dbc, unknown_imsi, "99"), -ENOENT);