| От | Tom Lane |
|---|---|
| Тема | Re: BUG #3599: Wrong search_path inside a function |
| Дата | |
| Msg-id | 26403.1188923274@sss.pgh.pa.us обсуждение исходный текст |
| Ответ на | BUG #3599: Wrong search_path inside a function ("Alexis Beuraud" <alexis@siatel.com>) |
| Список | pgsql-bugs |
"Alexis Beuraud" <alexis@siatel.com> writes:
> EXECUTE (' set search_path to ' || p_schemaName ); ---- setting the search
> path here!
> FOR result in
> select i
> from TableT
> loop
> return next result;
> END LOOP;
The reason that doesn't do what you expect is that the plan for the
SELECT is cached the first time through. You'll need to use FOR IN
EXECUTE to make this work. Rather than explicitly setting search_path
like that, which is likely to have unpleasant consequences all over the
place (hint: the effects persist after your function exits), you might
want to just insert the schema name into the EXECUTE string:
FOR result IN EXECUTE
'select i from ' || quote_ident(p_schemaName) || '.TableT'
LOOP ...
regards, tom lane
В списке pgsql-bugs по дате отправления:
Сайт использует файлы cookie для корректной работы и повышения удобства. Нажимая кнопку «Принять» или продолжая пользоваться сайтом, вы соглашаетесь на их использование в соответствии с Политикой в отношении обработки cookie ООО «ППГ», в том числе на передачу данных из файлов cookie сторонним статистическим и рекламным службам. Вы можете управлять настройками cookie через параметры вашего браузера