Re: [GENERAL] interperting type oid in C code

2015-10-20 Thread Albe Laurenz
Ken Been wrote: > I'm working on a foreign data wrapper and I want to switch based on the > column type. > Specifically, if the column type in the external table is the same as in the > (locally defined) foreign > table then I can get some speedup for some types. > > Through the ForeignScanState

Re: [GENERAL] interperting type oid in C code

2015-10-19 Thread Ken Been
Well, it's a few types, but the logic is different for each one, so they have to be handled independently anyway. On Mon, Oct 19, 2015 at 7:40 PM, Alvaro Herrera wrote: > Ken Been wrote: > > Those are more complicated, and it's not obvious to me how to use them. > I > > really think that all I n

Re: [GENERAL] interperting type oid in C code

2015-10-19 Thread Alvaro Herrera
Ken Been wrote: > Those are more complicated, and it's not obvious to me how to use them. I > really think that all I need is something as simple as "if (my_oid == > INT4OID) {...}". Is there any reason why I shouldn't just do that? I don't know. I was thinking that you might want to handle a l

Re: [GENERAL] interperting type oid in C code

2015-10-19 Thread Ken Been
Those are more complicated, and it's not obvious to me how to use them. I really think that all I need is something as simple as "if (my_oid == INT4OID) {...}". Is there any reason why I shouldn't just do that? On Mon, Oct 19, 2015 at 7:08 PM, Alvaro Herrera wrote: > Ken Been wrote: > > Thanks

Re: [GENERAL] interperting type oid in C code

2015-10-19 Thread Alvaro Herrera
Ken Been wrote: > Thanks, but I actually wanted to do it from C code. But anyway I think I > found the answer: use the symbolic constants in catalog/pg_type.h, such as > INT4OID. You can probably use SearchSysCache1(TYPEOID, ObjectIdGetDatum(your_oid)) or perhaps lookup_type_cache(your_oid). --

Re: [GENERAL] interperting type oid in C code

2015-10-19 Thread Ken Been
Thanks, but I actually wanted to do it from C code. But anyway I think I found the answer: use the symbolic constants in catalog/pg_type.h, such as INT4OID. On Mon, Oct 19, 2015 at 6:44 PM, Melvin Davidson wrote: > SELECT typname >FROM pg_type > WHERE oid = Oid_x; > > On Mon, Oct 19, 2015

Re: [GENERAL] interperting type oid in C code

2015-10-19 Thread Melvin Davidson
SELECT typname FROM pg_type WHERE oid = Oid_x; On Mon, Oct 19, 2015 at 2:36 PM, Ken Been wrote: > I'm working on a foreign data wrapper and I want to switch based on the > column type. Specifically, if the column type in the external table is the > same as in the (locally defined) foreign t

[GENERAL] interperting type oid in C code

2015-10-19 Thread Ken Been
I'm working on a foreign data wrapper and I want to switch based on the column type. Specifically, if the column type in the external table is the same as in the (locally defined) foreign table then I can get some speedup for some types. Through the ForeignScanState object I can get TupleDesc and