Re: [INTERFACES] [libpq] Return value of int - Mailing list pgsql-interfaces

From D'Arcy" "J.M." Cain
Subject Re: [INTERFACES] [libpq] Return value of int
Date
Msg-id m10e211-0000bIC@druid.net
Whole thread Raw
In response to Re: [INTERFACES] [libpq] Return value of int  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Field types (was Re: Return value of int)
List pgsql-interfaces
Thus spake Tom Lane
> Henk Jan Barendregt <henkjan@barendregt.xs4all.nl> writes:
> > How can i use libpq to return an int value when i access an INT or INT4
> > value
> 
> Use atoi() ... what comes out of libpq is a character string always.
> It's up to you to convert it to whatever form you want it in.

Regarding this, it would be nice if libpq had some official, documented
way of determining the type of the field.  Currently I deal with this
in PyGreSQL by stealing some #defines from src/include/catalog/pg_type.h,
something that isn't normally available to application programmers.  In
fact, maybe we just have to move those #defines into postgres.h or
something that is in the public include directory.

Just thinking out loud.

-- 
D'Arcy J.M. Cain <darcy@{druid|vex}.net>   |  Democracy is three wolves
http://www.druid.net/darcy/                |  and a sheep voting on
+1 416 424 2871     (DoD#0082)    (eNTP)   |  what's for dinner.


pgsql-interfaces by date:

Previous
From: barreiro@arrakis.es
Date:
Subject: Error linking C++ code.
Next
From: Tom Lane
Date:
Subject: Field types (was Re: Return value of int)