Hi Kannel Devel,

Attached and included in this email, is a postgresql patch that does not use
Automatic OIDs, which has been removed from Postgresql.

You can make smsc,ts the primary key or as suggested by Guillaume Cottenceau
you can set smsc,ts as an index.

diff -u gateway/gw/dlr_pgsql.c gateway/gw/dlr_pgsql.c
--- gateway/gw/dlr_pgsql.c      2008-06-23 08:16:34.000000000 +0200
+++ gateway/gw/dlr_pgsql.c   2008-06-22 12:27:38.000000000 +0200
@@ -220,12 +220,11 @@
     Octstr *sql;

     debug("dlr.pgsql", 0, "removing DLR from database");
-    sql = octstr_format("DELETE FROM %s WHERE (%s,%s) IN (SELECT %s,%s
WHERE %s='%s' AND %s='%s' LIMIT 1);",
-                        octstr_get_cstr(fields->table),
-
octstr_get_cstr(fields->field_smsc),octstr_get_cstr(fields->field_ts),
-
octstr_get_cstr(fields->field_smsc),octstr_get_cstr(fields->field_ts),
-                        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' 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));
+

     pgsql_update(sql);
     octstr_destroy(sql);
@@ -237,12 +236,11 @@
     Octstr *sql;

     debug("dlr.pgsql", 0, "updating DLR status in database");
-    sql = octstr_format("UPDATE %s SET %s=%d WHERE (%s,%s) IN (SELECT %s,%s
WHERE %s='%s' AND %s='%s' LIMIT 1);",
+    sql = octstr_format("UPDATE %s SET %s=%d WHERE oid = (SELECT oid FROM
%s 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(fields->field_ts),
-
octstr_get_cstr(fields->field_smsc),octstr_get_cstr(fields->field_ts),
-                       octstr_get_cstr(fields->field_smsc),
octstr_get_cstr(smsc),
+                        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));
     pgsql_update(sql);
     octstr_destroy(sql);

Attachment: postgreSQL.patch
Description: Binary data

Reply via email to