libpq doing strange things

From: Daniel Andersen <zedar(at)free2air(dot)com(dot)au>
To: pgsql-interfaces(at)postgresql(dot)org
Subject: libpq doing strange things
Date: 2002-01-03 23:30:21
Message-ID: S37UHOr0GtgBQZfv4eq00051a02@smtp01.iprimus.net.au
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-interfaces

Hi,

Is there some undocumented feature in libpq to do with executing update
queries? I just programmed my mail server to put a mark next to a users name
whenever they check their email, but for some reason the update query does
not execute properly. It returns PGRES_COMMAND_OK, and if i check the text
output of the query it says its updated one record. I know that the
connection is working ok, because it extracts the password and username from
the database ok in the query before. Is there any other way to check what is
going wrong, or is there something else i should be doing i don't know about?
all i do is load the query into a string using sprintf, and then use that
string to execute the query like PGexec (conn, string)
Heres the exact query and commands in case it helps:

snprintf (ptr, 256, "update accounting set mail = 1 where time_stamp
in (select max (time_stamp) from accounting where username='%s') and
username='%s';", pinfo->userid, pinfo->userid);
syslog(LOG_ERR,ptr);
res2 = PQexec (conn, ptr);
if (PQresultStatus(res2) != PGRES_TUPLES_OK) syslog(LOG_ERR,
PQresStatus(PQresultStatus(res2)));

and the output in the syslog is like:

Jan 4 09:21:49 spa teapop[17449]: update accounting set mail = 1 where
time_stamp in (select max (time_stamp) from accounting where username='bsn')
and username='bsn';
Jan 4 09:21:49 spa teapop[17449]: PGRES_COMMAND_OK

which seems like it should be doing ok. Can anyone shed some light on what
might be causing this problem?

Thanks,
Daniel Andersen

Responses

Browse pgsql-interfaces by date

  From Date Subject
Next Message Michael Meskes 2002-01-04 13:05:17 Re: ECPG: How to use #define and string host variable
Previous Message Sandro Dentella 2002-01-03 10:09:39 ANNOUNCE: tksql rel 0.5.21