Re: ON SELECT rule on a table without columns

From: Andres Freund <andres(at)anarazel(dot)de>
To: Ashutosh Sharma <ashu(dot)coek88(at)gmail(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Rushabh Lathia <rushabh(dot)lathia(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: ON SELECT rule on a table without columns
Date: 2019-02-11 10:21:56
Message-ID: 20190211102156.s2hoadjket7pks3n@alap3.anarazel.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

On 2019-02-11 15:39:03 +0530, Ashutosh Sharma wrote:
> Andres, Tom, Please have a look into the attached patch and let me
> know if I'm still missing something. Thank you.

> --- a/src/test/regress/expected/create_view.out
> +++ b/src/test/regress/expected/create_view.out
> @@ -1706,9 +1706,16 @@ select pg_get_ruledef(oid, true) from pg_rewrite
> 43 AS col_b;
> (1 row)
>
> +-- create view on a table without columns
> +create table t0();
> +create view v0 as select * from t0;
> +select * from v0;
> +--
> +(0 rows)

I suggest also adding a view that select zero columns, where the
unerlying table has columns.

I think it'd be good to name the view in a way that's a bit more unique,
and leaving it in place. That way pg_dump can be tested with this too
(and mostly would be tested via pg_upgrade's tests).

> -- clean up all the random objects we made above
> \set VERBOSITY terse \\ -- suppress cascade details
> DROP SCHEMA temp_view_test CASCADE;
> NOTICE: drop cascades to 27 other objects
> DROP SCHEMA testviewschm2 CASCADE;
> -NOTICE: drop cascades to 62 other objects
> +NOTICE: drop cascades to 64 other objects
> diff --git a/src/test/regress/expected/matview.out b/src/test/regress/expected/matview.out
> index d0121a7..f1d24e6 100644
> --- a/src/test/regress/expected/matview.out
> +++ b/src/test/regress/expected/matview.out
> @@ -589,3 +589,12 @@ SELECT * FROM mvtest2;
> ERROR: materialized view "mvtest2" has not been populated
> HINT: Use the REFRESH MATERIALIZED VIEW command.
> ROLLBACK;
> +-- create materialized view on a table without columns
> +create table mt0();
> +create materialized view mv0 as select * from mt0;
> +select * from mv0;
> +--
> +(0 rows)

Same.

Thanks!

Greetings,

Andres Freund

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Michael Paquier 2019-02-11 10:55:00 Re: pgsql: Restrict the use of temporary namespace in two-phase transaction
Previous Message Ashutosh Sharma 2019-02-11 10:09:03 Re: ON SELECT rule on a table without columns