Re: libpq Describe Extension [WAS: Bytea and perl]

From: Volkan YAZICI <yazicivo(at)ttnet(dot)net(dot)tr>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Re: libpq Describe Extension [WAS: Bytea and perl]
Date: 2006-04-15 08:06:01
Message-ID: 20060415080601.GB224@alamut
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-novice

Hi,

[Sending this message (first) to -hackers for discussion about the
extension and followed implementation.]

On Apr 01 09:39, Volkan YAZICI wrote:
> I've prepared a patch for the Describe <-> ParameterDescription
> messaging which is available via current extended query protocol.

Here's a written from scratch patch for the above mentioned extension.
It adds PQdescribePrepared() and PQdescribePortal() functions to the
libpq. New functions work as follows:

1. Issue a PQdescribePrepared() call.
2. First PQgetResult() will return a PGresult with input parameter
types of the prepared statement. (You can use PQftype() on this
PGresult to extract information.)
3. Second PQgetResult() will return another PGresult which holds the
column information for the will be returned tuples. (All PQf*()
functions can be used on this result.)

(A PQdescribePortal() call will just skip the 2nd step in the above
list.)

Patch passes regression tests and there're two examples attached for
PQdescribePrepared() and PQdescribePortal() usage.

To mention about the followed implementation, it needed some hack on
pqParseInput3() code to make it understand if a received message is
a reponse to a Describe ('D') query or to another tuple returning
query. To summarize problem, there're two possible forms of a 'D'
response:

1. Description of a prepared statement: t, T, Z
2. Description of a portal: T, Z

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.

Regards.

Attachment Content-Type Size
libpq_desc_msg.patch.4 text/plain 11.2 KB
PQdescribePrepared.c text/plain 3.2 KB
PQdescribePortal.c text/plain 2.7 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Hannu Krosing 2006-04-15 10:31:58 Re: Is full_page_writes=off safe in conjunction with
Previous Message Florian Weimer 2006-04-15 07:37:50 Re: Is full_page_writes=off safe in conjunction with PITR?

Browse pgsql-novice by date

  From Date Subject
Next Message Andrew Chambers 2006-04-15 12:31:47 Re: Colors/bold chars in a select?
Previous Message none 2006-04-15 05:12:55 Install password not recognized