From: | Michael Richards <miker(at)scifair(dot)acadiau(dot)ca> |
---|---|
To: | Vince Vielhaber <vev(at)michvhf(dot)com> |
Cc: | pgsql-hackers(at)postgreSQL(dot)org |
Subject: | Re: [HACKERS] Getting number of tuples affected |
Date: | 1999-06-30 14:28:43 |
Message-ID: | Pine.BSF.4.10.9906301124010.12242-100000@scifair.acadiau.ca |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On Wed, 30 Jun 1999, Vince Vielhaber wrote:
> > I was looking for a function to return the number of tuples an update
> > returned, but couldn't find anything for libpq++. Any ideas?
>
> Added to my list of stuff to do. As to what else you can do, submit
> patches? :)
> > There is no PgDatabase::exec
> Yep. Guess that should be data.Exec(...
Not sure there is an Exec either :)
I've been making a pile of changes to the PgDatabase class. (Actually I
derived it). One such change is a function to quote a string you're going
to use in SQL. I'm not sure if this belongs in the PgDatabase class, but
if you think so, I'll add it before I submit the tuple count patches.
This allows me to do something like:
String updatesql(form("UPDATE users SET lastrequest='now' WHERE
loginid=%s",dbh->quote(_username).chars()));
cout << dbh->ExecTuplesOk(updatesql);
That is actually the call I needed the update count to ensure it worked...
Here is the routine:
// routine to quote any \ or ' chars in the passed string
// this isn't too efficient, but how much data are we really quoting?
String TDatabase::quote(const char *dirty) {
// start with a single quote
String clean("'");
const char *strptr=dirty;
// escape the string if it contains any ' or \ chars
while (*strptr) {
if ((*strptr=='\'') || (*strptr=='\\'))
clean+='\\';
clean+=*(strptr++);
}
// end with a quote
clean+="'";
return clean;
}
-Michael
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 1999-06-30 14:33:51 | Re: [HACKERS] regression bigtest needs very long time |
Previous Message | Vince Vielhaber | 1999-06-30 14:27:35 | Re: Vaccum (Was: Re: [HACKERS] Hot Backup Ability) |