Re: pgbench - allow backslash-continuations in custom scripts

Поиск
Список
Период
Сортировка
От Kyotaro HORIGUCHI
Тема Re: pgbench - allow backslash-continuations in custom scripts
Дата
Msg-id 20150724.121514.70011563.horiguchi.kyotaro@lab.ntt.co.jp
обсуждение исходный текст
Ответ на Re: pgbench - allow backslash-continuations in custom scripts  (Fabien COELHO <coelho@cri.ensmp.fr>)
Ответы Re: pgbench - allow backslash-continuations in custom scripts  (Fabien COELHO <coelho@cri.ensmp.fr>)
Список pgsql-hackers
Hi,

> If you feel that this feature only deserve a lexer solution, then the
> patch should be "returned with feedback".

It's unfortunate to abandon this idea so I tried this and made it
run with psql's parser.  I think it works as expected.

The attached files are as follwoing.

- 0001-Prepare-for-share-psqlscan-with-pgbench.patchA patch to modify psql so that psqlscan can be shared with other
modules.

- 0002-Make-use-of-psqlscan-in-pgbench.patchA patch to use psqlscan in pgbench.

- hoge.sqlA sample custom script including multilne statement and line comment 

I can't judge wheter this is a new version of Febien's patch
following Tom's suggestion or brand-new one. Anyway I'd like to
post on this thread.


======
At Fri, 17 Jul 2015 21:26:44 +0200 (CEST), Fabien COELHO <coelho@cri.ensmp.fr> wrote in
<alpine.DEB.2.10.1507172113080.31314@sto>
> > Pgbench variable substitution is performed when the script is run, not
> > while the file is being processed for being split, which is when a
> > lexer would be used. The situation is not the same with psql. The most
> > it could do would be to keep track of what substitution are done in
> > queries.
> >
> >> So this is looking *eminently* doable.
> >
> > Possibly.  How much more effort would be involved compared to the
> > quick patch I did, I wonder:-)


The patch set consists of two parts.

The first modifies psqlscan.l to work in pgbench. Almost along on
Tom's suggestion.
 - Eliminate direct reading of pset and store them into   PsqlScanState in psql_scan_setup.
 - variables, common, settings and prompt in pgbench are the   shrinked version from that of psql.

The second part modifies pgbench to use the modified version of
psqlscan.l. As the result,

- Multiline SQLs (not backslash continuation) in custom script is allowed. (also for builtins but it's no use).

- backslash commands is handled as the same as before: multiline is not allowed.

A sample script is also attached.

Suggestions? Opinions?

I don't have idea how to deal with the copy of psqlscan.[lh] from
psql. Currently they are simply the dead copies of those of psql.

- Modifying psqlscan in psql requires consideration on how it is used in pgbench.

- They are rather small but common, variables, prompt are essentially needeless files..



reagsrds,

-- 
Kyotaro Horiguchi
NTT Open Source Software Center

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

Предыдущее
От: Alvaro Herrera
Дата:
Сообщение: Re: BRIN index and aborted transaction
Следующее
От: Amit Kapila
Дата:
Сообщение: Re: RFC: replace pg_stat_activity.waiting with something more descriptive