Re: Tab completion for CREATE SCHEMAAUTHORIZATION

From: Suraj Khamkar <khamkarsuraj(dot)b(at)gmail(dot)com>
To: Dagfinn Ilmari Mannsåker <ilmari(at)ilmari(dot)org>
Cc: pgsql-hackers(at)lists(dot)postgresql(dot)org, michael(at)paquier(dot)xyz
Subject: Re: Tab completion for CREATE SCHEMAAUTHORIZATION
Date: 2021-08-11 17:34:10
Message-ID: CA+U=F9i3wayOrRK5__dAKipfNSsO53HbC0uE=NA1kOkj3S3mRQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Thanks Dagfinn for the updated patches.

I do not get these errors, neither with the patch file I still have
> locally, or by saving the attachment from my original email. Are you
> sure something in your download process hasn't converted it to Windows
> line endings (\r\n), or otherwise mangled the whitespace?

No. I have downloaded patch on linux and patch also doesn't have any
trailing
spaces, though it is throwing an error.

Here are few other comments,

1. USER MAPPING does not have SESSION_USER as username in syntax
(though it works) but your changes provide the same. Also, we have USER
in
list which is missing in current code changes.
CREATE USER MAPPING [ IF NOT EXISTS ] FOR { user_name | USER |
CURRENT_ROLE | CURRENT_USER | PUBLIC }
SERVER server_name
[ OPTIONS ( option 'value' [ , ... ] ) ]
2. It might not be a scope of this ticket but as we are changing the
query for ALTER GROUP,
we should complete the role_specification after ALTER GROUP.
postgres(at)17077=#ALTER GROUP
pg_database_owner pg_monitor
pg_read_all_settings
pg_read_server_files pg_stat_scan_tables
pg_write_server_files
surajkhamkar. pg_execute_server_program pg_read_all_data

pg_read_all_stats pg_signal_backend pg_write_all_data

3. Missing schema_elements after CREATE SCHEMA AUTHORIZATION username to
tab-complete .
schema_elements might be CREATE, GRAND etc.

Thanks..

On Mon, Aug 9, 2021 at 11:30 PM Dagfinn Ilmari Mannsåker <ilmari(at)ilmari(dot)org>
wrote:

> Hi Suraj,
>
> Suraj Khamkar <khamkarsuraj(dot)b(at)gmail(dot)com> writes:
>
> > Hello Dagfinn,
> >
> > I had a look at your patch and below are my review comments.
> > Please correct me if I am missing something.
> >
> > 1. For me the patch does not apply cleanly. I have been facing the
> error
> > of trailing whitespaces.
>
> I do not get these errors, neither with the patch file I still have
> locally, or by saving the attachment from my original email. Are you
> sure something in your download process hasn't converted it to Windows
> line endings (\r\n), or otherwise mangled the whitespace?
>
> > 2. We can remove space in before \ and below change
> > +" UNION ALL SELECT 'PUBLIC'" \
> >
> > Should be,
> > +" UNION ALL SELECT 'PUBLIC' "\
>
> The patch doesn't add any lines that end with quote-space-backslash.
> As for the space before the quote, that is not necessary either, since the
> next line starts with a space after the quote. Either way, the updated
> version of the patch doesn't add any new lines with continuation after a
> string constant, so the point is moot.
>
> > 3. role_specification has CURRENT_ROLE, CURRENT_USER and SESSION_USER.
> > But current changes are missing CURRENT_ROLE.
>
> Ah, I was looking at the documentation for 13, but CURRENT_ROLE is only
> allowed in this context as of 14. Fixed.
>
> > 4. I'm not sure about this but do we need to enable tab completion
> for IF
> > NOT EXIST?
> >
> > 5. I think we are not handling IF NOT EXIST that's why it's not
> > completing tab completion
> > for AUTHORIZATION.
>
> As you note, psql currently doesn't currently tab-complete IF NOT EXISTS
> for any command, so that would be a subject for a separate patch.
>
> > 6. As we are here we can also enable missing tab completion for ALTER
> > SCHEMA.
> > After OWNER TO we should also get CURRENT_ROLE, CURRENT_USER and
> > SESSION_USER.
>
> I did an audit of all the uses of Query_for_list_of_roles, and there
> turned out be several more that accept CURRENT_ROLE, CURRENT_USER and
> SESSION_USER that they weren't tab-completed for. I also renamed the
> constant to Query_for_list_of_owner_roles, but I'm not 100% happy with
> that name either.
>
> > 7. Similarly, as we can drop multiple schemas' simultaneously, we
> should
> > enable tab completion for
> > comma with CASCADE and RESTRICT
> > postgres(at)53724=#DROP SCHEMA sch
> > CASCADE RESTRICT
>
> The tab completion code for DROP is generic for all object types (see
> the words_after_create array and the create_or_drop_command_generator
> function), so that should be done genericallly, and is thus outside the
> scope for this patch.
>
> > Thanks.
>
> Thanks for the review. Updated patch attached, with the CURRENT/SESSION
> ROLE/USER changes for other commands separated out.
>
> - ilmari
>
>

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Geoghegan 2021-08-11 17:35:16 Re: 2021-08-12 release announcement draft
Previous Message John Naylor 2021-08-11 17:11:22 call popcount32/64 directly on non-x86 platforms