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

SOAR执行alter合并,报panic: runtime error: invalid memory address or nil pointer dereference错误 #163

Closed
haoclf opened this issue Dec 14, 2018 · 0 comments

Comments

@haoclf
Copy link

haoclf commented Dec 14, 2018

Please answer these questions before submitting your issue. Thanks!

  1. What did you do?
    If possible, provide a recipe for reproducing the error.

[root@mongodb-test-td-2-c ~]# echo "alter table test1 add column idd int not null AUTO_INCREMENT;alter table test1 add index idx_idd(idd);alter table test2 add column idd int not null AUTO_INCREMENT;" |soar -report-type rewrite -rewrite-rules mergealter
ALTER TABLE test1 add column idd int not null AUTO_INCREMENT, add index idx_idd(idd) ;
ALTER TABLE test2 add column idd int not null AUTO_INCREMENT ;
[root@mongodb-test-td-2-c ~]#
[root@mongodb-test-td-2-c ~]#
[root@mongodb-test-td-2-c ~]#
[root@mongodb-test-td-2-c ~]#
[root@mongodb-test-td-2-c ~]# echo "alter table test1 add column idd int not null AUTO_INCREMENT;alter table test1 alter column idd drop default;alter table test1 add index idx_idd(idd);alter table test2 add column idd int not null AUTO_INCREMENT;" |soar -report-type rewrite -rewrite-rules mergealter
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x28 pc=0x992a10]

goroutine 1 [running]:
github.com/XiaoMi/soar/advisor.(*Query4Audit).RuleColumnWithCharset(0xc000a11e00, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
src/github.com/XiaoMi/soar/advisor/heuristic.go:2857 +0x290
main.main()
src/github.com/XiaoMi/soar/cmd/soar/soar.go:210 +0xb76
[root@mongodb-test-td-2-c ~]#

  1. What did you expect to see?
    最好有一个条件判断,可以自由选择是否将drop default操作合并到alter语句中
    例如 添加一个控制参数 --ensure-drop-default=[true |false]
    参数为true时表示:祛除字段的default值
    参数为false时表示:保留字段的default值,忽略drop default语句;
    原因:有些架构平台在根据model生成sql时会产生alter table table_name alter column column_name drop default;这样的语句。一般情况下 这些默认值是要保留的,所以预留一个开关,决定是否保留drop default操作。

  2. What did you see instead?
    [root@mongodb-test-td-2-c ~]# echo "alter table test1 add column idd int not null AUTO_INCREMENT;alter table test1 alter column idd drop default;alter table test1 add index idx_idd(idd);alter table test2 add column idd int not null AUTO_INCREMENT;" |soar -report-type rewrite -rewrite-rules mergealter
    panic: runtime error: invalid memory address or nil pointer dereference
    [signal SIGSEGV: segmentation violation code=0x1 addr=0x28 pc=0x992a10]

goroutine 1 [running]:
github.com/XiaoMi/soar/advisor.(*Query4Audit).RuleColumnWithCharset(0xc000a11e00, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
src/github.com/XiaoMi/soar/advisor/heuristic.go:2857 +0x290
main.main()
src/github.com/XiaoMi/soar/cmd/soar/soar.go:210 +0xb76

  1. What version of are you using (soar -version)?
    version:0.10.0-10-g1bdc431
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant