Re: pgbench - allow to store select results into variables
Fabien COELHO <coelho@cri.ensmp.fr>
From: Fabien COELHO <coelho@cri.ensmp.fr>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Amit Langote <Langote_Amit_f8@lab.ntt.co.jp>,
Robert Haas <robertmhaas@gmail.com>,
Pavel Stehule <pavel.stehule@gmail.com>,
PostgreSQL Developers <pgsql-hackers@postgresql.org>
Date: 2017-01-07T09:25:06Z
Lists: pgsql-hackers
Attachments
- pgbench-into-7.patch (text/x-diff) patch
- gset-1.sql (application/x-sql)
- gset-err-1.sql (application/x-sql)
- gset-err-2.sql (application/x-sql)
- gset-err-3.sql (application/x-sql)
- gset-err-4.sql (application/x-sql)
- gset-err-5.sql (application/x-sql)
- gset-err-6.sql (application/x-sql)
- (unnamed) (text/plain)
Hello Tom, > Please look at changing \into to be a SQL-command-ending backslash > command as we previously discussed. Done. There are two variants: \gset & \gcset for compound (end SQL query, set variables, but do not end command, so that several settings are allowed in a compound command, a key feature for performance testing). Personnally, I find the end-of-query semicolon-replacing syntax ugly. However I'm more interested in feature than in elegance on this one, so I'll put up with it. > I think you will find that the implementation is a great deal simpler > that way and doesn't require weird hackery on the shared lexer. I have removed the "hackery", only counting embedded semicolons remains to keep track of compound queries. Note that the (somehow buggy and indeed not too clean) hackery was not related to the into syntax, but to detecting empty queries which are silently skipped by the server. > If you won't do that, [...] I think that I have done what you required. I have documented the fact that now the feature does not work if compound commands contain empty queries, which is a very minor drawback for a pgbench script anyway. Attached are the patch, a test script for the feature, and various test scripts to trigger error cases. -- Fabien.
Commits
-
pgbench: Remove \cset
- 25ee70511ec2 12.0 landed
-
pgbench: add \cset and \gset commands
- 6260cc550b0e 12.0 landed
-
Adjust pgbench to allow non-ASCII characters in variable names.
- 9d36a386608d 11.0 landed
-
Refactor script execution state machine in pgbench.
- 12788ae49e19 10.0 cited
-
Allow empty queries in pgbench.
- 6471045230f5 10.0 cited