Re: Where is the char and varchar length in pg_catalog for function input variables

From: "Kevin Grittner" <Kevin(dot)Grittner(at)wicourts(dot)gov>
To: "jam3" <jamorton3(at)gmail(dot)com>,<pgsql-general(at)postgresql(dot)org>
Subject: Re: Where is the char and varchar length in pg_catalog for function input variables
Date: 2012-09-05 21:02:13
Message-ID: 504777850200002500049EE0@gw.wicourts.gov
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

jam3 <jamorton3(at)gmail(dot)com> wrote:

> create or replace function test1(c1 char(10), c2 varchar(20))

> Just showing that it does indeed not use the length in at all

Correct. That is functioning as intended and is not likely to
change any time soon.

You might consider using domains:

drop function if exists test1(c1 t1, c2 t2);
drop table if exists test_table;
drop domain if exists t1;
drop domain if exists t2;

create domain t1 varchar(10);
create domain t2 varchar(20);
create table test_table
(
column1 char(20),
column2 varchar(40)
) without oids;
create or replace function test1(c1 t1, c2 t2)
returns void as
$$
BEGIN
insert into test_table values ($1, $2);
END
$$
language plpgsql;
select
test1('12345678900123456789',
'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ABCD');
select * from test_table;

-Kevin

In response to

Browse pgsql-general by date

  From Date Subject
Next Message David Johnston 2012-09-05 21:05:07 Re: Re: Where is the char and varchar length in pg_catalog for function input variables
Previous Message jam3 2012-09-05 20:51:47 Re: max_connections