Re: CREATE TYPE with array

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: CREATE TYPE with array
Дата
Msg-id 6162.1058881677@sss.pgh.pa.us
обсуждение исходный текст
Ответ на CREATE TYPE with array  (Wolfgang Drotschmann <drotschm@fgan.de>)
Список 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 по дате отправления:

Предыдущее
От: Ben Clewett
Дата:
Сообщение: Encrypted data.
Следующее
От: "Chad Thompson"
Дата:
Сообщение: Fw: It worked! Was :Re: Select Statement Hang...