Re: CREATE TYPE with array - Mailing list pgsql-novice

From Tom Lane
Subject Re: CREATE TYPE with array
Date
Msg-id 6162.1058881677@sss.pgh.pa.us
Whole thread Raw
In response to CREATE TYPE with array  (Wolfgang Drotschmann <drotschm@fgan.de>)
List pgsql-novice
Wolfgang Drotschmann <drotschm@fgan.de> writes:
> I tried to create a new type with an array in it.  So I took an example
> from (the german translation of) "PostgreSQL: Introduction and Concepts"
> by Bruce Momjian.

> create type int4array (
>        input=array_in,output=array_out,
>        internallength=variable,element=int4
> );
> ERROR:  TypeCreate: function array_out(int4array) does not exist

7.3 is stricter about the declarations of datatype I/O functions than
prior releases were.  Since array_out is declared to take anyarray,
not int4array, the above fails.

You could hack your way to a working datatype by creating extra pg_proc
entries for array_in/_out:

regression=# create function int4array_in(cstring) returns int4array
regression-# as 'array_in' language internal strict immutable;
NOTICE:  ProcedureCreate: type int4array is not yet defined
CREATE FUNCTION
regression=# create function int4array_out(int4array) returns cstring
regression-# as 'array_out' language internal strict immutable;
NOTICE:  Argument type "int4array" is only a shell
CREATE FUNCTION
regression=# create type int4array (
regression(# input=int4array_in, output=int4array_out,
regression(# internallength=variable,element=int4
regression(# );
CREATE TYPE
regression=#

            regards, tom lane

pgsql-novice by date:

Previous
From: Ben Clewett
Date:
Subject: Encrypted data.
Next
From: "Chad Thompson"
Date:
Subject: Fw: It worked! Was :Re: Select Statement Hang...