Make psql's \set display variables in alphabetical order.
authorTom Lane <tgl@sss.pgh.pa.us>
Wed, 1 Feb 2017 16:25:19 +0000 (11:25 -0500)
committerTom Lane <tgl@sss.pgh.pa.us>
Wed, 1 Feb 2017 16:25:19 +0000 (11:25 -0500)
commitc3e3844a92fe42109e4106314f7d229f784a7d0a
treeb17c8238e03d45da6cee4d313b8754f3932664ce
parent86322dc7e013b4062393dcbb74043db003e23ec5
Make psql's \set display variables in alphabetical order.

"\set" with no arguments displays all defined variables, but it does so
in the order that they appear in variables.c's list, which previously
was mostly creation order.  That makes the list ugly and hard to find
things in, and it exposes some psql implementation details to users.
(For instance, ordinary variables will move to the bottom of the list
if unset and set again, but variables that have hooks won't.)

Fix that by keeping the list in alphabetical order at all times, which
isn't much more complicated than breaking out of the insertion search
loops once we reach an entry that should be after the one to be inserted.

Discussion: https://postgr.es/m/31785.1485900786@sss.pgh.pa.us
src/bin/psql/variables.c