Re: [HACKERS] pgbench - allow to store select results into variables
Alvaro Herrera <alvherre@2ndquadrant.com>
From: Alvaro Herrera <alvherre@2ndquadrant.com>
To: Fabien COELHO <coelho@cri.ensmp.fr>
Cc: Michael Paquier <michael@paquier.xyz>, Stephen Frost <sfrost@snowman.net>, Andrew Dunstan <andrew.dunstan@2ndquadrant.com>, PostgreSQL Developers <pgsql-hackers@postgresql.org>
Date: 2019-01-03T17:51:02Z
Lists: pgsql-hackers
Attachments
- pgbench-into-25.patch (text/x-diff) patch
I revised this patch a bit. Here's v25, where some finishing touches are needed -- see below. I think with these changes the patch would become committable, at least for me. I didn't like that you were adding an #include of psqlscan_int.h into pgbench.c, when there's a specific comment in the header saying not to do that, so I opted for adding a new accessor function on psqlscan.h. I renamed some of your parameter additions. I think the new names are clearer, but they meant the +1's in your code are now in illogical places. (I moved some; probably not enough). Please review/fix that. I think "gset" is not a great name for the new struct member; please find a better name. I suggest "targetvar" but feel free to choose a name that suits your taste. There are two XXX comments. One is about a function needing a comment atop it. The other is about realloc behavior. To fix this one I would add a new struct member indicating the allocated size of the array, then growing exponentially instead of one at a time. For most cases you can probably get away with never reallocating beyond an initial allocation of, say, 8 members. In the docs, the [prefix] part needs to be explained in the \cset entry; right now it's in \gset, which comes afterwards. Let's move the explanation up, and then in \gset say "prefix behaves as in \cset". Thanks -- Álvaro Herrera https://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
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