Re: Sort a column that does not exist

Поиск
Список
Период
Сортировка
От Hitoshi Harada
Тема Re: Sort a column that does not exist
Дата
Msg-id e08cc0400904010313s69fb7b69hc65826dad4f6fc13@mail.gmail.com
обсуждение исходный текст
Ответ на Sort a column that does not exist  (Werner Echezuria <wercool@gmail.com>)
Ответы Re: Sort a column that does not exist  (Werner Echezuria <wercool@gmail.com>)
Список pgsql-hackers
2009/4/1 Werner Echezuria <wercool@gmail.com>:
> As you can see if someone do this: SELECT * FROM table WHERE
> field=some_value ORDER BY grmemb, postgresql creates a new target entry and
> then assigned to the targetlist as a sort node. I know that it creates the
> node on the parser, but it does not work, it seems the executor don't see
> it.

See include/nodes/primnodes.h around line 1075:bool        resjunk;        /* set to true to eliminate the attribute
from                            * final target list */
 

If the TargetEntry is set resjunk = false, the final result is
filtered as junk. So more accurately the executor sees but drops it.

>
> How could I sort a column like this?, I know i'm missing something, but i
> just don't see it. What is the process to sort a column?
>

Use makeTargetEntry in makefuncs.c
TargetEntry *
makeTargetEntry(Expr *expr,            AttrNumber resno,            char *resname,            bool resjunk)

by the 4th argument you can set resjunk = false if you don't want it
to be in the result.

Regards,


-- 
Hitoshi Harada


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

Предыдущее
От: Nikhil Sontakke
Дата:
Сообщение: Re: Partitioning feature ...
Следующее
От: Heikki Linnakangas
Дата:
Сообщение: Re: More message encoding woes