| From: | Serge Rielau <serge(at)rielau(dot)com> |
|---|---|
| To: | pgsql-hackers(at)postgresql(dot)org |
| Subject: | Silent bug in transformIndexConstraint |
| Date: | 2017-08-23 17:24:02 |
| Message-ID: | 6d911319-5207-46a4-b6aa-6432bb96c896@rielau.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | 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.
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Josh Berkus | 2017-08-23 18:11:29 | Re: Quorum commit for multiple synchronous replication. |
| Previous Message | Mark Rofail | 2017-08-23 17:01:18 | Re: GSoC 2017: Foreign Key Arrays |