AW: AW: Why is materialized view creation a "security-restricted operation"?

From: Färber, Franz-Josef (StMUK) <Franz-Josef(dot)Faerber(at)stmuk(dot)bayern(dot)de>
To: Laurenz Albe <laurenz(dot)albe(at)cybertec(dot)at>, Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com>, "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Cc: "Haupt, Matthias (StMUK)" <Matthias(dot)Haupt(at)stmuk(dot)bayern(dot)de>
Subject: AW: AW: Why is materialized view creation a "security-restricted operation"?
Date: 2026-10-13 14:17:25
Message-ID: 3b50a3393fd84d56b40cfddd67c98dbc@stmuk.bayern.de
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-general

>Well, you want to use a materialized view for something that it cannot be used for, for security reasons. We tried to explain that in this thread.
Yes, you can see it this way: One way would be: Using Temp Tables. This way is blocked due to security reasons. Discussion finished.

Another point of view is:
0) The security problem is not inherent for what I was trying to archieve; but due to lack of expressiveness one is forced into this dead end.
1) Either: Postgres' COPY stmt lacks the ability to omit the physical table, something like SELECT * FROM COPY FROM ...
2) or: Postgres lacks table variables.

> Just because the features you are stacking don't work the way you'd like them to, it's not a shortcoming of orthogonality or modularity.
Well this is my very definition of orthogonality / modularity, This is what I'm out for: Language features should be generally combinable, with very few limits.

> You could write a procedure that truncates the table and populates it with a query, using a temporary table if you want. Calling that procedure is just as convenient as calling REFRESH MATERIALIZED VIEW.
Yes, that's what I meant in my last post.
But this leads to: I need to adjust all callings points, notify users of the previously-MATVIEW to adjust, and so on.

> Are you searching for a usable solution for a problem? Then that should do.
I am searching for both
* A solution that does not feel like a workaround. (Well I WILL be able to live with the function solution. Somehow.)
* Some common ground that there is some lack of modularity / orthogonality / expressiveness in Postgres. Addressing the problem is the first step.

Thank You.

Regards,
Franz-Josef Färber

-----Ursprüngliche Nachricht-----
Von: Laurenz Albe <laurenz(dot)albe(at)cybertec(dot)at>
Gesendet: Dienstag, 13. Oktober 2026 15:48
An: Färber, Franz-Josef (StMUK) <Franz-Josef(dot)Faerber(at)stmuk(dot)bayern(dot)de>; Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com>; pgsql-general(at)postgresql(dot)org
Cc: Haupt, Matthias (StMUK) <Matthias(dot)Haupt(at)stmuk(dot)bayern(dot)de>
Betreff: Re: AW: Why is materialized view creation a "security-restricted operation"?

On Tue, 2026-10-13 at 11:36 +0000, Färber, Franz-Josef (StMUK) wrote:
> > > [rant about PostgreSQL security restrictions]
>
> No no no, not about security restrictions. The rant is about lacking orthogonality.
> About often NOT being able to combine language features. Doesn't
> anybody share that view? We COULD do better, I think.

Well, you want to use a materialized view for something that it cannot be used for, for security reasons. We tried to explain that in this thread.

> > If the security restrictions of materialized views prevent you from
> > using them, why don't you use a normal table instead, TRUNCATE it and INSERT into it?
>
> The MAT VIEW is used from "outside". From other views, or from a client that connects to the database.
>
> * I can replace it with a view; I didn't do that for performance reasons.
> * I can replace it with a persistent table, a stored procedure, and custom caching
> logic. That'll work. But this is what a MAT VIEW is for, I thought.

You could write a procedure that truncates the table and populates it with a query, using a temporary table if you want. Calling that procedure is just as convenient as calling REFRESH MATERIALIZED VIEW.

Are you searching for a usable solution for a problem? Then that should do.

Yours,
Laurenz Albe

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Rob Sargent 2026-10-13 15:36:47 Re: Why is materialized view creation a "security-restricted operation"?
Previous Message Laurenz Albe 2026-10-13 13:47:40 Re: AW: Why is materialized view creation a "security-restricted operation"?