Re: Typmod associated with multi-row VALUES constructs

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Typmod associated with multi-row VALUES constructs
Дата
Msg-id 30604.1480972964@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: Typmod associated with multi-row VALUES constructs  ("David G. Johnston" <david.g.johnston@gmail.com>)
Ответы Re: Typmod associated with multi-row VALUES constructs
Список pgsql-hackers
"David G. Johnston" <david.g.johnston@gmail.com> writes:
> On Mon, Dec 5, 2016 at 1:08 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
>> In order to fix this, we first have to decide what the semantics ought
>> to be.  I think there are two plausible definitions:
>> 1. If all the expressions in the VALUES column share the same typmod,
>> use that typmod, else use -1.
>> 2. Use -1 whenever there is more than one VALUES row.

> ​Can we be precise enough to perform #2 if the top-level (or immediate
> parent) command is an INSERT - the existing table is going to enforce its
> own typemod anyway, otherwise go with #1?

I dunno if that's "precise" or just "randomly inconsistent" ;-)

> ​Lacking that possibility I'd say that documenting that our treatment of
> typemod in VALUES is similar to our treatment of typemod in function
> arguments would be acceptable. This suggests a #3 - simply use "-1"
> regardless of the number of rows in the VALUES expression.

I'm a bit concerned about whether that would introduce overhead that we
avoid today, in particular for something like

insert into foo (varchar20col) values ('bar'::varchar(20));

I think if we throw away the knowledge that the VALUES row produces the
right typmod already, we'd end up adding an unnecessary runtime coercion
step.
        regards, tom lane



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

Предыдущее
От: Haribabu Kommi
Дата:
Сообщение: Re: commitfest 2016-11 status summary
Следующее
От: Robert Haas
Дата:
Сообщение: Re: commitfest 2016-11 status summary