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

From: jam3 <jamorton3(at)gmail(dot)com>
To: 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 18:49:49
Message-ID: 1346870989069-5722876.post@n5.nabble.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

How does postgres figure this out to throw the error msg?

create table test_table
(
column1 char(10),
column2 varchar(20)
) without oids;


create or replace function test1(c1 char(10), c2 varchar(20))
returns void as
$$
BEGIN
insert into test_table values ($1, $2);
END
$$
language plpgsql

select test1('1234567890','ABCDEFGHIJKLMNOPQRST')

select * from test_table;
-- 1234567890, ABCDEFGHIJKLMNOPQRST

select test1('this is way way longer than 10 characters','this is way way
way way way way way way way way way way longer than 20 characters')

ERROR: value too long for type character(10)
CONTEXT: SQL statement "insert into test_table values ($1, $2)"
PL/pgSQL function "test1" line 3 at SQL statement

********** Error **********

ERROR: value too long for type character(10)

--
View this message in context: http://postgresql.1045698.n5.nabble.com/Where-is-the-char-and-varchar-length-in-pg-catalog-for-function-input-variables-tp5722845p5722876.html
Sent from the PostgreSQL - general mailing list archive at Nabble.com.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message jam3 2012-09-05 19:08:19 Re: "Too far out of the mainstream"
Previous Message Aleksey Tsalolikhin 2012-09-05 18:44:45 Re: postgres process got stuck in "notify interrupt waiting" status