Re: PATCH: Postgresql Patch

Guillaume Cottenceau <[email protected]>
Newsgroups gmane.comp.mobile.kannel.devel
Message-ID <[email protected]>
"Hillel" <hillel 'at' ecommunicate.biz> writes:

> 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);",

The general contract of the code at that point is to delete only
one row even if there are multiple smsc,ts rows, which your
change breaks.

dn=# create table foo ( bar int, baz int );
CREATE TABLE
dn=# insert into foo ( bar, baz ) values ( 1, 2 );
INSERT 447809901 1
dn=# insert into foo ( bar, baz ) values ( 1, 2 );
INSERT 447809902 1
dn=# delete from foo where ( bar, baz ) in ( select 1, 2 limit 1 );
DELETE 2

Same for the UPDATE statement, actually.

-- 
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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.