Re: Segmentation Fault

From: "Frankie Lam" <frankie(at)ucr(dot)com(dot)hk>
To: pgsql-interfaces(at)postgresql(dot)org
Subject: Re: Segmentation Fault
Date: 2003-04-04 02:16:07
Message-ID: b6ippj$an8$1@news.hub.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-interfaces

Thanks all for replying.

> > len =strlen(PQgetvalue(res, 0, i)) * 2 + 1; // <=========
> Why not using PQgetlength(res, 0, i)?

Actually I'm quite new to libPQ, that's why I didn't know there's a
PQgetlength function. :-)

> > PQescapeString(tmp2, PQgetvalue(res, 0, i), len); // <=========
> One last question:
> Why are you using PQescapeString on PQgetvalue?
>
> The doc says:
> If you want to include strings that have been received from a source
> that is not trustworthy (for example, because a random user entered
> them), you cannot directly include them in SQL queries for security
> reasons. Instead, you have to quote special characters that are
> otherwise interpreted by the SQL parser.

hmm.., I did this on purpose. Because I want to grab SQL commands
I previously stored in a table from one database, then reformat them
and store them into another database.
E.g. the reformatted string looks like:
INSERT INTO tableOnAnotherDB(sqlCMD) values('delete from test where
name=''\\\\''');

I'm trying to implement a scale-down'ed version of synchronous
replication, only limited to replicating between two databases.
And this C program is responsible for synchronizing the two
databases and keep them consistent, in case one of them failed
and is up again later and other cases. (checking who's master, and
who's slave, are they accepting requests etc, is done by the server
side stored functions. VB + ODBC + PL/PGSQL in backend)

Regards
Frankie Lam

In response to

Browse pgsql-interfaces by date

  From Date Subject
Next Message =?ISO-2022-JP?B?GyRCMiZJTBsoQg==?= 2003-04-04 02:20:29 unsubscribe
Previous Message Frankie Lam 2003-04-04 02:12:09 Re: Segmentation Fault