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: properly support CTEs inside views #31007

Merged
merged 2 commits into from Oct 11, 2018

Conversation

3 participants
@knz
Member

knz commented Oct 5, 2018

Fixes #23833.

@knz knz requested review from jordanlewis and BramGruneir Oct 5, 2018

@knz knz added this to Triage in SQL Front-end, Lang & Semantics via automation Oct 5, 2018

@knz knz requested review from cockroachdb/sql-execution-prs as code owners Oct 5, 2018

@cockroach-teamcity

This comment has been minimized.

Show comment
Hide comment
@cockroach-teamcity

cockroach-teamcity Oct 5, 2018

Member

This change is Reviewable

Member

cockroach-teamcity commented Oct 5, 2018

This change is Reviewable

@jordanlewis

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained


pkg/sql/logictest/testdata/logic_test/dependencies, line 140 at r4 (raw file):

----
descriptor_id  descriptor_name    index_id  dependedonby_id  dependedonby_type  dependedonby_index_id  dependedonby_name  dependedonby_details
63             blog_posts_id_seq  NULL      64               sequence           0                      NULL               Columns: [0]

I don't understand these test changes. Why are the descriptor ids changing?


pkg/sql/logictest/testdata/logic_test/pg_catalog, line 284 at r4 (raw file):

4084598993  primary       393119649     0        NULL      NULL   0            0
4084598994  t3_a_b_idx    393119649     0        NULL      NULL   0            0
4252432642  v1            393119649     0        NULL      NULL   0            0

likewise, what caused these changes?

@knz

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained


pkg/sql/logictest/testdata/logic_test/dependencies, line 140 at r4 (raw file):

Previously, jordanlewis (Jordan Lewis) wrote…

I don't understand these test changes. Why are the descriptor ids changing?

The previous code was performing name resolution of the table names on the AST during the semantic analysis, thereby acquiring a lease. This caused the subsequent transaction that was creating the view and update the leased table desc to abort with a retry error. However since the ID generation is not transactional, we'd "lose" a desc ID this way.

The new code skips this name resolution with lease (the name resolution is performed using uncached/unleased table descs instead) and so the retry error does not occur, so the first generated ID can be used.


pkg/sql/logictest/testdata/logic_test/pg_catalog, line 284 at r4 (raw file):

Previously, jordanlewis (Jordan Lewis) wrote…

likewise, what caused these changes?

ditto

knz added some commits Oct 5, 2018

sql: properly support CTEs inside views
Release note (sql change): CockroachDB now supports CTEs inside views.
@knz

This comment has been minimized.

Show comment
Hide comment
@knz

knz Oct 7, 2018

Member

rebased, RFAL

Member

knz commented Oct 7, 2018

rebased, RFAL

@knz knz moved this from Triage to Current milestone in SQL Front-end, Lang & Semantics Oct 8, 2018

@knz

This comment has been minimized.

Show comment
Hide comment
@knz

knz Oct 11, 2018

Member

ping?

Member

knz commented Oct 11, 2018

ping?

@knz

This comment has been minimized.

Show comment
Hide comment
@knz

knz Oct 11, 2018

Member

(just a rubber stamp since the same commits were approved in #31051)

Member

knz commented Oct 11, 2018

(just a rubber stamp since the same commits were approved in #31051)

@jordanlewis

Oops, I didn't realize that I hadn't reviewed this before letting the backport go in... this all looks good to me but I wonder if @vivekmenezes should take a look with regards to the simpler lease stuff, which I don't quite understand.

@knz

This comment has been minimized.

Show comment
Hide comment
@knz

knz Oct 11, 2018

Member

I think it's fair that Vivek and I look into this together again, because in truth I do not understand all of it myself.

However since this commit went into 2.1 already I will merge the PR as-is. If there are additional fixes needed I'll make a new PR.

Thanks

bors r+

Member

knz commented Oct 11, 2018

I think it's fair that Vivek and I look into this together again, because in truth I do not understand all of it myself.

However since this commit went into 2.1 already I will merge the PR as-is. If there are additional fixes needed I'll make a new PR.

Thanks

bors r+

craig bot pushed a commit that referenced this pull request Oct 11, 2018

Merge #31007 #31222
31007: sql: properly support CTEs inside views r=knz a=knz

Fixes #23833.


31222: sql: assorted mutation fixes r=knz a=knz

Fixes #25742.
Fixes #26106.
Fixes #29494.
Fixes #31255.
Fixes #29497.

~This may even full address #26106 but I have a couple more checks to add first to confirm this.~ edit: it does



Co-authored-by: Raphael 'kena' Poss <knz@cockroachlabs.com>
@jordanlewis

This comment has been minimized.

Show comment
Hide comment
@jordanlewis

jordanlewis Oct 11, 2018

Member

Sounds good

Member

jordanlewis commented Oct 11, 2018

Sounds good

@craig

This comment has been minimized.

Show comment
Hide comment
@craig

craig bot commented Oct 11, 2018

Build succeeded

@craig craig bot merged commit 0221624 into cockroachdb:master Oct 11, 2018

3 checks passed

GitHub CI (Cockroach) TeamCity build finished
Details
bors Build succeeded
Details
license/cla Contributor License Agreement is signed.
Details

@knz knz deleted the knz:20181005-cte-in-view branch Oct 11, 2018

@knz knz moved this from Current milestone to Finished (milestone r2.1) in SQL Front-end, Lang & Semantics Oct 11, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment