Re: Column info without executing query - Mailing list pgsql-general

From
Subject Re: Column info without executing query
Date
Msg-id 6A6C88E023CEAE4186002016A357161D077D6E38@prdhqwsemlmb01.prod-am.ameritrade.com
Whole thread Raw
In response to Re: Column info without executing query  (Martijn van Oosterhout <kleptog@svana.org>)
List pgsql-general
My question is a bit off the path that you're taking with this issues, but I'd like to add a twist to the discussion --
tomeet my needs of course :) 

Is it possible to simply retrieve Column Type (Numeric, Varchar, Int,...) data for a given table using ecpg?

The reason I ask is that when I write in C/C++ and do a memset to NULL ('\0') on a struct to use as an Input for a
table,if I do not receive a value for a Numeric data type from the calling program, I get this error: 

ERROR: -400 'invalid input syntax for type numeric: ""'

I'm guessing this error is associated with the fact that the Struct Member is NULL, and it doesn't like that.

So, I get around the "problem" all right, but I'd prefer to not have to hard code this "fix" in my code for each
Numericfield.  I'd prefer grabbing the "Format" of the table and then only calling this "fix" function when the column
I'minserting into is of type Numeric. 

But, I don't want to have any associated Query or Select that was executed first, as this Thread seems to be mostly
dealingwith. 

-----Original Message-----
From: pgsql-general-owner@postgresql.org [mailto:pgsql-general-owner@postgresql.org] On Behalf Of Martijn van
Oosterhout
Sent: Friday, July 21, 2006 9:25 AM
To: Volkan YAZICI
Cc: Jacob Coby; Dan Strömberg; pgsql-general@postgresql.org
Subject: Re: [GENERAL] Column info without executing query

On Fri, Jul 21, 2006 at 05:07:08PM +0300, Volkan YAZICI wrote:
> AFAICS, that's not possible with current parsing capabilities. See
> related lines in
>
> fe-protocol3.c:pqParseInput3()
>     102         /*
>     103          * Can't process if message body isn't all here yet.
>     104          */
>
> But, IMNSHO, we can modify parsing functionality to process message
> parts step by step. For instance, in the current behaviour when we
> receive a T, D, D, ... message, libpq won't attempt to process data
> until it receives whole data chunk. But with some modification on the
> parser side, we can make it process data in such a way:

Actually, you're wrong. It processes the T as it comes in, and then each D as it comes in. "message body" in this case
refersto a single 'T' or 'D' record, not the entire query result. 

> But in this case, some advanced function routines must be written to
> access conn->result in a hardcoded way under strict control. Because,
> PQgetReesult() won't work properly till it receives whole result set.

Did you see my comment about get partial result sets from libpq. for asyncronous queries you can run PQftype as soon as
you'vereceived and parsed the T record, you don't actually have to have received any data yet... See
pqPrepareAsyncResult().

Have a nice day,
--
Martijn van Oosterhout   <kleptog@svana.org>   http://svana.org/kleptog/
> From each according to his ability. To each according to his ability to litigate.

pgsql-general by date:

Previous
From: Martijn van Oosterhout
Date:
Subject: Re: Column info without executing query
Next
From: Volkan YAZICI
Date:
Subject: Re: Column info without executing query