Re: [HACKERS] pgbench - allow to store select results into variables

Поиск
Список
Период
Сортировка
От Alvaro Herrera
Тема Re: [HACKERS] pgbench - allow to store select results into variables
Дата
Msg-id 20181116221313.nwc3ozw3tqvkzsec@alvherre.pgsql
обсуждение исходный текст
Ответ на Re: [HACKERS] pgbench - allow to store select results into variables  (Alvaro Herrera <alvherre@2ndquadrant.com>)
Список pgsql-hackers
On 2018-Nov-16, Alvaro Herrera wrote:

> On 2017-Nov-04, Fabien COELHO wrote:
> 
> > Think of one initialization followed by two appends:
> > 
> >   SELECT 1 AS x \cset
> >   SELECT 2 \; SELECT 3 AS y \cset
> >   SELECT 4 \; SELECT 5 \; SELECT 6 AS z \gset
> > 
> > In the end, we must have the full 6 queries
> > 
> >   "SELECT 1 AS x \; SELECT 2 \; SELECT 3 AS y \; SELECT 4 \; SELECT 5 \; SELECT 6 AS z"
> > 
> > and know that we want to set variables from queries 1, 3 and 6 and ignore
> > the 3 others.
> 
> I'm not sure I understand this.  Why is the "SELECT 2" ignored?  (I can
> see why the 4 and 5 are ignored: they are not processed by gset).
> 
> What exactly does \cset do?

Oh!  I understand it now.  You say "replace a semicolon" to mean "works
as if it were a semicolon, and also captures the result".  So \cset
means "works as if it were an escaped semicolon".  It all suddenly makes
sense now!  I think I'll propose some rewording of that explanation, as
it was very confusing to me.

-- 
Álvaro Herrera                https://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services


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

Предыдущее
От: Thomas Munro
Дата:
Сообщение: Re: Refactoring the checkpointer's fsync request queue
Следующее
От: Tom Lane
Дата:
Сообщение: Re: BUG #15449: file_fdw using program cause exit code error when using LIMIT