db: Fix fall-out with the subscriber removal in the subscriber deletion code
The sender_id is gone so the code that attempted to delete SMS
didn't work anymore. Delete the SMS based on src_addr or the
dest_addr.
Fixes:
======================================================================
ERROR: testSubscriberAddRemove (__main__.TestCtrlNITB)
----------------------------------------------------------------------
Traceback (most recent call last):
File "tests/ctrl_test_runner.py", line 379, in testSubscriberAddRemove
r = self.do_set('subscriber-delete-v1', '2620345')
File "tests/ctrl_test_runner.py", line 114, in do_set
return self.recv_msgs()[id]
KeyError: 1002
diff --git a/openbsc/src/libmsc/db.c b/openbsc/src/libmsc/db.c
index 1580acd..90c66c8 100644
--- a/openbsc/src/libmsc/db.c
+++ b/openbsc/src/libmsc/db.c
@@ -1042,8 +1042,8 @@
dbi_result_free(result);
result = dbi_conn_queryf(conn,
- "DELETE FROM SMS WHERE sender_id=%llu OR receiver_id=%llu",
- subscr->id, subscr->id);
+ "DELETE FROM SMS WHERE src_addr=%s OR dest_addr=%s",
+ subscr->extension, subscr->extension);
if (!result) {
LOGP(DDB, LOGL_ERROR,
"Failed to delete SMS for %llu\n", subscr->id);