Stipe Tolj <st 'at' tolj.org> writes:
> Hillel, can you please revise and update the patch?
AFAIK, the attached patch should work with all versions of pg (at
least since 7.3).
Index: gw/dlr_pgsql.c
===================================================================
RCS file: /home/cvs/gateway/gw/dlr_pgsql.c,v
retrieving revision 1.11
diff -u -r1.11 dlr_pgsql.c
--- gw/dlr_pgsql.c 9 Jan 2008 20:06:56 -0000 1.11
+++ gw/dlr_pgsql.c 23 Jun 2008 15:57:10 -0000
@@ -220,7 +220,7 @@
Octstr *sql;
debug("dlr.pgsql", 0, "removing DLR from database");
- sql = octstr_format("DELETE FROM %s WHERE oid = (SELECT oid FROM %s WHERE %s='%s' AND %s='%s' LIMIT 1);",
+ sql = octstr_format("DELETE FROM %s WHERE ctid = (SELECT ctid 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));
@@ -236,7 +236,7 @@
Octstr *sql;
debug("dlr.pgsql", 0, "updating DLR status in database");
- sql = octstr_format("UPDATE %s SET %s=%d WHERE oid = (SELECT oid FROM %s WHERE %s='%s' AND %s='%s' LIMIT 1);",
+ sql = octstr_format("UPDATE %s SET %s=%d WHERE ctid = (SELECT ctid 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->table),
Index: gw/dlr_sdb.c
===================================================================
RCS file: /home/cvs/gateway/gw/dlr_sdb.c,v
retrieving revision 1.14
diff -u -r1.14 dlr_sdb.c
--- gw/dlr_sdb.c 9 Jan 2008 20:06:57 -0000 1.14
+++ gw/dlr_sdb.c 23 Jun 2008 15:57:10 -0000
@@ -281,12 +281,9 @@
/*
* Postgres doesn't support limiting delete/update queries,
* thus we need to use a select subquery.
- * - notice that for uniqueness use of `oid', postgres suggests
- * 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)",
+ sql = octstr_format("DELETE FROM %s WHERE ctid = \
+ (SELECT ctid 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),
--
Guillaume Cottenceau, MNC Mobile News Channel SA, an Alcatel-Lucent Company
Av. de la Gare 10, 1003 Lausanne, Switzerland - direct +41 21 317 50 36