pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Mitar <mmitar@gmail.com>
Cc: pgsql-general@lists.postgresql.org
Subject: Re: CREATE UNLOGGED MATERIALIZED VIEW
Date: Wed, 26 Dec 2018 11:35:05 -0500
Message-ID: <29165.1545842105@sss.pgh.pa.us> (raw)
In-Reply-To: <CAKLmikNZ6qquFkh_eF9kWm5daTJy0PXhNt-xHT+iniYfaKkgZg@mail.gmail.com>
References: <CAKLmikNZ6qquFkh_eF9kWm5daTJy0PXhNt-xHT+iniYfaKkgZg@mail.gmail.com>

Mitar <mmitar@gmail.com> writes:
> I am looking at parser grammar rules and it looks like the following
> is a valid query:
> CREATE UNLOGGED MATERIALIZED VIEW
> Any particular reason this is not documented?

Because it's not supported:

regression=# CREATE UNLOGGED MATERIALIZED VIEW foo AS select 1;
ERROR:  materialized views cannot be UNLOGGED

Tracing down the source of that error message, we find

        /*
         * For now, we disallow unlogged materialized views, because it seems
         * like a bad idea for them to just go to empty after a crash. (If we
         * could mark them as unpopulated, that would be better, but that
         * requires catalog changes which crash recovery can't presently
         * handle.)
         */
        if (stmt->into->rel->relpersistence == RELPERSISTENCE_UNLOGGED)
            ereport(ERROR,
                    (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
                     errmsg("materialized views cannot be UNLOGGED")));

So that's a value judgment you might or might not agree with (and even if
you don't, it's not clear whether there are any deeper implementation
problems that would be exposed if we just deleted this prohibition).
But there it is, and it's why the documentation doesn't mention such a
capability.

The reason the grammar allows the possibility is likely some combination
of (1) sharing grammar with other statements, (2) an error like the above
is a lot more user-friendly than "syntax error" if someone tries to use
the nonexistent feature, and (3) making provision for future enhancements.

			regards, tom lane




view thread (7+ messages)  latest in thread

Message-ID: <29165.1545842105@sss.pgh.pa.us>
Permalink:  ../29165.1545842105@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/29165.1545842105@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: tgl@sss.pgh.pa.us, mmitar@gmail.com
  Subject: Re: CREATE UNLOGGED MATERIALIZED VIEW
  In-Reply-To: <29165.1545842105@sss.pgh.pa.us>
  References: <CAKLmikNZ6qquFkh_eF9kWm5daTJy0PXhNt-xHT+iniYfaKkgZg@mail.gmail.com> <29165.1545842105@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox