Thread: Data type OID numbers fixed?

Data type OID numbers fixed?

From
"Stephen R. van den Berg"
Date:
I'm in the process of finishing a native Protocol 3 PostgreSQL driver
written in Pike.
And while trying to make it make intelligent decisions regarding binary
or text encoding of different columns and parameters, I run into the
OIDs of types.

In looking through the specs, I decided that the following OIDtypes will
be (automatically) binary passed (both as results and as parameters),
all others will be passed as text:
   case 16:   // _bool   case 17:   // _bytea   case 18:   // _char   case 20:   // _int8   case 21:   // _int2   case
23:  // _int4   case 25:   // _text   case 142:  // _xml   case 829:  // _macaddr   case 869:  // _inet   case 1042: //
_bpchar  case 1043: // _varchar   case 1700: // _numeric   case 2950: // _uuid
 

How large is the probability of these numbers ever changing?
Should I extract them from a query at the beginning of the connection?
Or can I leave them hardcoded in the driver?
-- 
Sincerely,          Stephen R. van den Berg.

A truly wise man never plays leapfrog with a unicorn.


Re: Data type OID numbers fixed?

From
Alvaro Herrera
Date:
Stephen R. van den Berg wrote:

> How large is the probability of these numbers ever changing?

Really small.  I'd just hardcode them.


-- 
Alvaro Herrera                                http://www.CommandPrompt.com/
PostgreSQL Replication, Consulting, Custom Development, 24x7 support


Re: Data type OID numbers fixed?

From
Tom Lane
Date:
"Stephen R. van den Berg" <srb@cuci.nl> writes:
>     case 16:   // _bool
>     case 17:   // _bytea
>     case 18:   // _char
>     case 20:   // _int8
>     case 21:   // _int2
>     case 23:   // _int4
>     case 25:   // _text
>     case 142:  // _xml
>     case 829:  // _macaddr
>     case 869:  // _inet
>     case 1042: // _bpchar
>     case 1043: // _varchar
>     case 1700: // _numeric
>     case 2950: // _uuid

> How large is the probability of these numbers ever changing?

Not very, but just on code readability grounds, you should use the
macros from pg_type.h instead of writing literal constants.
        regards, tom lane


Re: Data type OID numbers fixed?

From
imad
Date:
I'd include catalog/pg_type.h and use the #DEFINE for that.

--Imad

On Tue, Jul 8, 2008 at 10:16 AM, Alvaro Herrera
<alvherre@commandprompt.com> wrote:
> Stephen R. van den Berg wrote:
>
>> How large is the probability of these numbers ever changing?
>
> Really small.  I'd just hardcode them.
>
>
> --
> Alvaro Herrera                                http://www.CommandPrompt.com/
> PostgreSQL Replication, Consulting, Custom Development, 24x7 support
>
> --
> Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-hackers
>