Re: libpq Describe Extension [WAS: Bytea and perl]
Volkan YAZICI <yazicivo@ttnet.net.tr>
From: Volkan YAZICI <yazicivo@ttnet.net.tr>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Bruce Momjian <pgman@candle.pha.pa.us>, pgsql-hackers@postgresql.org
Date: 2006-06-24T11:45:33Z
Lists: pgsql-hackers
Attachments
- libpq_desc_msg.patch.5 (text/plain)
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.