Datatyp of a column

Started by Ishaya Bhattabout 12 years ago3 messages
#1Ishaya Bhatt
ishayabhatt@gmail.com

Hi,
In the sorting code, I need to determine the datatype of my sort keys
and call some code conditionally based on the datatype. Is there any way to
determine the datatype of a column from the *backend* PostGreSQL code. is
the datatype of the column available in the query plan? Any help on this
would be very much appreciated.

Thanks,
Ishaya Bhatt.

#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Ishaya Bhatt (#1)
Re: Datatyp of a column

Ishaya Bhatt <ishayabhatt@gmail.com> writes:

In the sorting code, I need to determine the datatype of my sort keys
and call some code conditionally based on the datatype. Is there any way to
determine the datatype of a column from the *backend* PostGreSQL code. is
the datatype of the column available in the query plan? Any help on this
would be very much appreciated.

You really need to be more specific about where you need this information.
The "sorting code" certainly knows what datatypes it's working with ---
for example, in tuplesort.c there's a TupleDesc for the tuples passing
through the sort, and the column types are available from the per-column
atttypid fields of that. But it's not clear if that's what you're talking
about.

regards, tom lane

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

#3Ishaya Bhatt
ishayabhatt@gmail.com
In reply to: Tom Lane (#2)
Re: Datatyp of a column

Yes!! Thats exactly what I was looking for !! Thanks :)

On Mon, Nov 11, 2013 at 7:58 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:

Show quoted text

Ishaya Bhatt <ishayabhatt@gmail.com> writes:

In the sorting code, I need to determine the datatype of my sort

keys

and call some code conditionally based on the datatype. Is there any way

to

determine the datatype of a column from the *backend* PostGreSQL code. is
the datatype of the column available in the query plan? Any help on this
would be very much appreciated.

You really need to be more specific about where you need this information.
The "sorting code" certainly knows what datatypes it's working with ---
for example, in tuplesort.c there's a TupleDesc for the tuples passing
through the sort, and the column types are available from the per-column
atttypid fields of that. But it's not clear if that's what you're talking
about.

regards, tom lane