typmod is always -1

Поиск
Список
Период
Сортировка
От Pavel Stehule
Тема typmod is always -1
Дата
Msg-id 162867790903161317q178e11e6ie276d1254c279dd1@mail.gmail.com
обсуждение исходный текст
Ответы Re: typmod is always -1
Список 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

В списке pgsql-hackers по дате отправления:

Предыдущее
От: "Jonah H. Harris"
Дата:
Сообщение: Re: Problem with accesing Oracle from plperlu functionwhen using remote pg client.
Следующее
От: Tom Lane
Дата:
Сообщение: Re: small but useful patches for text search