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: PREPARE q AS DROP TYPE typ causes an internal error #61226

Closed
rafiss opened this issue Feb 27, 2021 · 0 comments · Fixed by #61394
Closed

sql: PREPARE q AS DROP TYPE typ causes an internal error #61226

rafiss opened this issue Feb 27, 2021 · 0 comments · Fixed by #61394
Labels
C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior. S-3 Medium-low impact: incurs increased costs for some users (incl lower avail, recoverable bad data)

Comments

@rafiss
Copy link
Collaborator

rafiss commented Feb 27, 2021

This is affecting master right now, and is causing Random Syntax Tests to fail: https://teamcity.cockroachdb.com/viewLog.html?buildId=2725105&buildTypeId=Cockroach_Nightlies_RandomSyntaxTests

It seems like the issue is that planner.Annotations() is nil when calling connExecutor.addPreparedStmt().

Repro:

root@:26257/defaultdb> create type type_a as enum ('a');
CREATE TYPE

Time: 311ms total (execution 311ms / network 0ms)

root@:26257/defaultdb>
root@:26257/defaultdb> prepare q as drop type type_a;
ERROR: internal error: no Annotations provided
SQLSTATE: XX000
DETAIL: stack trace:
github.com/cockroachdb/cockroach/pkg/sql/sem/tree/format.go:247: NewFmtCtxEx()
github.com/cockroachdb/cockroach/pkg/sql/sem/tree/format.go:412: AsStringWithFQNames()
github.com/cockroachdb/cockroach/pkg/sql/drop_type.go:112: DropType()
github.com/cockroachdb/cockroach/pkg/sql/opaque.go:148: planOpaque()
github.com/cockroachdb/cockroach/pkg/sql/opaque.go:61: buildOpaque()
github.com/cockroachdb/cockroach/pkg/sql/opt/optbuilder/opaque.go:69: tryBuildOpaque()
github.com/cockroachdb/cockroach/pkg/sql/opt/optbuilder/builder.go:348: buildStmt()
github.com/cockroachdb/cockroach/pkg/sql/opt/optbuilder/builder.go:229: buildStmtAtRoot()
github.com/cockroachdb/cockroach/pkg/sql/opt/optbuilder/builder.go:200: Build()
github.com/cockroachdb/cockroach/pkg/sql/plan_opt.go:380: buildReusableMemo()
github.com/cockroachdb/cockroach/pkg/sql/plan_opt.go:123: prepareUsingOptimizer()
github.com/cockroachdb/cockroach/pkg/sql/conn_executor_prepare.go:265: populatePrepared()
github.com/cockroachdb/cockroach/pkg/sql/conn_executor_prepare.go:207: func1()
github.com/cockroachdb/cockroach/pkg/sql/conn_executor_prepare.go:213: prepare()
github.com/cockroachdb/cockroach/pkg/sql/conn_executor_prepare.go:132: addPreparedStmt()
github.com/cockroachdb/cockroach/pkg/sql/conn_executor_exec.go:511: execStmtInOpenState()
github.com/cockroachdb/cockroach/pkg/sql/conn_executor_exec.go:120: execStmt()
github.com/cockroachdb/cockroach/pkg/sql/conn_executor.go:1502: func1()
github.com/cockroachdb/cockroach/pkg/sql/conn_executor.go:1504: execCmd()
github.com/cockroachdb/cockroach/pkg/sql/conn_executor.go:1429: run()
github.com/cockroachdb/cockroach/pkg/sql/conn_executor.go:483: ServeConn()
github.com/cockroachdb/cockroach/pkg/sql/pgwire/conn.go:625: func1()
runtime/asm_amd64.s:1374: goexit()

HINT: You have encountered an unexpected error.
@rafiss rafiss added C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior. S-3 Medium-low impact: incurs increased costs for some users (incl lower avail, recoverable bad data) labels Feb 27, 2021
tharun208 added a commit to tharun208/cockroach that referenced this issue Mar 3, 2021
Release justification: fixes for high-priority or high-severity bugs in existing functionality

Previously, prepare statement doesnt have support for drop type
in optimizer, so it panic during execution as no flags are generated.

This patch fixes this by adding dropType to the optimizer.

Resolves cockroachdb#61226

Release note: none

Signed-off-by: Tharun <[email protected]>
tharun208 added a commit to tharun208/cockroach that referenced this issue Mar 3, 2021
Release justification: fixes for high-priority or high-severity bugs in existing functionality

Previously, prepare statement doesnt have support for drop type
in optimizer, so it panic during execution as no flags are generated.

This patch fixes this by adding dropType to the optimizer.

Resolves cockroachdb#61226

Release note: none

Signed-off-by: Tharun <[email protected]>
tharun208 added a commit to tharun208/cockroach that referenced this issue Mar 3, 2021
Release justification: fixes for high-priority or high-severity bugs in existing functionality

Previously, prepare statement doesnt have support for drop type
in optimizer, so it panic during execution as no flags are generated.

This patch fixes this by adding dropType to the optimizer.

Resolves cockroachdb#61226

Release note: none

Signed-off-by: Tharun <[email protected]>
tharun208 added a commit to tharun208/cockroach that referenced this issue Mar 4, 2021
Release justification: fixes for high-priority or high-severity bugs in existing functionality

Previously, prepare statement doesnt have support for drop type
in optimizer, so it panic during execution as no flags are generated.

This patch fixes this by adding dropType to the optimizer.

Resolves cockroachdb#61226

Release note: none

Signed-off-by: Tharun <[email protected]>
craig bot pushed a commit that referenced this issue Mar 4, 2021
61394: sql: add drop type to the prepared statement generator r=rafiss a=tharun208

Release justification: fixes for high-priority or high-severity bugs in existing functionality

Previously, prepare statement doesn't have support for drop type
in the optimizer, so it panics during execution as no flags are generated.

This patch fixes this by adding `dropType` to the optimizer.

Resolves #61226

Release note: none

Signed-off-by: Tharun <[email protected]>

<img width="454" alt="Screen Shot 2021-03-03 at 2 39 29 PM" src="https://user-images.githubusercontent.com/14926492/109781995-6c2a8d80-7c2e-11eb-902e-e596aa4f2bb3.png">


61437: sql: block interleaved tables with REGIONAL BY ROW r=ajstorm a=otan

Release justification: Low-risk change to new functionality.

Release note: None

61449: sql: fix UNIQUE column definition for REGIONAL BY ROW r=rytaft a=otan

This was buggy as the implicitly added crdb_region column was not
initialized before the UNIQUE definition was available. Instead, defer
these index creations until after all column definitions have been
initialized.

Release justification: low-risk bug fix to new functionality

Release note: None

Co-authored-by: Tharun <[email protected]>
Co-authored-by: Oliver Tan <[email protected]>
@craig craig bot closed this as completed in 556ea20 Mar 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior. S-3 Medium-low impact: incurs increased costs for some users (incl lower avail, recoverable bad data)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant