Re: [HACKERS] DEFAULT fixed

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: [HACKERS] DEFAULT fixed
Дата
Msg-id 27950.927500332@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: [HACKERS] DEFAULT fixed  (Bruce Momjian <maillist@candle.pha.pa.us>)
Ответы Re: [HACKERS] DEFAULT fixed  (Bruce Momjian <maillist@candle.pha.pa.us>)
Re: [HACKERS] DEFAULT fixed  (Bruce Momjian <maillist@candle.pha.pa.us>)
Список pgsql-hackers
Actually, it's not as fixed as all that...

create table foo1 (a char(5) default '', b int4);
insert into foo1 (b) values (334);
select * from foo1;
a    |  b
-----+---    |334
(1 row)

Good, the basic case is fixed, but:

create table foo2 (a char(5) default text '', b int4);
insert into foo2 (b) values (334);
select * from foo2;
a| b
-+--|16
(1 row)

Ooops.

What you seem to have done is twiddle the handling of DEFAULT clauses
so that the value stored for the default expression is pre-coerced to the
column type.  That's good as far as it goes, but it fails in cases where
the stored value has to be of a different type.

My guess is that what *really* ought to happen here is that
transformInsertStmt should check the type of the value it's gotten from
the default clause and apply coerce_type if necessary.

Unless someone can come up with a less artificial example than the one
above, I'm inclined to leave it alone for 6.5.  This is the same code
area that will have to be redone to fix the INSERT ... SELECT problem
I was chasing earlier today: coercion of the values produced by SELECT
will have to wait until the tail end of transformInsertStmt, and we
might as well make wrong-type default constants get fixed in the same
place.  So I'm not eager to write some throwaway code to patch a problem
that no one is likely to see in practice.  What's your feeling about it?
        regards, tom lane


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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: [HACKERS] Sequence nexvtal() and initdb/pg_proc problem
Следующее
От: "Hiroshi Inoue"
Дата:
Сообщение: RE: [HACKERS] Current TODO list