Suggestions for implementing IS DISTINCT FROM?
От | Thomas Lockhart |
---|---|
Тема | Suggestions for implementing IS DISTINCT FROM? |
Дата | |
Msg-id | 3D152B8F.1D429898@fourpalms.org обсуждение исходный текст |
Ответы |
Re: Suggestions for implementing IS DISTINCT FROM?
|
Список | pgsql-hackers |
I'm looking at implementing IS DISTINCT FROM, among other things. It has the unusual behavior that it compares elements for a tuple by considering two NULLs to be equal (hence non-distinct) rather than "unknown". So the rules for comparison seem to be: a) if the rows compared have different lengths, they are distinct b) if the rows are both zero-length, they are not distinct c) otherwise, each element in the row (or a single value on each side of the comparison) are compared pairwise, with1) if both elements are NULL, they are not distinct2) if one element of the pairis NULL, they are distinct3) if both elements are NOT NULL and are equal, they are not distinct4) if no pair of elementsis distinct, the rows are not distinct5) otherwise, the rows are distinct I was thinking to implement this by simply expanding these rules within gram.y to be a tree of comparison tests. But I think that this does not generalize properly into allowing tuples or rows to be supplied by subqueries or other non-literal tuples. So, I'm looking for suggestions on how to go about implementing this. Should I define a new comparison node like the AND expression which can directly handle the NULL behaviors correctly? That would require at least minor changes in the optimizer and executor. Does another approach come to mind (esp. one which works ;)? TIA - Thomas
В списке pgsql-hackers по дате отправления: