Re: libpq: PQcmdStatus, PQcmdTuples signatures can be painlessly improved - Mailing list pgsql-hackers

From Peter Eisentraut
Subject Re: libpq: PQcmdStatus, PQcmdTuples signatures can be painlessly improved
Date
Msg-id 1326215622.22414.2.camel@vanquo.pezone.net
Whole thread Raw
In response to libpq: PQcmdStatus, PQcmdTuples signatures can be painlessly improved  (Alex Goncharov <alex-goncharov@comcast.net>)
Responses Re: libpq: PQcmdStatus, PQcmdTuples signatures can be painlessly improved  (Alex Goncharov <alex-goncharov@comcast.net>)
List pgsql-hackers
On tis, 2011-12-13 at 07:55 -0500, Alex Goncharov wrote:
>   char *PQcmdStatus(PGresult *res);
>   char *PQcmdTuples(PGresult *res);
> 
> Unreasonable:
> 
>   a. What, these two can modify 'res' I pass in?..
> 
>   b. Oh, yes, because they return 'char *' pointing to
>      'res->cmdStatus+n', so, a libpq user may write:
> 
>         char *s = PQcmdStatus(res);
>         *s = 'x';
> 
>      and have 'res' modified.  (Would be the user's fault, of course.)
> 
Note that const PGresult * would only warn against changing the fields
of the PGresult struct.  It doesn't do anything about changing the data
pointed to by pointers in the PGresult struct.  So what you are saying
doesn't follow.




pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: Sending notifications from the master to the standby
Next
From: Andrew Dunstan
Date:
Subject: Re: Add SPI results constants available for PL/*