pg.ddx.io  pgsql-interfaces@postgresql.org mailing list archive  
help / color / mirror / Atom feed
types oids
2+ messages / 2 participants
[nested] [flat]

* types oids
@ 1999-08-16 23:18 Nicolas Aragon <nyco@jet.es>
  1999-08-17 00:23 ` Re: [INTERFACES] types oids Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 1 reply; 2+ messages in thread

From: Nicolas Aragon @ 1999-08-16 23:18 UTC (permalink / raw)
  To: pgsql-interfaces

Hello,

I'm programming with pqlib from Pascal (FPC) and trying to build some
classes to encapsulate result sets in a similar way as Delphi.

I need to know the type of every field and I've found that PQftype returns
an OID. OK, I can query pg_type system table and find out type information.

But this leads me to new questions because it seems that standard types
aren't hardcoded anywhere. pg_type tells me the name, size and some other
information about the type. But what about the "kind" of the type (numeric,
text, date...)?

I can only think of comparing the name with a list of names for standard
types. Is there another simpler method? A standard relation between standard
types and their OIDs?

If the answer to last question is "no", can I really trust at least the name?
If so, since I don't want to make the metadata query before each "regular"
query, I'll have to cache it. Is it OK to do it once per connection?

I can even think that.... is the user (admin) allowed to change the names
of standard types?

Another, more trivial question: do you know where to find nice logos
for postgres?

Thanks in advance


  Nico


http://www.clubdelphi.com/nico/




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

* Re: [INTERFACES] types oids
  1999-08-16 23:18 types oids Nicolas Aragon <nyco@jet.es>
@ 1999-08-17 00:23 ` Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 2+ messages in thread

From: Tom Lane @ 1999-08-17 00:23 UTC (permalink / raw)
  To: Nicolas Aragon <nyco@jet.es>; +Cc: pgsql-interfaces

Nicolas Aragon <nyco@jet.es> writes:
> But this leads me to new questions because it seems that standard types
> aren't hardcoded anywhere. pg_type tells me the name, size and some other
> information about the type. But what about the "kind" of the type (numeric,
> text, date...)?

You pretty much have to know from the name what the datatype is.
Postgres doesn't have any type categorization like that.  (Maybe it
should ... I think there are some hacks in the parser that amount to
categorizing the standard datatypes, but that knowledge is not visible
outside the parser.)

> I can only think of comparing the name with a list of names for standard
> types. Is there another simpler method? A standard relation between standard
> types and their OIDs?

In reality, the OIDs assigned to standard types like "bool" and "int4"
are unlikely ever to change; they certainly will not change faster than
once per Postgres major release.  You could probably get away with
hard-wiring the knowledge that OID 16 == bool, say.  If that seems a
little too ugly, reading the OIDs for known types during startup is
plenty good enough.

If you are dealing with user-defined types, looking up the OIDs at
startup is the way to go.  (User type OIDs could change across a
database dump/reload, so hardwiring those would be a bad idea.)

> I can even think that.... is the user (admin) allowed to change the names
> of standard types?

Not if he wants things to keep working ;-)

> Another, more trivial question: do you know where to find nice logos
> for postgres?

See the website.

			regards, tom lane



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


end of thread, other threads:[~1999-08-17 00:23 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
1999-08-16 23:18 types oids Nicolas Aragon <nyco@jet.es>
1999-08-17 00:23 ` Tom Lane <tgl@sss.pgh.pa.us>

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