Consider the following statements:
CREATE TABLE t0(c0 INT);
CREATE TABLE t1(c0 BOOL, c1 SERIAL2 CHECK (FALSE), FOREIGN KEY (c1) REFERENCES t0(rowid));
UPSERT INTO t1(c0) VALUES (false); -- internal error: cannot convert int to type bool
Unexpectedly, the UPSERT results in an internal error with the following stack trace:
ERROR: internal error: cannot convert int to type bool
SQLSTATE: XX000
DETAIL: stack trace:
github.com/cockroachdb/cockroach/pkg/sql/sem/tree/datum.go:369: GetBool()
github.com/cockroachdb/cockroach/pkg/sql/check.go:352: checkMutationInput()
github.com/cockroachdb/cockroach/pkg/sql/upsert.go:161: processSourceRow()
github.com/cockroachdb/cockroach/pkg/sql/upsert.go:104: BatchedNext()
github.com/cockroachdb/cockroach/pkg/sql/plan_batch.go:159: startExec()
github.com/cockroachdb/cockroach/pkg/sql/plan.go:398: func2()
github.com/cockroachdb/cockroach/pkg/sql/walk.go:143: func1()
github.com/cockroachdb/cockroach/pkg/sql/walk.go:720: visitInternal()
github.com/cockroachdb/cockroach/pkg/sql/walk.go:110: visit()
github.com/cockroachdb/cockroach/pkg/sql/walk.go:74: walkPlan()
github.com/cockroachdb/cockroach/pkg/sql/plan.go:401: startExec()
github.com/cockroachdb/cockroach/pkg/sql/plan_node_to_row_source.go:117: Start()
github.com/cockroachdb/cockroach/pkg/sql/execinfra/processorsbase.go:748: Run()
github.com/cockroachdb/cockroach/pkg/sql/flowinfra/flow.go:370: Run()
github.com/cockroachdb/cockroach/pkg/sql/distsql_running.go:405: Run()
github.com/cockroachdb/cockroach/pkg/sql/distsql_running.go:1019: PlanAndRun()
github.com/cockroachdb/cockroach/pkg/sql/conn_executor_exec.go:874: execWithDistSQLEngine()
github.com/cockroachdb/cockroach/pkg/sql/conn_executor_exec.go:767: dispatchToExecutionEngine()
github.com/cockroachdb/cockroach/pkg/sql/conn_executor_exec.go:472: execStmtInOpenState()
github.com/cockroachdb/cockroach/pkg/sql/conn_executor_exec.go:95: execStmt()
github.com/cockroachdb/cockroach/pkg/sql/conn_executor.go:1394: execCmd()
github.com/cockroachdb/cockroach/pkg/sql/conn_executor.go:1323: run()
github.com/cockroachdb/cockroach/pkg/sql/conn_executor.go:478: ServeConn()
github.com/cockroachdb/cockroach/pkg/sql/pgwire/conn.go:594: func1()
runtime/asm_amd64.s:1357: goexit()
I found this issue based on commit 322f83364bc0807c3147af0631cb7317c584ce43.
@mrigger commit 322f83364bc0807c3147af0631cb7317c584ce43 is not in the master history. Can you report the result of cockroach version? Thanks
cc @asubiotto @jordanlewis for triage.
If am not mistaken, it should be the latest commit on master, and was also linked by GitHub. Here is the output of cockroach version:
Build Tag: v20.1.0-beta.2-988-g322f83364b
Build Time: 2020/03/21 09:45:52
Distribution: CCL
Platform: linux amd64 (x86_64-linux-gnu)
Go Version: go1.13.4
C Compiler: gcc 8.3.0
Build SHA-1: 322f83364bc0807c3147af0631cb7317c584ce43
Build Type: development
thanks my repo wasn't up to date.
This doesn't fail with optimizer_foreign_keys=false, so reassigning to @RaduBerinde.
Very nice find, thank you @mrigger!