Re: libpq Describe Extension [WAS: Bytea and perl] - Mailing list pgsql-hackers

From Volkan YAZICI
Subject Re: libpq Describe Extension [WAS: Bytea and perl]
Date
Msg-id 20060624114533.GA2351@alamut.tdm.local
Whole thread Raw
In response to Re: libpq Describe Extension [WAS: Bytea and perl]  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: libpq Describe Extension [WAS: Bytea and perl]  (Martijn van Oosterhout <kleptog@svana.org>)
Re: libpq Describe Extension [WAS: Bytea and perl]  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
On Jun 16 08:21, Tom Lane wrote:
> Bruce Momjian <pgman@candle.pha.pa.us> writes:
> > Volkan YAZICI wrote:
> >> The problem is, AFAICS, it's not possible to distinguish between a tuple
> >> returning query (T, ..., C, Z or T, E) and a description of a portal (T,
> >> Z). Therefore, I've created a global flag (parsing_row_desc) which is
> >> turned on when we receive a 'T' and turned off if we receive a 'C' or
> >> 'E'. It's a kind of ugly method but the only solution I could come up
> >> with.
>
> > The problem with this solution is that it is not thread-safe.  Perhaps
> > you can use a per-PGconn boolean?

Ie replaced the static flag with a conn->queryclass value using
PGQueryClass as Tom suggested. Also updated patch to be compatible with
exports.txt stuff.

> The whole thing sounds like brute force to me.  Shouldn't you be adding
> states to enum PGQueryClass, if you need to track what sort of Describe
> you're doing?

I totally agree with the followed ugly style. But IMHO the recursive
parsing (that is followed in pqParseInputN()) of received data is the main
problem behind this. I think, it will even get harder everytime somebody
try to to add another type of message parsing capability to that loop.
For instance, isn't pollution of PGQueryClass with state variables (like
PGQUERY_PREPARE or PGQUERY_DESCRIBE) one of the proofs of this.

While playing with pqParseInputN loops, I feel like coding Lisp recursions
using C syntax; it's quite ridiculous.


Regards.

Attachment

pgsql-hackers by date:

Previous
From: Heikki Linnakangas
Date:
Subject: Re: vacuum, performance, and MVCC
Next
From: "Mark Woodward"
Date:
Subject: Re: vacuum, performance, and MVCC