Hi,
attched you can find patch that includes destination address into dlr
lookup. This patch implements include all necessary changes for all dlr
storage types. Additionally this patch changes my email addr. from
@centrium.de to @kannel.org and does some cleanup for sql query generation.
What this patch try to do is pretty simple and I hope to be generic approach
(picked from dlr.c):
/*
* It's not possible to use the whole destination in sql query, so we just
* strip country prefix and do DB lookup like 'like "%striped-dst"' and so
* increase probability to find a right DB entry.
* Example: for Germany dst=+491711234567 striped=1711234567
* Example2: for Germany dst=01711234567 striped=1711234567
*/
This approach was used at centrium for years and workes just fine...
Comments/votes please!
P.S. Patch is only compile tested, but should work (changes are trivial ;)).
--
Thanks,
Alex
Index: gw/dlr.c
===================================================================
RCS file: /home/cvs/gateway/gw/dlr.c,v
retrieving revision 1.51
diff -a -u -r1.51 dlr.c
--- gw/dlr.c 11 Aug 2004 16:41:29 -0000 1.51
+++ gw/dlr.c 25 Sep 2004 19:06:22 -0000
@@ -61,7 +61,7 @@
*
* Andreas Fink <[EMAIL PROTECTED]>, 18.08.2001
* Stipe Tolj <[EMAIL PROTECTED]>, 22.03.2002
- * Alexander Malysh <[EMAIL PROTECTED]> 2003
+ * Alexander Malysh <[EMAIL PROTECTED]> 2003
*
* Changes:
* 2001-12-17: [EMAIL PROTECTED]:
@@ -262,7 +262,7 @@
* add aditional types here
*/
- if (handles == NULL) {
+ if (handles == NULL) {
panic(0, "DLR: storage type '%s' is not supported!", octstr_get_cstr(dlr_type));
}
@@ -344,7 +344,8 @@
debug("dlr.dlr", 0, "DLR[%s]: Adding DLR smsc=%s, ts=%s, src=%s, dst=%s, mask=%d, boxc=%s",
dlr_type(), octstr_get_cstr(dlr->smsc), octstr_get_cstr(dlr->timestamp),
- octstr_get_cstr(dlr->source), octstr_get_cstr(dlr->destination), dlr->mask, octstr_get_cstr(dlr->boxc_id));
+ octstr_get_cstr(dlr->source), octstr_get_cstr(dlr->destination), dlr->mask,
+ octstr_get_cstr(dlr->boxc_id));
/* call registered function */
handles->dlr_add(dlr);
@@ -359,6 +360,7 @@
{
Msg *msg = NULL;
struct dlr_entry *dlr = NULL;
+ Octstr *striped_dst;
if(octstr_len(smsc) == 0) {
warning(0, "DLR[%s]: Can't find a dlr without smsc-id", dlr_type());
@@ -369,15 +371,33 @@
if (handles == NULL || handles->dlr_get == NULL)
return NULL;
+
+ /*
+ * It's not possible to use the whole destination in sql query, so we just
+ * strip country prefix and do DB lookup like 'like "%striped-dst"' and so
+ * increase probability to find a right DB entry.
+ * Example: for Germany dst=+491711234567 striped=1711234567
+ * Example2: for Germany dst=01711234567 striped=1711234567
+ * Note: How many chars to strip should be probably configurable!
+ */
+ striped_dst = octstr_duplicate(dst);
+ if (octstr_len(dst) > 10)
+ octstr_delete(striped_dst, 0, octstr_len(dst) - 10);
+ else if (octstr_len(dst) > 7) /* fallback to 7 */
+ octstr_delete(striped_dst, 0, octstr_len(dst) - 7);
+
+
debug("dlr.dlr", 0, "DLR[%s]: Looking for DLR smsc=%s, ts=%s, dst=%s, type=%d",
- dlr_type(), octstr_get_cstr(smsc), octstr_get_cstr(ts), octstr_get_cstr(dst), typ);
+ dlr_type(), octstr_get_cstr(smsc), octstr_get_cstr(ts), octstr_get_cstr(striped_dst), typ);
- dlr = handles->dlr_get(smsc, ts, dst);
+ dlr = handles->dlr_get(smsc, ts, striped_dst);
if (dlr == NULL) {
warning(0, "DLR[%s]: DLR for DST<%s> not found.",
- dlr_type(), octstr_get_cstr(dst));
+ dlr_type(), octstr_get_cstr(striped_dst));
+ octstr_destroy(striped_dst);
return NULL;
}
+ octstr_destroy(striped_dst);
#define O_SET(x, val) if (octstr_len(val) > 0) { x = val; val = NULL; }
@@ -407,7 +427,8 @@
debug("dlr.dlr", 0, "DLR[%s]: created DLR message for URL <%s>",
dlr_type(), (msg->sms.dlr_url?octstr_get_cstr(msg->sms.dlr_url):""));
} else {
- debug("dlr.dlr", 0, "DLR[%s]: Ignoring DLR message because of mask type=%d dlr->mask=%d", dlr_type(), typ, dlr->mask);
+ debug("dlr.dlr", 0, "DLR[%s]: Ignoring DLR message because of mask type=%d dlr->mask=%d",
+ dlr_type(), typ, dlr->mask);
/* ok that was a status report but we where not interested in having it */
msg = NULL;
}
@@ -419,11 +440,11 @@
info(0, "DLR[%s]: DLR not destroyed, still waiting for other delivery report", dlr_type());
/* update dlr entry status if function defined */
if (handles != NULL && handles->dlr_update != NULL)
- handles->dlr_update(smsc, ts, dst, typ);
+ handles->dlr_update(smsc, ts, dlr->destination, typ);
} else {
if (handles != NULL && handles->dlr_remove != NULL) {
/* it's not good for internal storage, but better for all others */
- handles->dlr_remove(smsc, ts, dst);
+ handles->dlr_remove(smsc, ts, dlr->destination);
} else {
warning(0, "DLR[%s]: Storage don't have remove operation defined", dlr_type());
}
Index: gw/dlr.h
===================================================================
RCS file: /home/cvs/gateway/gw/dlr.h,v
retrieving revision 1.18
diff -a -u -r1.18 dlr.h
--- gw/dlr.h 22 Jan 2004 14:08:24 -0000 1.18
+++ gw/dlr.h 25 Sep 2004 19:06:23 -0000
@@ -61,6 +61,7 @@
*
* Andreas Fink <[EMAIL PROTECTED]>, 18.08.2001
* Stipe Tolj <[EMAIL PROTECTED]>, 22.03.2002
+ * Alexander Malysh <[EMAIL PROTECTED]>, 2003
*/
#ifndef DLR_H
Index: gw/dlr_mem.c
===================================================================
RCS file: /home/cvs/gateway/gw/dlr_mem.c,v
retrieving revision 1.7
diff -a -u -r1.7 dlr_mem.c
--- gw/dlr_mem.c 8 Aug 2004 19:50:18 -0000 1.7
+++ gw/dlr_mem.c 25 Sep 2004 19:06:23 -0000
@@ -62,7 +62,7 @@
*
* Andreas Fink <[EMAIL PROTECTED]>, 18.08.2001
* Stipe Tolj <[EMAIL PROTECTED]>, 22.03.2002
- * Alexander Malysh <[EMAIL PROTECTED]> 2003
+ * Alexander Malysh <[EMAIL PROTECTED]> 2003
*/
#include "gwlib/gwlib.h"
@@ -125,7 +125,8 @@
/* XXX: check destination addr too, because e.g. for UCP is not enough to check only
* smsc and timestamp (timestamp is even without milliseconds)
*/
- if(octstr_compare(dlr->smsc,smsc) == 0 && octstr_compare(dlr->timestamp,ts) == 0)
+ if(octstr_compare(dlr->smsc,smsc) == 0 && octstr_compare(dlr->timestamp,ts) == 0 &&
+ octstr_search(dlr->destination, dst, 0) != -1)
return 0;
return 1;
Index: gw/dlr_mysql.c
===================================================================
RCS file: /home/cvs/gateway/gw/dlr_mysql.c,v
retrieving revision 1.7
diff -a -u -r1.7 dlr_mysql.c
--- gw/dlr_mysql.c 22 Jan 2004 14:08:24 -0000 1.7
+++ gw/dlr_mysql.c 25 Sep 2004 19:06:24 -0000
@@ -62,7 +62,7 @@
*
* Andreas Fink <[EMAIL PROTECTED]>, 18.08.2001
* Stipe Tolj <[EMAIL PROTECTED]>, 22.03.2002
- * Alexander Malysh <[EMAIL PROTECTED]> 2003
+ * Alexander Malysh <[EMAIL PROTECTED]> 2003
*/
#include "gwlib/gwlib.h"
@@ -144,17 +144,18 @@
{
Octstr *sql;
- sql = octstr_format("INSERT INTO %s (%s, %s, %s, %s, %s, %s, %s, %s, %s) VALUES "
- "('%s', '%s', '%s', '%s', '%s', '%s', '%d', '%s', '%d');",
- octstr_get_cstr(fields->table), octstr_get_cstr(fields->field_smsc),
- octstr_get_cstr(fields->field_ts),
- octstr_get_cstr(fields->field_src), octstr_get_cstr(fields->field_dst),
- octstr_get_cstr(fields->field_serv), octstr_get_cstr(fields->field_url),
- octstr_get_cstr(fields->field_mask), octstr_get_cstr(fields->field_boxc),
- octstr_get_cstr(fields->field_status),
- octstr_get_cstr(entry->smsc), octstr_get_cstr(entry->timestamp), octstr_get_cstr(entry->source),
- octstr_get_cstr(entry->destination), octstr_get_cstr(entry->service), octstr_get_cstr(entry->url),
- entry->mask, octstr_get_cstr(entry->boxc_id), 0);
+ sql = octstr_format("INSERT INTO %S (%S, %S, %S, %S, %S, %S, %S, %S, %S) VALUES "
+ "('%S', '%S', '%S', '%S', '%S', '%S', '%d', '%S', '%d');",
+ fields->table, fields->field_smsc,
+ fields->field_ts,
+ fields->field_src, fields->field_dst,
+ fields->field_serv, fields->field_url,
+ fields->field_mask, fields->field_boxc,
+ fields->field_status,
+ entry->smsc, entry->timestamp,
+ entry->source, entry->destination,
+ entry->service, entry->url,
+ entry->mask, entry->boxc_id, 0);
mysql_update(sql);
@@ -170,12 +171,13 @@
MYSQL_RES *result;
MYSQL_ROW row;
- sql = octstr_format("SELECT %s, %s, %s, %s, %s, %s FROM %s WHERE %s='%s' AND %s='%s';",
- octstr_get_cstr(fields->field_mask), octstr_get_cstr(fields->field_serv),
- octstr_get_cstr(fields->field_url), octstr_get_cstr(fields->field_src),
- octstr_get_cstr(fields->field_dst), octstr_get_cstr(fields->field_boxc),
- octstr_get_cstr(fields->table), octstr_get_cstr(fields->field_smsc),
- octstr_get_cstr(smsc), octstr_get_cstr(fields->field_ts), octstr_get_cstr(ts));
+ sql = octstr_format("SELECT %S, %S, %S, %S, %S, %S FROM %S WHERE %S='%S' AND %S='%S' AND %S LIKE '%%S';",
+ fields->field_mask, fields->field_serv,
+ fields->field_url, fields->field_src,
+ fields->field_dst, fields->field_boxc,
+ fields->table, fields->field_smsc,
+ smsc, fields->field_ts, ts,
+ fields->field_dst, dst);
result = mysql_select(sql);
@@ -191,7 +193,7 @@
}
row = mysql_fetch_row(result);
if (!row) {
- debug("dlr.mysql", 0, "rows found but could not load them");
+ debug("dlr.mysql", 0, "rows found but could not fetch them");
mysql_free_result(result);
return NULL;
}
@@ -219,10 +221,10 @@
Octstr *sql;
debug("dlr.mysql", 0, "removing DLR from database");
- sql = octstr_format("DELETE FROM %s WHERE %s='%s' AND %s='%s' LIMIT 1;",
- octstr_get_cstr(fields->table), octstr_get_cstr(fields->field_smsc),
- octstr_get_cstr(smsc), octstr_get_cstr(fields->field_ts), octstr_get_cstr(ts));
-
+ sql = octstr_format("DELETE FROM %S WHERE %S='%S' AND %S='%S' AND %S='%S' LIMIT 1;",
+ fields->table, fields->field_smsc,
+ smsc, fields->field_ts, ts,
+ fields->field_dst, dst);
mysql_update(sql);
@@ -234,11 +236,12 @@
Octstr *sql;
debug("dlr.mysql", 0, "updating DLR status in database");
- sql = octstr_format("UPDATE %s SET %s=%d WHERE %s='%s' AND %s='%s' LIMIT 1;",
- octstr_get_cstr(fields->table),
- octstr_get_cstr(fields->field_status), status,
- octstr_get_cstr(fields->field_smsc), octstr_get_cstr(smsc),
- octstr_get_cstr(fields->field_ts), octstr_get_cstr(ts));
+ sql = octstr_format("UPDATE %S SET %S=%d WHERE %S='%S' AND %S='%S' AND %S='%S' LIMIT 1;",
+ fields->table,
+ fields->field_status, status,
+ fields->field_smsc, smsc,
+ fields->field_ts, ts,
+ fields->field_dst, dst);
mysql_update(sql);
@@ -253,7 +256,7 @@
MYSQL_RES *result;
MYSQL_ROW row;
- sql = octstr_format("SELECT count(*) FROM %s;", octstr_get_cstr(fields->table));
+ sql = octstr_format("SELECT count(*) FROM %S;", fields->table);
result = mysql_select(sql);
octstr_destroy(sql);
@@ -282,7 +285,7 @@
{
Octstr *sql;
- sql = octstr_format("DELETE FROM %s;", octstr_get_cstr(fields->table));
+ sql = octstr_format("DELETE FROM %S;", fields->table);
mysql_update(sql);
octstr_destroy(sql);
Index: gw/dlr_oracle.c
===================================================================
RCS file: /home/cvs/gateway/gw/dlr_oracle.c,v
retrieving revision 1.6
diff -a -u -r1.6 dlr_oracle.c
--- gw/dlr_oracle.c 20 Mar 2004 19:48:22 -0000 1.6
+++ gw/dlr_oracle.c 25 Sep 2004 19:06:25 -0000
@@ -57,7 +57,7 @@
/*
* dlr_oracle.c - Oracle dlr storage implementation.
*
- * Author: Alexander Malysh <[EMAIL PROTECTED]>, (C) 2003
+ * Author: Alexander Malysh <[EMAIL PROTECTED]>, (C) 2003
* Robert Ga�ach <[EMAIL PROTECTED]>
* 2004 Rewrited sql queries to use binding variables.
*
@@ -210,7 +210,7 @@
if (pconn == NULL) /* should not happens, but sure is sure */
return NULL;
- sql = octstr_format("SELECT %S, %S, %S, %S, %S, %S FROM %S WHERE %S=:1 AND %S=:2 AND %S=:3 AND ROWNUM < 2",
+ sql = octstr_format("SELECT %S, %S, %S, %S, %S, %S FROM %S WHERE %S=:1 AND %S=:2 AND %S LIKE '%%:3' AND ROWNUM < 2",
fields->field_mask, fields->field_serv,
fields->field_url, fields->field_src,
fields->field_dst, fields->field_boxc,
Index: gw/dlr_pgsql.c
===================================================================
RCS file: /home/cvs/gateway/gw/dlr_pgsql.c,v
retrieving revision 1.1
diff -a -u -r1.1 dlr_pgsql.c
--- gw/dlr_pgsql.c 9 Jun 2004 10:06:33 -0000 1.1
+++ gw/dlr_pgsql.c 25 Sep 2004 19:06:25 -0000
@@ -62,7 +62,7 @@
*
* modeled after dlr_mysql.c
*
- * Alexander Malysh <[EMAIL PROTECTED]>, cleanup 2004
+ * Alexander Malysh <[EMAIL PROTECTED]>, cleanup 2004
*/
#include "gwlib/gwlib.h"
@@ -138,17 +138,17 @@
{
Octstr *sql;
- sql = octstr_format("INSERT INTO %s (%s, %s, %s, %s, %s, %s, %s, %s, %s) VALUES "
- "('%s', '%s', '%s', '%s', '%s', '%s', '%d', '%s', '%d');",
- octstr_get_cstr(fields->table), octstr_get_cstr(fields->field_smsc),
- octstr_get_cstr(fields->field_ts),
- octstr_get_cstr(fields->field_src), octstr_get_cstr(fields->field_dst),
- octstr_get_cstr(fields->field_serv), octstr_get_cstr(fields->field_url),
- octstr_get_cstr(fields->field_mask), octstr_get_cstr(fields->field_boxc),
- octstr_get_cstr(fields->field_status),
- octstr_get_cstr(entry->smsc), octstr_get_cstr(entry->timestamp), octstr_get_cstr(entry->source),
- octstr_get_cstr(entry->destination), octstr_get_cstr(entry->service), octstr_get_cstr(entry->url),
- entry->mask, octstr_get_cstr(entry->boxc_id), 0);
+ sql = octstr_format("INSERT INTO %S (%S, %S, %S, %S, %S, %S, %S, %S, %S) VALUES "
+ "('%S', '%S', '%S', '%S', '%S', '%S', '%d', '%S', '%d');",
+ fields->table, fields->field_smsc,
+ fields->field_ts,
+ fields->field_src, fields->field_dst,
+ fields->field_serv, fields->field_url,
+ fields->field_mask, fields->field_boxc,
+ fields->field_status,
+ entry->smsc, entry->timestamp, entry->source,
+ entry->destination, entry->service, entry->url,
+ entry->mask, entry->boxc_id, 0);
pgsql_update(sql);
@@ -163,12 +163,13 @@
Octstr *sql;
List *result, *row;
- sql = octstr_format("SELECT %s, %s, %s, %s, %s, %s FROM %s WHERE %s='%s' AND %s='%s';",
- octstr_get_cstr(fields->field_mask), octstr_get_cstr(fields->field_serv),
- octstr_get_cstr(fields->field_url), octstr_get_cstr(fields->field_src),
- octstr_get_cstr(fields->field_dst), octstr_get_cstr(fields->field_boxc),
- octstr_get_cstr(fields->table), octstr_get_cstr(fields->field_smsc),
- octstr_get_cstr(smsc), octstr_get_cstr(fields->field_ts), octstr_get_cstr(ts));
+ sql = octstr_format("SELECT %S, %S, %S, %S, %S, %S FROM %S WHERE %S='%S' AND %S='%S' AND %S LIKE '%%S';",
+ fields->field_mask, fields->field_serv,
+ fields->field_url, fields->field_src,
+ fields->field_dst, fields->field_boxc,
+ fields->table, fields->field_smsc,
+ smsc, fields->field_ts, ts,
+ fields->field_dst, dst);
result = pgsql_select(sql);
@@ -190,8 +191,7 @@
octstr_get_cstr(list_get(row, 2)),
octstr_get_cstr(list_get(row, 3)),
octstr_get_cstr(list_get(row, 4)),
- octstr_get_cstr(list_get(row, 5))
- );
+ octstr_get_cstr(list_get(row, 5)));
res = dlr_entry_create();
gw_assert(res != NULL);
@@ -215,9 +215,9 @@
Octstr *sql;
debug("dlr.pgsql", 0, "removing DLR from database");
- sql = octstr_format("DELETE FROM %s WHERE %s='%s' AND %s='%s' LIMIT 1;",
- octstr_get_cstr(fields->table), octstr_get_cstr(fields->field_smsc),
- octstr_get_cstr(smsc), octstr_get_cstr(fields->field_ts), octstr_get_cstr(ts));
+ sql = octstr_format("DELETE FROM %S WHERE %S='%S' AND %S='%S' AND %S='%S' LIMIT 1;",
+ fields->table, fields->field_smsc,
+ smsc, fields->field_ts, ts, fields->field_dst, dst);
pgsql_update(sql);
@@ -229,11 +229,11 @@
Octstr *sql;
debug("dlr.pgsql", 0, "updating DLR status in database");
- sql = octstr_format("UPDATE %s SET %s=%d WHERE %s='%s' AND %s='%s' LIMIT 1;",
- octstr_get_cstr(fields->table),
- octstr_get_cstr(fields->field_status), status,
- octstr_get_cstr(fields->field_smsc), octstr_get_cstr(smsc),
- octstr_get_cstr(fields->field_ts), octstr_get_cstr(ts));
+ sql = octstr_format("UPDATE %S SET %S=%d WHERE %S='%S' AND %S='%S' AND %S='%S' LIMIT 1;",
+ fields->table,
+ fields->field_status, status,
+ fields->field_smsc, smsc,
+ fields->field_ts, ts, fields->field_dst, dst);
pgsql_update(sql);
octstr_destroy(sql);
}
@@ -245,7 +245,7 @@
long ret;
List *res;
- sql = octstr_format("SELECT count(*) FROM %s;", octstr_get_cstr(fields->table));
+ sql = octstr_format("SELECT count(*) FROM %S;", fields->table);
res = pgsql_select(sql);
octstr_destroy(sql);
@@ -267,7 +267,7 @@
{
Octstr *sql;
- sql = octstr_format("DELETE FROM %s;", octstr_get_cstr(fields->table));
+ sql = octstr_format("DELETE FROM %S;", fields->table));
pgsql_update(sql);
octstr_destroy(sql);
Index: gw/dlr_sdb.c
===================================================================
RCS file: /home/cvs/gateway/gw/dlr_sdb.c,v
retrieving revision 1.9
diff -a -u -r1.9 dlr_sdb.c
--- gw/dlr_sdb.c 18 May 2004 13:04:20 -0000 1.9
+++ gw/dlr_sdb.c 25 Sep 2004 19:06:27 -0000
@@ -62,7 +62,7 @@
*
* Andreas Fink <[EMAIL PROTECTED]>, 18.08.2001
* Stipe Tolj <[EMAIL PROTECTED]>, 22.03.2002
- * Alexander Malysh <[EMAIL PROTECTED]> 2003
+ * Alexander Malysh <[EMAIL PROTECTED]> 2003
* Guillaume Cottenceau 2004 (dbpool support)
*/
@@ -137,18 +137,18 @@
Octstr *sql;
int state;
- sql = octstr_format("INSERT INTO %s (%s, %s, %s, %s, %s, %s, %s, %s, %s) VALUES "
- "('%s', '%s', '%s', '%s', '%s', '%s', '%d', '%s', '%d')",
- octstr_get_cstr(fields->table), octstr_get_cstr(fields->field_smsc),
- octstr_get_cstr(fields->field_ts),
- octstr_get_cstr(fields->field_src), octstr_get_cstr(fields->field_dst),
- octstr_get_cstr(fields->field_serv), octstr_get_cstr(fields->field_url),
- octstr_get_cstr(fields->field_mask), octstr_get_cstr(fields->field_boxc),
- octstr_get_cstr(fields->field_status),
- octstr_get_cstr(dlr->smsc), octstr_get_cstr(dlr->timestamp),
- octstr_get_cstr(dlr->source), octstr_get_cstr(dlr->destination),
- octstr_get_cstr(dlr->service), octstr_get_cstr(dlr->url), dlr->mask,
- octstr_get_cstr(dlr->boxc_id), 0);
+ sql = octstr_format("INSERT INTO %S (%S, %S, %S, %S, %S, %S, %S, %S, %S) VALUES "
+ "('%S', '%S', '%S', '%S', '%S', '%S', '%d', '%S', '%d')",
+ fields->table, fields->field_smsc,
+ fields->field_ts,
+ fields->field_src, fields->field_dst,
+ fields->field_serv, fields->field_url,
+ fields->field_mask, fields->field_boxc,
+ fields->field_status,
+ dlr->smsc, dlr->timestamp,
+ dlr->source, dlr->destination,
+ dlr->service, dlr->url, dlr->mask,
+ dlr->boxc_id, 0);
#if defined(DLR_TRACE)
debug("dlr.sdb", 0, "SDB: sql: %s", octstr_get_cstr(sql));
@@ -216,13 +216,15 @@
gw_assert(res != NULL);
- sql = octstr_format("SELECT %s, %s, %s, %s, %s, %s FROM %s WHERE %s='%s' AND %s='%s' %s",
- octstr_get_cstr(fields->field_mask), octstr_get_cstr(fields->field_serv),
- octstr_get_cstr(fields->field_url), octstr_get_cstr(fields->field_src),
- octstr_get_cstr(fields->field_dst), octstr_get_cstr(fields->field_boxc),
- octstr_get_cstr(fields->table),
- octstr_get_cstr(fields->field_smsc), octstr_get_cstr(smsc),
- octstr_get_cstr(fields->field_ts), octstr_get_cstr(ts), sdb_get_limit_str());
+ sql = octstr_format("SELECT %S, %S, %S, %S, %S, %S FROM %S WHERE %S='%S' AND %S='%S' AND %S LIKE '%%S' %s",
+ fields->field_mask, fields->field_serv,
+ fields->field_url, fields->field_src,
+ fields->field_dst, fields->field_boxc,
+ fields->table,
+ fields->field_smsc, smsc,
+ fields->field_ts, ts,
+ fields->field_dst, dst,
+ sdb_get_limit_str());
#if defined(DLR_TRACE)
debug("dlr.sdb", 0, "SDB: sql: %s", octstr_get_cstr(sql));
@@ -254,11 +256,13 @@
int state;
debug("dlr.sdb", 0, "SDB: updating DLR status in database");
- sql = octstr_format("UPDATE %s SET %s=%d WHERE %s='%s' AND %s='%s' %s",
- octstr_get_cstr(fields->table),
- octstr_get_cstr(fields->field_status), status,
- octstr_get_cstr(fields->field_smsc), octstr_get_cstr(smsc),
- octstr_get_cstr(fields->field_ts), octstr_get_cstr(ts), sdb_get_limit_str());
+ sql = octstr_format("UPDATE %S SET %S=%d WHERE %S='%S' AND %S='%S' AND %S='%S' %s",
+ fields->table,
+ fields->field_status, status,
+ fields->field_smsc, smsc,
+ fields->field_ts, ts,
+ fields->field_dst, dst,
+ sdb_get_limit_str());
#if defined(DLR_TRACE)
debug("dlr.sdb", 0, "SDB: sql: %s", octstr_get_cstr(sql));
@@ -285,17 +289,20 @@
* to do vacuum regularly, even if it's virtually impossible
* to hit duplicates since oid's are given in a row
*/
- sql = octstr_format("DELETE FROM %s WHERE oid = \
- (SELECT oid FROM %s WHERE %s='%s' AND %s='%s' LIMIT 1)",
- octstr_get_cstr(fields->table),
- octstr_get_cstr(fields->table),
- octstr_get_cstr(fields->field_smsc), octstr_get_cstr(smsc),
- octstr_get_cstr(fields->field_ts), octstr_get_cstr(ts));
+ sql = octstr_format("DELETE FROM %S WHERE "
+ "oid = (SELECT oid FROM %S WHERE %S='%S' AND %S='%S' AND %S='%S' LIMIT 1)",
+ fields->table,
+ fields->table,
+ fields->field_smsc, smsc,
+ fields->field_ts, ts,
+ fields->field_dst, dst);
} else {
- sql = octstr_format("DELETE FROM %s WHERE %s='%s' AND %s='%s' %s",
- octstr_get_cstr(fields->table),
- octstr_get_cstr(fields->field_smsc), octstr_get_cstr(smsc),
- octstr_get_cstr(fields->field_ts), octstr_get_cstr(ts), sdb_get_limit_str());
+ sql = octstr_format("DELETE FROM %S WHERE %S='%S' AND %S='%S' AND %S='%S' %s",
+ fields->table,
+ fields->field_smsc, smsc,
+ fields->field_ts, ts,
+ fields->field_dst, dst,
+ sdb_get_limit_str());
}
#if defined(DLR_TRACE)
@@ -314,7 +321,7 @@
int state;
long res = 0;
- sql = octstr_format("SELECT count(*) FROM %s", octstr_get_cstr(fields->table));
+ sql = octstr_format("SELECT count(*) FROM %S", fields->table);
#if defined(DLR_TRACE)
debug("dlr.sdb", 0, "sql: %s", octstr_get_cstr(sql));
@@ -335,7 +342,7 @@
Octstr *sql;
int state;
- sql = octstr_format("DELETE FROM %s", octstr_get_cstr(fields->table));
+ sql = octstr_format("DELETE FROM %S", fields->table);
#if defined(DLR_TRACE)
debug("dlr.sdb", 0, "sql: %s", octstr_get_cstr(sql));