Re: BUG #15198: nextval() accepts tables/indexes when adding adefault to a column
От | Feike Steenbergen |
---|---|
Тема | Re: BUG #15198: nextval() accepts tables/indexes when adding adefault to a column |
Дата | |
Msg-id | CAK_s-G0eNHk_RocV2UQ3_PJaaUfUegnx4BDRnjJ4aB0x8nK0iA@mail.gmail.com обсуждение исходный текст |
Ответ на | Re: BUG #15198: nextval() accepts tables/indexes when adding adefault to a column (Peter Eisentraut <peter.eisentraut@2ndquadrant.com>) |
Ответы |
Re: BUG #15198: nextval() accepts tables/indexes when adding adefault to a column
Re: BUG #15198: nextval() accepts tables/indexes when adding adefault to a column |
Список | pgsql-bugs |
On 16 May 2018 at 16:20, Peter Eisentraut <peter.eisentraut@2ndquadrant.com> wrote: > In this case, they are putting the erroneous call into a column default, > so the difference ends up being getting the error at setup time versus > at run time, which is a difference of significance. Yes, I'm not particularly concerned with nextval taking a regclass as an argument, and therefore raising this error, but I'd rather have this error at DDL time than at DML time. I don't know how hard it would be to implement, but say, calling currval(regclass) when a default is defined should already throw this error at DDL time. Or, when registering the default in the catalog, we verify that it is actually a sequence: Note: I'm not a C coder, so read it as pseudo-code please. --- a/src/backend/catalog/heap.c +++ b/src/backend/catalog/heap.c @@ -2059,6 +2059,9 @@ StoreAttrDefault(Relation rel, AttrNumber attnum, defobject.objectId = attrdefOid; defobject.objectSubId = 0; + if (!IsSequence( find_oid_referenced (defobject) ) ) + elog(ERROR, "Column defaults can only depend on sequences") + heap_close(adrel, RowExclusiveLock); /* now can free some of the stuff allocated above */ but again, I've only seen this once, so the value of adding this check seems very limited
В списке pgsql-bugs по дате отправления: