postgresql/src/bin/psql
Stephen Frost 2022d594da Fix tab completion in psql for ALTER DEFAULT PRIVILEGES
When providing tab completion for ALTER DEFAULT PRIVILEGES, we are
including the list of roles as possible options for completion after the
GRANT or REVOKE.  Further, we accept FOR ROLE/IN SCHEMA at the same time
and in either order, but the tab completion was only working for one or
the other.  Lastly, we weren't using the actual list of allowed kinds of
objects for default privileges for completion after the 'GRANT X ON' but
instead were completeing to what 'GRANT X ON' supports, which isn't the
ssame at all.

Address these issues by improving the forward tab-completion for ALTER
DEFAULT PRIVILEGES and then constrain and correct how the tail
completion is done when it is for ALTER DEFAULT PRIVILEGES.

Back-patch the forward/tail tab-completion to 9.6, where we made it easy
to handle such cases.

For 9.5 and earlier, correct the initial tab-completion to at least be
correct as far as it goes and then add a check for GRANT/REVOKE to only
tab-complete when the GRANT/REVOKE is the start of the command, so we
don't try to do tab-completion after we get to the GRANT/REVOKE part of
the ALTER DEFAULT PRIVILEGES command, which is better than providing
incorrect completions.

Initial patch for master and 9.6 by Gilles Darold, though I cleaned it
up and added a few comments.  All bugs in the 9.5 and earlier patch are
mine.

Discussion: https://www.postgresql.org/message-id/1614593c-e356-5b27-6dba-66320a9bc68b@dalibo.com
2016-12-23 21:01:48 -05:00
..
po Translation updates 2016-10-24 10:55:55 -04:00
.gitignore Convert cvsignore to gitignore, and add .gitignore for build targets. 2010-09-22 12:57:04 +02:00
command.c Fix assorted places in psql to print version numbers >= 10 in new style. 2016-08-16 15:58:31 -04:00
command.h Update copyrights for 2013 2013-01-01 17:15:01 -05:00
common.c Fix assorted places in psql to print version numbers >= 10 in new style. 2016-08-16 15:58:31 -04:00
common.h psql: fix \connect with URIs and conninfo strings 2015-04-01 20:00:07 -03:00
copy.c Remove tabs after spaces in C comments 2014-05-06 11:26:28 -04:00
copy.h Update copyrights for 2013 2013-01-01 17:15:01 -05:00
create_help.pl pgindent run for release 9.3 2013-05-29 16:58:43 -04:00
describe.c Fix assorted places in psql to print version numbers >= 10 in new style. 2016-08-16 15:58:31 -04:00
describe.h psql: Let \l accept a pattern 2013-03-04 15:17:40 +00:00
help.c psql: fix \connect with URIs and conninfo strings 2015-04-01 20:00:07 -03:00
help.h Update copyrights for 2013 2013-01-01 17:15:01 -05:00
input.c Guard against empty buffer in gets_fromFile()'s check for a newline. 2016-07-28 18:57:48 -04:00
input.h Fix psql \s to work with recent libedit, and add pager support. 2014-09-08 16:09:52 -04:00
large_obj.c Remove tabs after spaces in C comments 2014-05-06 11:26:28 -04:00
large_obj.h Update copyrights for 2013 2013-01-01 17:15:01 -05:00
mainloop.c Remove tabs after spaces in C comments 2014-05-06 11:26:28 -04:00
mainloop.h Update copyrights for 2013 2013-01-01 17:15:01 -05:00
Makefile Fix client-only installation 2014-01-17 23:11:02 -05:00
mbprint.c Remove tabs after spaces in C comments 2014-05-06 11:26:28 -04:00
mbprint.h Fix indentation of \d footers for non-ASCII cases. 2012-03-07 19:25:59 -05:00
nls.mk Translation updates 2013-09-02 02:28:21 -04:00
print.c Restore psql's SIGPIPE setting if popen() fails. 2016-12-07 12:39:24 -05:00
print.h Add a latex-longtable output format to psql 2013-01-17 11:39:38 -05:00
prompt.c Update copyrights for 2013 2013-01-01 17:15:01 -05:00
prompt.h Update copyrights for 2013 2013-01-01 17:15:01 -05:00
psqlrc.sample Improve FILES section of psql reference page. 2014-01-14 19:28:06 -05:00
psqlscan.h Update copyrights for 2013 2013-01-01 17:15:01 -05:00
psqlscan.l Sort out paired double quotes in \connect, \password and \crosstabview. 2016-08-08 10:07:51 -04:00
settings.h Improve consistency of parsing of psql's magic variables. 2014-12-31 12:17:00 -05:00
startup.c Introduce a psql "\connect -reuse-previous=on|off" option. 2016-08-08 10:07:51 -04:00
stringutils.c Remove tabs after spaces in C comments 2014-05-06 11:26:28 -04:00
stringutils.h Add support for piping COPY to/from an external program. 2013-02-27 18:22:31 +02:00
tab-complete.c Fix tab completion in psql for ALTER DEFAULT PRIVILEGES 2016-12-23 21:01:48 -05:00
tab-complete.h Update copyrights for 2013 2013-01-01 17:15:01 -05:00
variables.c Improve consistency of parsing of psql's magic variables. 2014-12-31 12:17:00 -05:00
variables.h Improve consistency of parsing of psql's magic variables. 2014-12-31 12:17:00 -05:00