ERROR: MergeAppend child's targetlist doesn't match MergeAppend

Поиск
Список
Период
Сортировка
От Teodor Sigaev
Тема ERROR: MergeAppend child's targetlist doesn't match MergeAppend
Дата
Msg-id 4EB96BA8.60603@sigaev.ru
обсуждение исходный текст
Ответы Re: ERROR: MergeAppend child's targetlist doesn't match MergeAppend  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-hackers
Hi!

I ran into a problem with PG 9.1 and bug is observed even in master. After 
simplifying a query (original was 9Kb long!) it's possible to reproduce it easily:

CREATE TABLE wow (t1 text, t2 text);
CREATE INDEX idx ON wow (t1,t2);

SET enable_seqscan=off;
SET enable_bitmapscan=off;

EXPLAIN
SELECT    t1, t2
FROM (    SELECT t1, t2 FROM wow    UNION ALL    SELECT 'a', 'a' FROM wow
) t
ORDER BY t1, t2;

if second 'a' constant is changed to something else then it works fine.

The root of problem is that tlist_member() (called in 
create_merge_append_plan()) for second constant returns TargetEntry for first 
constant because they are equal. And the same problem is observed if second 
select is replaced by  "SELECT t1, t1 FROM wow".

It's seems to me that check in create_merge_append_plan() is too restrictive:        if (memcmp(sortColIdx,
node->sortColIdx,                  numsortkeys * sizeof(AttrNumber)) != 0)            elog(ERROR, "MergeAppend child's
targetlistdoesn't match 
 
MergeAppend");

Although I think, that more accurate check will repeat work done in 
prepare_sort_from_pathkeys().

-- 
Teodor Sigaev                                   E-mail: teodor@sigaev.ru
  WWW: http://www.sigaev.ru/
 


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

Предыдущее
От: Heikki Linnakangas
Дата:
Сообщение: Re: DatumGetInetP buggy
Следующее
От: Greg Smith
Дата:
Сообщение: Re: Measuring relation free space