[HACKERS] Silent bug in transformIndexConstraint

Поиск
Список
Период
Сортировка
От Serge Rielau
Тема [HACKERS] Silent bug in transformIndexConstraint
Дата
Msg-id 6d911319-5207-46a4-b6aa-6432bb96c896@rielau.com
обсуждение исходный текст
Ответы Re: [HACKERS] Silent bug in transformIndexConstraint  (Serge Rielau <serge@rielau.com>)
Список pgsql-hackers
In parse_utilcmd.c: transformIndexConstraint()
resides the following piece of code:


/*
* For UNIQUE and PRIMARY KEY, we just have a list of column names.
*
* Make sure referenced keys exist.  If we are making a PRIMARY KEY index,
* also make sure they are NOT NULL, if possible. (Although we could leave
* it to DefineIndex to mark the columns NOT NULL, it's more efficient to
* get it right the first time.)
*/
foreach(lc, constraint->keys)
{
char   *key = strVal(lfirst(lc));

The strVal() is wrong since first(lc) returns an IndexElem * and not a Value *
and we should be doing:
char *key = ((IndexElem *) lfirst(lc))->name

The existing code only works by luck because Value.val.str  happens to match the same offset as IndexElem.name.

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

Предыдущее
От: Mark Rofail
Дата:
Сообщение: Re: [HACKERS] GSoC 2017: Foreign Key Arrays
Следующее
От: Josh Berkus
Дата:
Сообщение: Re: [HACKERS] Quorum commit for multiple synchronous replication.