getting type name
Hi,
How do i get a char * type from a type Oid. i.e. getStringTypeFromOid(INT4OID)
will return "int4".
10x.
--
Regards,
Tzahi.
--
Tzahi Fadida
Blog: http://tzahi.blogsite.org | Home Site: http://tzahi.webhop.info
WARNING TO SPAMMERS: see at
http://members.lycos.co.uk/my2nis/spamwarning.html
On Sun, Jul 09, 2006 at 09:03:21PM +0300, Tzahi Fadida wrote:
How do i get a char * type from a type Oid. i.e. getStringTypeFromOid(INT4OID)
will return "int4".
Server-side or client-side? In the backend I think you could use
format_type_be() or format_type_with_typemod(), both declared in
utils/builtins.h and defined in src/backend/utils/adt/format_type.c.
--
Michael Fuhr
On Sunday 09 July 2006 21:49, Michael Fuhr wrote:
On Sun, Jul 09, 2006 at 09:03:21PM +0300, Tzahi Fadida wrote:
How do i get a char * type from a type Oid. i.e.
getStringTypeFromOid(INT4OID) will return "int4".Server-side or client-side? In the backend I think you could use
Backend.
format_type_be() or format_type_with_typemod(), both declared in
utils/builtins.h and defined in src/backend/utils/adt/format_type.c.
They return format_type_be(INT4OID) = "integer" or format_type_be(FLOAT8OID)
= "double precision"
I need to use this in a query with the "::" cast operator.
There is a function SPI_gettype but it works on relations. I wish to work
directly with the oid types without opening a relation.
10x.
--
Regards,
Tzahi.
--
Tzahi Fadida
Blog: http://tzahi.blogsite.org | Home Site: http://tzahi.webhop.info
WARNING TO SPAMMERS: see at
http://members.lycos.co.uk/my2nis/spamwarning.html
On Sun, Jul 09, 2006 at 10:08:42PM +0300, Tzahi Fadida wrote:
They return format_type_be(INT4OID) = "integer" or format_type_be(FLOAT8OID)
= "double precision"
I need to use this in a query with the "::" cast operator.
The problem being?
test=# select '1'::integer, '4.5'::double precision;
int4 | float8
------+--------
1 | 4.5
(1 row)
Have a nice day,
--
Martijn van Oosterhout <kleptog@svana.org> http://svana.org/kleptog/
Show quoted text
From each according to his ability. To each according to his ability to litigate.
On Monday 10 July 2006 00:29, Martijn van Oosterhout wrote:
On Sun, Jul 09, 2006 at 10:08:42PM +0300, Tzahi Fadida wrote:
They return format_type_be(INT4OID) = "integer" or
format_type_be(FLOAT8OID) = "double precision"
I need to use this in a query with the "::" cast operator.The problem being?
Just if it is a one-to-one conversion, otherwise the same type
equality functions i use would potentially not work properly.
test=# select '1'::integer, '4.5'::double precision;
int4 | float8
------+--------
1 | 4.5
(1 row)Have a nice day,
--
Regards,
Tzahi.
--
Tzahi Fadida
Blog: http://tzahi.blogsite.org | Home Site: http://tzahi.webhop.info
WARNING TO SPAMMERS: see at
http://members.lycos.co.uk/my2nis/spamwarning.html
On Mon, Jul 10, 2006 at 02:03:11AM +0300, Tzahi Fadida wrote:
On Monday 10 July 2006 00:29, Martijn van Oosterhout wrote:
On Sun, Jul 09, 2006 at 10:08:42PM +0300, Tzahi Fadida wrote:
They return format_type_be(INT4OID) = "integer" or
format_type_be(FLOAT8OID) = "double precision"
I need to use this in a query with the "::" cast operator.The problem being?
Just if it is a one-to-one conversion, otherwise the same type
equality functions i use would potentially not work properly.
Well, it is a one-to-one conversion. A float8 == double precision. They
are mapped together very early. Similarly for integer == int4. If you
look in the pg_type table, you'll see there are no entries for
"integer" or "double precision".
The fancy output is mostly for compatability purposes (SQL defines
these names).
Have a nice day,
--
Martijn van Oosterhout <kleptog@svana.org> http://svana.org/kleptog/
Show quoted text
From each according to his ability. To each according to his ability to litigate.