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

release-2.1: assorted CTE fixes #31051

Merged
merged 6 commits into from Oct 11, 2018

Conversation

Projects
None yet
5 participants
@knz
Member

knz commented Oct 7, 2018

Backport:

  • 1/1 commits from "opt: support single-use CTEs" (#30858)
  • 1/1 commits from "opt: remove some unimplementedfs" (#30939)
  • 1/1 commits from "sql: bark at unused CTEs containing mutations" (#31003)
  • 2/2 commits from "sql: do not silently ignore CTEs inside parentheses" (#31004)
  • 2/2 commits from "sql: properly support CTEs inside views" (#31007)

Please see individual PRs for details.

/cc @cockroachdb/release

justinj and others added some commits Oct 1, 2018

opt: support single-use CTEs
This commit introduces Cockroach-style single-use CTEs to the optimizer.
Such CTEs cannot be referenced more than once in a query.

Release note: None
opt: remove some unimplementedfs
These two checks are now exhaustive, meaning anything missing from them
going forward is an error.

Release note: None
sql: bark at unused CTEs containing mutations
The SQL standard (and pg) specifies that CTEs containing mutations are
executed no matter how / how many times they are used in the remainder
of the query.

Meanwhile the heuristic planner + execution machinery is currently
unable to force the execution of CTEs containing mutations if they are
not otherwise used in the rest of the query.

However meanwhile they are also accepted silently -- i.e. CockroachDB
silently fails to do what the semantics require.

This patch changes the behavior to instead report an error "feature
not supported".

Release note (bug fix): CockroachDB now reports an unimplemented error
when a common table expression containing INSERT/UPDATE/UPSERT/DELETE
is not otherwise used in the remainder of the query.
sql: do not silently ignore CTEs inside parentheses
Prior to this patch, CockroachDB silently ignored WITH clauses within
parentheses, so that the following SQL would return incorrect results:

```
CREATE TABLE t(x INT);
(WITH t AS (SELECT 1) TABLE t);
```

(note: `WITH ...` *without* parentheses did work fine)

This patch fixes this particular issue, and causes CockroachDB to
issue an "unimplemented error" in other cases not supported yet, for
example when there are multiple nested WITH clauses within
parentheses.

Release note (bug fix): CockroachDB does not silently ignore WITH
clauses within parentheses any more.
sql: properly support CTEs inside views
Release note (sql change): CockroachDB now supports CTEs inside views.

@knz knz requested review from jordanlewis and justinj Oct 7, 2018

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

@cockroach-teamcity

This comment has been minimized.

Show comment
Hide comment
@cockroach-teamcity

cockroach-teamcity Oct 7, 2018

Member

This change is Reviewable

Member

cockroach-teamcity commented Oct 7, 2018

This change is Reviewable

@rytaft

This comment has been minimized.

Show comment
Hide comment
@rytaft

rytaft Oct 7, 2018

Contributor

First 5 commits LGTM. I'll let someone review the last one who reviewed the original PR.

Contributor

rytaft commented Oct 7, 2018

First 5 commits LGTM. I'll let someone review the last one who reviewed the original PR.

@knz knz merged commit 0baee4f into cockroachdb:release-2.1 Oct 11, 2018

2 checks passed

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

@knz knz deleted the knz:backport2.1-30858-30939-31003-31004-31007 branch Oct 11, 2018

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