Re: Tab completion for CREATE SCHEMAAUTHORIZATION

From: ilmari(at)ilmari(dot)org (Dagfinn Ilmari Mannsåker )
To: Suraj Khamkar <khamkarsuraj(dot)b(at)gmail(dot)com>
Cc: pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: Tab completion for CREATE SCHEMAAUTHORIZATION
Date: 2021-08-09 18:00:02
Message-ID: 87im0efqhp.fsf@wibble.ilmari.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

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

Attachment Content-Type Size
v3-0001-Tab-complete-CURRENT_ROLE-CURRENT_USER-and-SESSIO.patch text/x-diff 4.3 KB
v3-0002-Add-more-tab-completion-for-CREATE-SCHEMA.patch text/x-diff 1.7 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Andres Freund 2021-08-09 18:04:07 Re: Worth using personality(ADDR_NO_RANDOMIZE) for EXEC_BACKEND on linux?
Previous Message Tom Lane 2021-08-09 17:54:25 Re: Worth using personality(ADDR_NO_RANDOMIZE) for EXEC_BACKEND on linux?