typmod is always -1

From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: typmod is always -1
Date: 2009-03-16 20:17:48
Message-ID: 162867790903161317q178e11e6ie276d1254c279dd1@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hello

I am playing with custom typmod. I did simple wrapper over varchar type.

PG_FUNCTION_INFO_V1(mvarcharin);

Datum
mvarcharin(PG_FUNCTION_ARGS)
{
elog(NOTICE, ">>>>>>>>%d", PG_GETARG_INT32(2));
return DirectFunctionCall3(varchar,
DirectFunctionCall3(varcharin,

PG_GETARG_DATUM(0),

PG_GETARG_DATUM(1),

Int32GetDatum(-1)),
PG_GETARG_DATUM(2),
/* original typmod */
BoolGetDatum(true));
/* explit casting, quite truncate */
}

CREATE TYPE mvarchar (
INPUT = mvarcharin,
OUTPUT = mvarcharout,
LIKE = pg_catalog.varchar,
typmod_in = pg_catalog.varchartypmodin,
typmod_out = pg_catalog.varchartypmodout
);

I have a problem - every call of mvarcharin is with typmod = -1.

postgres=# create table x(a mvarchar(3));
CREATE TABLE
Time: 29,930 ms
postgres=# \d x
Table "public.x"
┌────────┬─────────────┬───────────┐
│ Column │ Type │ Modifiers │
├────────┴─────────────┴───────────┤
│ a │ mvarchar(3) │ │
└──────────────────────────────────┘

postgres=# INSERT INTO x values('abcdef');
NOTICE: >>>>>>>>-1
INSERT 0 1
Time: 2,244 ms
postgres=#

can somebody navigate me?

regards
Pavel Stehule

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2009-03-16 20:41:29 Re: small but useful patches for text search
Previous Message Jonah H. Harris 2009-03-16 20:00:46 Re: Problem with accesing Oracle from plperlu functionwhen using remote pg client.