CREATE MATERIALIZED VIEW

Started by px shiover 1 year ago10 messageshackers
Jump to latest
#1px shi
spxlyy123@gmail.com

Hi, I see that materialized view cannot be unlogged now, but when I use
psql and type CREATE UNLOGGED, pressing the Tab key for auto-completion
suggests `TABLE` and MATERIALIZED VIEW.
Shouldn't `MATERIALIZED VIEW ` be suggested?

In reply to: px shi (#1)
Re: CREATE MATERIALIZED VIEW

px shi <spxlyy123@gmail.com> writes:

Hi, I see that materialized view cannot be unlogged now, but when I use
psql and type CREATE UNLOGGED, pressing the Tab key for auto-completion
suggests `TABLE` and MATERIALIZED VIEW.
Shouldn't `MATERIALIZED VIEW ` be suggested?

That's my fault, I added it in commit c951e9042dd1, presumably because
the grammar allows it, but it turns transformCreateTableAsStmt() rejects
it.

Attached is a patch to fix it, which sholud be backpatched to v17.

- ilmari

Attachments:

0001-Don-t-tab-complete-MATERIALIZED-VIEW-after-CREATE-UN.patchtext/x-diffDownload+2-9
In reply to: Dagfinn Ilmari Mannsåker (#2)
Re: CREATE MATERIALIZED VIEW

Dagfinn Ilmari Mannsåker <ilmari@ilmari.org> writes:

px shi <spxlyy123@gmail.com> writes:

Hi, I see that materialized view cannot be unlogged now, but when I use
psql and type CREATE UNLOGGED, pressing the Tab key for auto-completion
suggests `TABLE` and MATERIALIZED VIEW.
Shouldn't `MATERIALIZED VIEW ` be suggested?

That's my fault, I added it in commit c951e9042dd1, presumably because
the grammar allows it, but it turns transformCreateTableAsStmt() rejects
it.

Scratch that, I misread the diff. The tab completion has been there
since matviews were added in commit 3bf3ab8c5636, but the restriction on
unlogged matviews was added later in commit 3223b25ff73, which failed to
update the tab completion code to match.

Here's a updated patch with a corrected commit message.

- ilmari

Attachments:

v2-0001-Don-t-tab-complete-MATERIALIZED-VIEW-after-CREATE.patchtext/x-diffDownload+2-9
#4Nathan Bossart
nathandbossart@gmail.com
In reply to: Dagfinn Ilmari Mannsåker (#3)
Re: CREATE MATERIALIZED VIEW

On Thu, Jul 25, 2024 at 03:09:09PM +0100, Dagfinn Ilmari Manns�ker wrote:

Scratch that, I misread the diff. The tab completion has been there
since matviews were added in commit 3bf3ab8c5636, but the restriction on
unlogged matviews was added later in commit 3223b25ff73, which failed to
update the tab completion code to match.

As noted a few years ago [0]/messages/by-id/flat/ZR0P278MB092093E92263DE16734208A5D2C59@ZR0P278MB0920.CHEP278.PROD.OUTLOOK.COM, the commit message for 3223b25ff73 indicates
this was intentional:

I left the grammar and tab-completion support for CREATE UNLOGGED
MATERIALIZED VIEW in place, since it's harmless and allows delivering a
more specific error message about the unsupported feature.

However, since it looks like the feature was never actually supported in a
release, and the revert has been in place for over a decade, I think it'd
be reasonable to remove the tab completion now. It looks like the folks on
the 2021 thread felt similarly.

[0]: /messages/by-id/flat/ZR0P278MB092093E92263DE16734208A5D2C59@ZR0P278MB0920.CHEP278.PROD.OUTLOOK.COM

--
nathan

In reply to: Nathan Bossart (#4)
Re: CREATE MATERIALIZED VIEW

Nathan Bossart <nathandbossart@gmail.com> writes:

On Thu, Jul 25, 2024 at 03:09:09PM +0100, Dagfinn Ilmari Mannsåker wrote:

Scratch that, I misread the diff. The tab completion has been there
since matviews were added in commit 3bf3ab8c5636, but the restriction on
unlogged matviews was added later in commit 3223b25ff73, which failed to
update the tab completion code to match.

As noted a few years ago [0], the commit message for 3223b25ff73 indicates
this was intentional:

I left the grammar and tab-completion support for CREATE UNLOGGED
MATERIALIZED VIEW in place, since it's harmless and allows delivering a
more specific error message about the unsupported feature.

D'oh, I'm clearly struggling with reading things properly today.

However, since it looks like the feature was never actually supported in a
release, and the revert has been in place for over a decade, I think it'd
be reasonable to remove the tab completion now. It looks like the folks on
the 2021 thread felt similarly.

Keeping it in the grammar makes sense for the more specific error
message, but I don't think the tab completion should be suggesting bogus
things, regardless of whether it's the grammar or the parse analysis
that rejects it.

[0] /messages/by-id/flat/ZR0P278MB092093E92263DE16734208A5D2C59@ZR0P278MB0920.CHEP278.PROD.OUTLOOK.COM

- ilmari

#6Nathan Bossart
nathandbossart@gmail.com
In reply to: Dagfinn Ilmari Mannsåker (#5)
Re: CREATE MATERIALIZED VIEW

On Thu, Jul 25, 2024 at 03:49:02PM +0100, Dagfinn Ilmari Manns�ker wrote:

Nathan Bossart <nathandbossart@gmail.com> writes:

However, since it looks like the feature was never actually supported in a
release, and the revert has been in place for over a decade, I think it'd
be reasonable to remove the tab completion now. It looks like the folks on
the 2021 thread felt similarly.

Keeping it in the grammar makes sense for the more specific error
message, but I don't think the tab completion should be suggesting bogus
things, regardless of whether it's the grammar or the parse analysis
that rejects it.

Would you mind creating a commitfest entry for this one? I'll plan on
committing this early next week unless any objections materialize.

--
nathan

In reply to: Nathan Bossart (#6)
Re: CREATE MATERIALIZED VIEW

Nathan Bossart <nathandbossart@gmail.com> writes:

On Thu, Jul 25, 2024 at 03:49:02PM +0100, Dagfinn Ilmari Mannsåker wrote:

Nathan Bossart <nathandbossart@gmail.com> writes:

However, since it looks like the feature was never actually supported in a
release, and the revert has been in place for over a decade, I think it'd
be reasonable to remove the tab completion now. It looks like the folks on
the 2021 thread felt similarly.

Keeping it in the grammar makes sense for the more specific error
message, but I don't think the tab completion should be suggesting bogus
things, regardless of whether it's the grammar or the parse analysis
that rejects it.

Would you mind creating a commitfest entry for this one? I'll plan on
committing this early next week unless any objections materialize.

Done: https://commitfest.postgresql.org/49/5139/

I've taken the liberty of setting you as the committer, and the target
version to 17 even though it turns out to be an older bug, since it's
arguably a follow-on fix to the incomplete fix in c951e9042dd1.

- ilmari

#8Nathan Bossart
nathandbossart@gmail.com
In reply to: Dagfinn Ilmari Mannsåker (#7)
Re: CREATE MATERIALIZED VIEW

On Thu, Jul 25, 2024 at 04:10:37PM +0100, Dagfinn Ilmari Manns�ker wrote:

Done: https://commitfest.postgresql.org/49/5139/

I've taken the liberty of setting you as the committer, and the target
version to 17 even though it turns out to be an older bug, since it's
arguably a follow-on fix to the incomplete fix in c951e9042dd1.

Thanks. I'm -1 on back-patching since it was intentionally left around and
is basically harmless.

--
nathan

#9Nathan Bossart
nathandbossart@gmail.com
In reply to: Nathan Bossart (#8)
Re: CREATE MATERIALIZED VIEW

Committed.

--
nathan

In reply to: Nathan Bossart (#9)
Re: CREATE MATERIALIZED VIEW

Nathan Bossart <nathandbossart@gmail.com> writes:

Committed.

Thanks!

- ilmari