Unix Technical Forum

Finding the correct type

This is a discussion on Finding the correct type within the pgsql Hackers forums, part of the PostgreSQL category; --> I'm writing a UDT that takes a varchar argument that represents the name of a type. The caller may ...


Go Back   Unix Technical Forum > Database Server Software > PostgreSQL > pgsql Hackers

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-12-2008, 02:13 AM
Thomas Hallgren
 
Posts: n/a
Default Finding the correct type

I'm writing a UDT that takes a varchar argument that represents the name
of a type. The caller may optionally qualify with a namespace, i.e.
"pg_catalog.varchar", or "public.address". Is there a c-function
somewhere that will return the pg_type that corresponds to the name
(with respect to the current setting of search_path in case the name is
unqualified)?

Regards,
Thomas Hallgren


---------------------------(end of broadcast)---------------------------
TIP 4: Have you searched our list archives?

http://archives.postgresql.org

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-12-2008, 02:13 AM
Martijn van Oosterhout
 
Posts: n/a
Default Re: Finding the correct type

On Sun, Apr 30, 2006 at 12:50:23PM +0200, Thomas Hallgren wrote:
> I'm writing a UDT that takes a varchar argument that represents the name
> of a type. The caller may optionally qualify with a namespace, i.e.
> "pg_catalog.varchar", or "public.address". Is there a c-function
> somewhere that will return the pg_type that corresponds to the name
> (with respect to the current setting of search_path in case the name is
> unqualified)?


If you want it as a C string, something like format_type_be() would
suffice. Not it's designed for use in error messages so it makes no
particular to clean up after itself.

Another possibility is the output function for the regtype type, ie
regtypeout.

Hope this helps,
--
Martijn van Oosterhout <kleptog@svana.org> http://svana.org/kleptog/
> From each according to his ability. To each according to his ability to litigate.


-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)

iD8DBQFEVJhvIB7bNG8LQkwRAo1sAJ0aUGsvQitfVMJ5HxOCfy HiCJeT1wCfRwxT
Ld8iDAxhHj6Ak6pd7oiWSKM=
=TvXy
-----END PGP SIGNATURE-----

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 04-12-2008, 02:13 AM
Thomas Hallgren
 
Posts: n/a
Default Re: Finding the correct type

Martijn van Oosterhout wrote:
> On Sun, Apr 30, 2006 at 12:50:23PM +0200, Thomas Hallgren wrote:
>> I'm writing a UDT that takes a varchar argument that represents the name
>> of a type. The caller may optionally qualify with a namespace, i.e.
>> "pg_catalog.varchar", or "public.address". Is there a c-function
>> somewhere that will return the pg_type that corresponds to the name
>> (with respect to the current setting of search_path in case the name is
>> unqualified)?

>
> If you want it as a C string, something like format_type_be() would
> suffice. Not it's designed for use in error messages so it makes no
> particular to clean up after itself.
>
> Another possibility is the output function for the regtype type, ie
> regtypeout.
>
> Hope this helps,

Well, regtypeout led me to regtypein which in turn led me to parseTypeString which seems to
be exactly what I want.

Thanks,
Thomas Hallgren


---------------------------(end of broadcast)---------------------------
TIP 3: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faq

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 10:54 PM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com