pg.ddx.io  pgsql-interfaces@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Field types (was Re: Return value of int)
6+ messages / 4 participants
[nested] [flat]

* Field types (was Re: Return value of int)
@ 1999-05-02 22:36  Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 1 reply; 6+ messages in thread

From: Tom Lane @ 1999-05-02 22:36 UTC (permalink / raw)
  To: pgsql-interfaces

"D'Arcy" "J.M." Cain <darcy@druid.net> writes:
> 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.

Well, I don't see a big problem with stealing the defines --- the odds
of the OID for INT4, say, ever changing are pretty low.

But of course the "official, documented" way to find out what a given
type OID means is

	SELECT typname FROM pg_type WHERE oid = <whatever>;

If you kept a cache of type info on the application side, you could
probably even make this fast enough to be a reasonable approach :-)

			regards, tom lane



^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: [INTERFACES] Field types (was Re: Return value of int)
@ 1999-05-03 21:45  Hugh Lawson <hglawson@nr.infi.net>
  parent: Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 1 reply; 6+ messages in thread

From: Hugh Lawson @ 1999-05-03 21:45 UTC (permalink / raw)
  To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: pgsql-interfaces

On Sun, 2 May 1999, Tom Lane wrote:

> "D'Arcy" "J.M." Cain <darcy@druid.net> writes:
> > 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.
> 
> Well, I don't see a big problem with stealing the defines --- the odds
> of the OID for INT4, say, ever changing are pretty low.
> 
> But of course the "official, documented" way to find out what a given
> type OID means is
> 
> 	SELECT typname FROM pg_type WHERE oid = <whatever>;



I'm just getting started on fiddling with libpq.  I am wondering why
this passage from man libpq doesn't address this issue?  I'm not being
a smarty here, I just don't know the answer.

 PQftype returns the field type associated with  the
              given  field  index.  The  integer  returned  is an
              internal coding of the type.  Field  indices  start
              at 0.
              Oid PQftype(PGresult *res,
                          int field_num);
 

Hugh Lawson
Greensboro, North Carolina
hglawson@nr.infi.net





^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: [INTERFACES] Field types (was Re: Return value of int)
@ 1999-05-03 23:54  Tom Lane <tgl@sss.pgh.pa.us>
  parent: Hugh Lawson <hglawson@nr.infi.net>
  0 siblings, 1 reply; 6+ messages in thread

From: Tom Lane @ 1999-05-03 23:54 UTC (permalink / raw)
  To: hglawson@nr.infi.net; +Cc: pgsql-interfaces

Hugh Lawson <hglawson@nr.infi.net> writes:
> I'm just getting started on fiddling with libpq.  I am wondering why
> this passage from man libpq doesn't address this issue?  I'm not being
> a smarty here, I just don't know the answer.

>  PQftype returns the field type associated with  the
>               given  field  index.  The  integer  returned  is an
>               internal coding of the type.

Unless I missed what D'Arcy was getting at, his point was that when
PQftype tells you the field type is, say, 23, how do you know what
that means?

			regards, tom lane



^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: [INTERFACES] Field types (was Re: Return value of int)
@ 1999-05-04 02:37  D'Arcy J.M. Cain <darcy@druid.net>
  parent: Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 2 replies; 6+ messages in thread

From: "D'Arcy" "J.M." Cain @ 1999-05-04 02:37 UTC (permalink / raw)
  To: tgl@sss.pgh.pa.us; +Cc: pgsql-interfaces

Thus spake Tom Lane
> Hugh Lawson <hglawson@nr.infi.net> writes:
> > I'm just getting started on fiddling with libpq.  I am wondering why
> > this passage from man libpq doesn't address this issue?  I'm not being
> > a smarty here, I just don't know the answer.
> 
> >  PQftype returns the field type associated with  the
> >               given  field  index.  The  integer  returned  is an
> >               internal coding of the type.
> 
> Unless I missed what D'Arcy was getting at, his point was that when
> PQftype tells you the field type is, say, 23, how do you know what
> that means?

Exactly.

-- 
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.



^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: [INTERFACES] Field types (was Re: Return value of int)
@ 1999-05-04 06:59  Hannu Krosing <hannu@trust.ee>
  parent: D'Arcy J.M. Cain <darcy@druid.net>
  1 sibling, 0 replies; 6+ messages in thread

From: Hannu Krosing @ 1999-05-04 06:59 UTC (permalink / raw)
  To: pgsql-interfaces; +Cc: Tom Lane <tgl@sss.pgh.pa.us>; D'Arcy J.M. Cain <darcy@{druid|vex}.net>

"D'Arcy J.M. Cain" wrote:
> 
> Thus spake Tom Lane
> > Hugh Lawson <hglawson@nr.infi.net> writes:
> > > I'm just getting started on fiddling with libpq.  I am wondering why
> > > this passage from man libpq doesn't address this issue?  I'm not being
> > > a smarty here, I just don't know the answer.
> >
> > >  PQftype returns the field type associated with  the
> > >               given  field  index.  The  integer  returned  is an
> > >               internal coding of the type.
> >
> > Unless I missed what D'Arcy was getting at, his point was that when
> > PQftype tells you the field type is, say, 23, how do you know what
> > that means?

do "select * from pg_type where oid=23" and work from there on.

The 'internal coding' actually means OID for that type definition row.
(Could someone post a patch for docs ?)

the base types ids are quite stable and could possibly be found in some
.h file,
but anything new you add gets o quite random OID.

------------------
Hannu



^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: [INTERFACES] Field types (was Re: Return value of int)
@ 1999-05-04 14:55  Hugh Lawson <hglawson@nr.infi.net>
  parent: D'Arcy J.M. Cain <darcy@druid.net>
  1 sibling, 0 replies; 6+ messages in thread

From: Hugh Lawson @ 1999-05-04 14:55 UTC (permalink / raw)
  To: pgsql-interfaces; +Cc: Tom Lane <tgl@sss.pgh.pa.us>

On Mon, 3 May 1999, D'Arcy J.M. Cain wrote:

> Thus spake Tom Lane
> > Hugh Lawson <hglawson@nr.infi.net> writes:
> > > I'm just getting started on fiddling with libpq.  I am wondering why
> > > this passage from man libpq doesn't address this issue?  I'm not being
> > > a smarty here, I just don't know the answer.
> > 
> > >  PQftype returns the field type associated with  the
> > >               given  field  index.  The  integer  returned  is an
> > >               internal coding of the type.
> > 
> > Unless I missed what D'Arcy was getting at, his point was that when
> > PQftype tells you the field type is, say, 23, how do you know what
> > that means?
> 
> Exactly.

Uhhh, <cringe>, <blush>, thanks for the patient education.  Boy did I
ever miss the point!  Programming this is over my head right now, so
I'm saving these msgs.

Hugh Lawson
Greensboro, North Carolina
hglawson@nr.infi.net






^ permalink  raw  reply  [nested|flat] 6+ messages in thread


end of thread, other threads:[~1999-05-04 14:55 UTC | newest]

Thread overview: 6+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
1999-05-02 22:36 Field types (was Re: Return value of int) Tom Lane <tgl@sss.pgh.pa.us>
1999-05-03 21:45 ` Hugh Lawson <hglawson@nr.infi.net>
1999-05-03 23:54   ` Tom Lane <tgl@sss.pgh.pa.us>
1999-05-04 02:37     ` D'Arcy J.M. Cain <darcy@druid.net>
1999-05-04 06:59       ` Hannu Krosing <hannu@trust.ee>
1999-05-04 14:55       ` Hugh Lawson <hglawson@nr.infi.net>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox