Re: User Defined Types in Java

From: Thomas Hallgren <thomas(at)tada(dot)se>
To: Martijn van Oosterhout <kleptog(at)svana(dot)org>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: User Defined Types in Java
Date: 2006-02-09 12:53:13
Message-ID: 43EB3B39.9050804@tada.se
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Martijn van Oosterhout wrote:
> On Thu, Feb 09, 2006 at 01:08:01PM +0100, Thomas Hallgren wrote:
>> Hi,
>> I'd like to enable UDT's written in Java and made some initial trial and
>> error. I don't get very far. Here's what I do:
>>
>> I take the 'complex' type example described in '31.11 User-Defined
>> Types' and change it to use Java functions (see below). But I get:
>>
>> ERROR: type "complex" does not exist
>
> If you look at the code it says in a comment:
>
> /*
> * Only C-coded functions can be I/O functions. We enforce this
> * restriction here mainly to prevent littering the catalogs with
> * shell types due to simple typos in user-defined function
> * definitions.
> */
>

Ouch. Any chance of getting this changed? If we can agree on a good design I'd be happy to
implement and submit it.

> However, you could probably work around this like so:
>
> CREATE FUNCTION dummy(cstring) RETURNS complex AS [random existing
> function] LANGUAGE INTERNAL;
>
> This will create the shell type. You then create your other functions
> and finally the type, at which point you can delete the dummy function
> again.
>

Great. Thanks. Then at least I can test if what I have in mind is feasible.

> Roundabout, but it should work (I hope). Note, if you have a validator
> on your java code that tries to lookup the return type, you might get
> some interesting issues.
>

I don't yet. But I'll keep it in mind to watch out for shell types once I do.

Regards,
Thomas Hallgren

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Martijn van Oosterhout 2006-02-09 13:10:54 Re: User Defined Types in Java
Previous Message korry 2006-02-09 12:51:11 Re: pg_hba.conf alternative