| От | Tom Lane |
|---|---|
| Тема | Re: what exactly is a PlaceHolderVar? |
| Дата | |
| Msg-id | 23076.1277179362@sss.pgh.pa.us обсуждение |
| Ответ на | what exactly is a PlaceHolderVar? (Robert Haas <robertmhaas@gmail.com>) |
| Список | pgsql-hackers |
Robert Haas <robertmhaas@gmail.com> writes:
> ...but I'm still having a hard time wrapping my head around it.
The fundamental point is to be able to force a value to go to NULL
when outer-join logic says it ought to. Consider
CREATE VIEW foo AS SELECT x,y,'zed' FROM bar;
SELECT * FROM baz LEFT JOIN foo ON (baz.a = foo.x);
If you try to flatten the view then you end up with a constant 'zed'
that needs to be replaced by NULL whenever baz.a hasn't got a match
in bar.x. There's no way to make a constant go to NULL though: it's
a constant, n'est-ce pas? Instead, we have the idea of an expression
PlaceHolderVar(foo, 'zed'). This will go to null if variables from foo
ought to go to null. Otherwise it produces 'zed'. Sort of an
anti-COALESCE.
regards, tom lane
В списке pgsql-hackers по дате отправления:
Сайт использует файлы cookie для корректной работы и повышения удобства. Нажимая кнопку «Принять» или продолжая пользоваться сайтом, вы соглашаетесь на их использование в соответствии с Политикой в отношении обработки cookie ООО «ППГ», в том числе на передачу данных из файлов cookie сторонним статистическим и рекламным службам. Вы можете управлять настройками cookie через параметры вашего браузера