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

ddl: panic when adding index for some generated columns #22121

Closed
bb7133 opened this issue Dec 31, 2020 · 1 comment · Fixed by #22154
Closed

ddl: panic when adding index for some generated columns #22121

bb7133 opened this issue Dec 31, 2020 · 1 comment · Fixed by #22154
Assignees
Labels
severity/major sig/sql-infra SIG: SQL Infra type/bug The issue is confirmed as a bug.

Comments

@bb7133
Copy link
Member

bb7133 commented Dec 31, 2020

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

create table employees1 (
    id int not null,
        becf_no varchar(30) not null,
    fname varchar(30),
    lname varchar(30),
    hired date not null default '1970-01-01',
    separated date not null default '9999-12-31',
    job_code int not null,
    store_id int not null,
    create_date timestamp not null default now(),
    date_day timestamp generated always as (date_format(create_date)),
    primary key (store_id,create_date),
    key test_1 (fname,create_date)
);
create index idx_employees1_11 on employees1(becf_no,create_date);

2. What did you expect to see? (Required)

The index is created succesfuuly.

3. What did you see instead (Required)

TiDB server panicked with the following stack:

[expression:1582]Incorrect parameter count in the call to native function 'date_format'
github.com/pingcap/errors.AddStack
	/home/bb7133/Projects/gopath/pkg/mod/github.com/pingcap/errors@v0.11.5-0.20201029093017-5a7df2af2ac7/errors.go:174
github.com/pingcap/errors.(*Error).GenWithStackByArgs
	/home/bb7133/Projects/gopath/pkg/mod/github.com/pingcap/errors@v0.11.5-0.20201029093017-5a7df2af2ac7/normalize.go:156
github.com/pingcap/tidb/expression.(*baseFunctionClass).verifyArgs
	/home/bb7133/Projects/gopath/src/github.com/pingcap/tidb/expression/builtin.go:544
github.com/pingcap/tidb/expression.(*dateFormatFunctionClass).getFunction
	/home/bb7133/Projects/gopath/src/github.com/pingcap/tidb/expression/builtin_time.go:789
github.com/pingcap/tidb/expression.newFunctionImpl
	/home/bb7133/Projects/gopath/src/github.com/pingcap/tidb/expression/scalar_function.go:207
github.com/pingcap/tidb/expression.NewFunction
	/home/bb7133/Projects/gopath/src/github.com/pingcap/tidb/expression/scalar_function.go:238
github.com/pingcap/tidb/planner/core.(*expressionRewriter).newFunction
	/home/bb7133/Projects/gopath/src/github.com/pingcap/tidb/planner/core/expression_rewriter.go:1123
github.com/pingcap/tidb/planner/core.(*expressionRewriter).funcCallToExpression
	/home/bb7133/Projects/gopath/src/github.com/pingcap/tidb/planner/core/expression_rewriter.go:1632
github.com/pingcap/tidb/planner/core.(*expressionRewriter).Leave
	/home/bb7133/Projects/gopath/src/github.com/pingcap/tidb/planner/core/expression_rewriter.go:1003
github.com/pingcap/parser/ast.(*FuncCallExpr).Accept
	/home/bb7133/Projects/gopath/pkg/mod/github.com/pingcap/parser@v0.0.0-20201130080042-c3ddfec58248/ast/functions.go:500
github.com/pingcap/tidb/planner/core.(*PlanBuilder).rewriteExprNode
	/home/bb7133/Projects/gopath/src/github.com/pingcap/tidb/planner/core/expression_rewriter.go:185
github.com/pingcap/tidb/planner/core.(*PlanBuilder).rewriteWithPreprocess
	/home/bb7133/Projects/gopath/src/github.com/pingcap/tidb/planner/core/expression_rewriter.go:133
github.com/pingcap/tidb/planner/core.(*PlanBuilder).rewrite
	/home/bb7133/Projects/gopath/src/github.com/pingcap/tidb/planner/core/expression_rewriter.go:101
github.com/pingcap/tidb/planner/core.rewriteAstExpr
	/home/bb7133/Projects/gopath/src/github.com/pingcap/tidb/planner/core/expression_rewriter.go:68
github.com/pingcap/tidb/expression.ColumnInfos2ColumnsAndNames
	/home/bb7133/Projects/gopath/src/github.com/pingcap/tidb/expression/expression.go:816
github.com/pingcap/tidb/ddl.makeupDecodeColMap
	/home/bb7133/Projects/gopath/src/github.com/pingcap/tidb/ddl/index.go:1176
github.com/pingcap/tidb/ddl.(*worker).addPhysicalTableIndex
	/home/bb7133/Projects/gopath/src/github.com/pingcap/tidb/ddl/index.go:1388
github.com/pingcap/tidb/ddl.(*worker).addTableIndex
	/home/bb7133/Projects/gopath/src/github.com/pingcap/tidb/ddl/index.go:1484
github.com/pingcap/tidb/ddl.(*worker).onCreateIndex.func1
	/home/bb7133/Projects/gopath/src/github.com/pingcap/tidb/ddl/index.go:518
github.com/pingcap/tidb/ddl.(*worker).runReorgJob.func1
	/home/bb7133/Projects/gopath/src/github.com/pingcap/tidb/ddl/reorg.go:125
runtime.goexit
	/home/bb7133/Softwares/go/src/runtime/asm_amd64.s:1374"] [stack="github.com/pingcap/parser/terror.Log
	/home/bb7133/Projects/gopath/pkg/mod/github.com/pingcap/parser@v0.0.0-20201130080042-c3ddfec58248/terror/terror.go:271
github.com/pingcap/tidb/expression.ColumnInfos2ColumnsAndNames
	/home/bb7133/Projects/gopath/src/github.com/pingcap/tidb/expression/expression.go:818
github.com/pingcap/tidb/ddl.makeupDecodeColMap
	/home/bb7133/Projects/gopath/src/github.com/pingcap/tidb/ddl/index.go:1176
github.com/pingcap/tidb/ddl.(*worker).addPhysicalTableIndex
	/home/bb7133/Projects/gopath/src/github.com/pingcap/tidb/ddl/index.go:1388
github.com/pingcap/tidb/ddl.(*worker).addTableIndex
	/home/bb7133/Projects/gopath/src/github.com/pingcap/tidb/ddl/index.go:1484
github.com/pingcap/tidb/ddl.(*worker).onCreateIndex.func1
	/home/bb7133/Projects/gopath/src/github.com/pingcap/tidb/ddl/index.go:518
github.com/pingcap/tidb/ddl.(*worker).runReorgJob.func1
	/home/bb7133/Projects/gopath/src/github.com/pingcap/tidb/ddl/reorg.go:125

4. What is your TiDB version? (Required)

It appears in TiDB v4.0.9 and master branch.

@ti-srebot
Copy link
Contributor

ti-srebot commented Jan 5, 2021

Please edit this comment or add a new comment to complete the following information

Not a bug

  1. Remove the 'type/bug' label
  2. Add notes to indicate why it is not a bug

Duplicate bug

  1. Add the 'type/duplicate' label
  2. Add the link to the original bug

Bug

Note: Make Sure that 'component', and 'severity' labels are added
Example for how to fill out the template: #20100

1. Root Cause Analysis (RCA) (optional)

2. Symptom (optional)

3. All Trigger Conditions (optional)

4. Workaround (optional)

5. Affected versions

[v4.0.9:v4.0.10],[v5.0.0-rc]

6. Fixed versions

master

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
severity/major sig/sql-infra SIG: SQL Infra type/bug The issue is confirmed as a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants