Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sql: infrastructure support for hidden columns in views #93642

Closed
wants to merge 1 commit into from

Conversation

knz
Copy link
Contributor

@knz knz commented Dec 14, 2022

In another commit, we plan to start introducing hidden columns in crdb_internal virtual views. This change is a prerequisite to that.

Release note: None
Informs #93617.

In another commit, we plan to start introducing hidden columns in
crdb_internal virtual views. This change is a prerequisite to that.

Release note: None
@knz knz requested a review from ajwerner December 14, 2022 21:43
@cockroach-teamcity
Copy link
Member

This change is Reviewable

@knz
Copy link
Contributor Author

knz commented Dec 14, 2022

@mgartner while trying this PR, I discovered the following behavior: SELECT * FROM myview includes hidden columns in the view.

If I use SELECT * FROM mytable (with a table instead of a view), the * does not include hidden columns.

It looks like star expansion for views ignores the Hidden attribute on the column descriptor. Do you know where I should look to fix that?

@knz
Copy link
Contributor Author

knz commented Dec 14, 2022

For an example of what I mean in that last comment check out the branch at #93644 and try select * from crdb_internal.ranges (which has been modified to contain hidden columns)

@mgartner
Copy link
Collaborator

As far as I can tell, this behavior is correct. The view is created with the columns explicitly listed, and the "hidden-ness" of a column does not propagate to the view. So while the columns are hidden in the table, they are not hidden in the view.

Postgres behaves the same:

marcus=# CREATE TABLE t (a INT);
CREATE TABLE

marcus=# CREATE VIEW v AS SELECT a, tableoid FROM t;
CREATE VIEW

marcus=# SELECT * FROM v;
 a | tableoid
---+----------
(0 rows)

@knz
Copy link
Contributor Author

knz commented Dec 17, 2022

ok that works. thanks for checking

@knz knz closed this Dec 17, 2022
@knz knz deleted the 20221214-hidden-vtable-col branch December 17, 2022 11:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants