Please answer these questions before submitting your issue. Thanks!
- 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 ~]#
-
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操作。
-
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
- What version of are you using (
soar -version)?
version:0.10.0-10-g1bdc431
Please answer these questions before submitting your issue. Thanks!
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
test1add column idd int not null AUTO_INCREMENT, add index idx_idd(idd) ;ALTER TABLE
test2add 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 ~]#
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操作。
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
soar -version)?version:0.10.0-10-g1bdc431