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: support views that depend on virtual views #39195

Merged
merged 1 commit into from
Aug 1, 2019

Conversation

RaduBerinde
Copy link
Member

@RaduBerinde RaduBerinde commented Jul 31, 2019

When creating a view, we report a plan dependency on virtual
views which causes a failure. This commit fixes the logic to avoid
reporting a dependency in this case (just like we don't report
dependencies on virtual tables).

Fixes #38440.

Release note (bug fix): crdb_internal.ranges can now be used inside
views. Note that such views can become invalid in future releases if
crdb_internal.ranges changes.

@cockroach-teamcity
Copy link
Member

This change is Reviewable

@RaduBerinde RaduBerinde requested a review from knz August 1, 2019 12:33
Copy link
Contributor

@knz knz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM but you're weakening a guarantee that we were previolusly providing: when the column of a dependency gets renamed, prior to this we guaranteed that dependent views would not break (either by blocking the rename, or disallowing the dependency outright). With your change the vtable/vview can rename its column and any dependent view will not notice.

In any case I'd recommend spelling this out in the release not.

Reviewed 2 of 2 files at r1.
Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @jordanlewis)

Copy link
Member Author

@RaduBerinde RaduBerinde left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand, it's not possible to rename a column of a virtual table or view, is it? Or are you saying if we make a change between versions? (I don't see how we could fix that, because we can't allow the dependent view to block the upgrade)

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @jordanlewis)

@knz
Copy link
Contributor

knz commented Aug 1, 2019

are you saying if we make a change between versions?

yes

I don't see how we could fix that, because we can't allow the dependent view to block the upgrade

The proper way is to make the view depend on other things structurally, using table/column IDs and not names.

Copy link
Member Author

@RaduBerinde RaduBerinde left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see. Note though that this is already the case for vtables. This change only concerns the one virtual view we have (crdb_internal.ranges).

The proper way is to make the view depend on other things structurally, using table/column IDs and not names.

But for that to work, we'd still need to keep old column IDs in the vtable/vview valid and populated on all subsequent versions no?

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @jordanlewis)

@knz
Copy link
Contributor

knz commented Aug 1, 2019

But for that to work, we'd still need to keep old column IDs in the vtable/vview valid and populated on all subsequent versions no?

My previous comments only pertain to renames -- I was assuming that the columns would remain across versions.

For column deletions, I have no good story to tell.

When creating a view, we report a plan dependency on virtual
views which causes a failure. This commit fixes the logic to avoid
reporting a dependency in this case (just like we don't report
dependencies on virtual tables).

Fixes cockroachdb#38440.

Release note (bug fix): crdb_internal.ranges can now be used inside
views. Note that such views can become invalid in future releases if
`crdb_internal.ranges` changes.
@RaduBerinde
Copy link
Member Author

Got it. Updated the release note. TFTR!

bors r+

craig bot pushed a commit that referenced this pull request Aug 1, 2019
39195: sql: support views that depend on virtual views r=RaduBerinde a=RaduBerinde

When creating a view, we report a plan dependency on virtual
views which causes a failure. This commit fixes the logic to avoid
reporting a dependency in this case (just like we don't report
dependencies on virtual tables).

Fixes #38440.

Release note (bug fix): crdb_internal.ranges can now be used inside
views. Note that such views can become invalid in future releases if
`crdb_internal.ranges` changes.


Co-authored-by: Radu Berinde <radu@cockroachlabs.com>
@craig
Copy link
Contributor

craig bot commented Aug 1, 2019

Build succeeded

@craig craig bot merged commit 39253e4 into cockroachdb:master Aug 1, 2019
@RaduBerinde RaduBerinde deleted the virtual-view-dep branch August 3, 2019 14:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants