Re: CREATE TYPE with array

From: Wolfgang Drotschmann <drotschm(at)fgan(dot)de>
To: pgsql-novice(at)postgresql(dot)org
Subject: Re: CREATE TYPE with array
Date: 2003-07-23 08:21:33
Message-ID: 3F1E458D.B96F7B13@fgan.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

Thank you Tom,

so far so good. I tried the following for a database "foo" and being a
"normal" user...

Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> schrieb:
> [...]
> 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=#

create function int4array_in(cstring) returns int4array
as 'array_in' language internal strict immutable;
ERROR: internal: permission denied

Okay, switch to "root":

\c foo postgres
Password:
You are now connected to database foo as user postgres.
create function int4array_in(cstring) returns int4array
as 'array_in' language internal strict immutable;
NOTICE: ProcedureCreate: type int4array is not yet defined
CREATE FUNCTION

create function int4array_out(int4array) returns cstring
as 'array_out' language internal strict immutable;
NOTICE: Argument type "int4array" is only a shell
CREATE FUNCTION

Back to user "bpe" and trying to create a type

create type int4array (
input=int4array_in, output=int4array_out,
internallength=variable,element=int4
);
CREATE TYPE

Now! Creating a table...

create table xs ( a char(5), l int4array[]);
CREATE TABLE

...and inserting a row:

insert into xs values('abcde', '{1,2,3,4}');
ERROR: array_in: Need to specify dimension

Ups!?!

Best regards,
Wolfgang

In response to

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Jason Topaz 2003-07-23 08:57:45 Struggling with set-returning functions, seeking advice
Previous Message Markus Bertheau 2003-07-23 06:00:29 Re: Locking tables