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 -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers