proof concept: do statement parametrization

Поиск
Список
Период
Сортировка
От Pavel Stehule
Тема proof concept: do statement parametrization
Дата
Msg-id AANLkTilueazLDBUjEoxzILJZCwnMd1oLvap_1HugKIYQ@mail.gmail.com
обсуждение исходный текст
Ответы Re: proof concept: do statement parametrization  (Florian Pflug <fgp@phlo.org>)
Список pgsql-hackers
Hello

I enhanced DO statement syntax to allowing a parameters. Syntax is
relative simple:

do ([varname] vartype := value, ...) $$ ... $$

It allows to pass a content of psql variables to inline code block to
allows more easy scripting

\set schema 'public'

do(text := :'schema') $$
declare r record;
begin
  for r in
      select * from information_schema.tables where table_schema = $1
  loop
    raise notice '>>> table %', r.table_name;
  end loop;
end $$;
NOTICE:  >>> table t
NOTICE:  >>> table t1
DO

ToDo:

* doesn't allows SubLinks :(

pavel@postgres:5432=# do(text := (SELECT :'schema')) $$ declare r
record; begin for r in select * from information_schema.tables where
table_schema = $1 loop raise notice '>>> table %', r.table_name; end
loop; end $$;
ERROR:  XX000: unrecognized node type: 315
LOCATION:  ExecInitExpr, execQual.c:4868

ideas, notes, comments??

Regards

Pavel Stehule

Вложения

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

Предыдущее
От: Robert Haas
Дата:
Сообщение: Re: pessimal trivial-update performance
Следующее
От: Rainer Pruy
Дата:
Сообщение: Re: pessimal trivial-update performance