From: | darcy(at)druid(dot)net (D'Arcy J(dot)M(dot) Cain) |
---|---|
To: | bryan(at)arcamax(dot)com (Bryan White) |
Cc: | pgsql-interfaces(at)postgreSQL(dot)org |
Subject: | Re: [INTERFACES] Determine data type of columns |
Date: | 1998-11-10 22:27:41 |
Message-ID: | m0zdMGE-0000eRC@druid.net |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-interfaces |
Thus spake Bryan White
> This brings me to my question. The PQftype function returns an OID but I
> don't see any documentation on how to interpret it. Are the values constant
> for the built in types (specifically int4, text, and date)?
> Do I have to execute another query to determine the actual type?
> Is there a way to encode the values in an insert/update statement such that
> they will be quietly converted to the proper type on the backend?
Look at how I do it in PyGreSQL. The code is available at
http://www.druid.net/pygresql/
First, I run this Python script to get the proper OIDs.
#! /usr/local/bin/python
import string
# change this if you have it somewhere else
for l in open("/usr/local/pgsql/src/include/catalog/pg_type.h").readlines():
tokens = string.split(l)
if len(tokens) == 0 or tokens[0] != "#define": continue
if tokens[1] in ('CASHOID', 'INT2OID', 'INT4OID', 'OIDOID', 'FLOAT4OID', 'FLOAT8OID'):
print l,
This gets me my #defines. My assumption is that if it isn't one of those
then I just treat it as text. I include this in my C source with a
comment about how naughty I am. Then I use these values in the functions
that have to do the conversions.
--
D'Arcy J.M. Cain <darcy(at){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.
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 1998-11-10 23:19:30 | Re: [INTERFACES] Determine data type of columns |
Previous Message | Bryan White | 1998-11-10 21:21:26 | Determine data type of columns |