Description:
For MySQL-8.0 with the debug version, adding CONSTRAINT leads to the following crash stack.
#0 0x00007f7923a30847 in raise () from /lib64/libc.so.6
#1 0x00007f7923a31e8a in abort () from /lib64/libc.so.6
#2 0x00007f7923a29866 in __assert_fail_base () from /lib64/libc.so.6
#3 0x00007f7923a29912 in __assert_fail () from /lib64/libc.so.6
#4 0x0000000003bfd884 in fill_alter_inplace_info (thd=thd@entry=0x628000190100, table=table@entry=0x61e0000990a0,
ha_alter_info=ha_alter_info@entry=0x7f7600ed2820) at /flash12/daoke.wangc/PolarDB_80/sql/sql_table.cc:11689
#5 0x0000000003c242aa in mysql_alter_table (thd=thd@entry=0x628000190100, new_db=<optimized out>, new_name=<optimized out>,
create_info=create_info@entry=0x7f7600ed5540, table_list=<optimized out>, table_list@entry=0x61c0008928a8,
alter_info=alter_info@entry=0x7f7600ed5660) at /flash12/daoke.wangc/PolarDB_80/sql/sql_table.cc:17218
#6 0x00000000048ef2cd in Sql_cmd_alter_table::execute (this=<optimized out>, thd=0x628000190100)
at /flash12/daoke.wangc/PolarDB_80/sql/sql_alter.cc:354
#7 0x0000000003a273b5 in mysql_execute_command (thd=thd@entry=0x628000190100, first_level=first_level@entry=true)
at /flash12/daoke.wangc/PolarDB_80/sql/sql_parse.cc:5033
#8 0x0000000003a2a3d5 in mysql_parse (thd=thd@entry=0x628000190100, parser_state=parser_state@entry=0x7f7600ed9ab0)
at /flash12/daoke.wangc/PolarDB_80/sql/sql_parse.cc:5918
#9 0x0000000003a2cae6 in dispatch_command (thd=thd@entry=0x628000190100, com_data=com_data@entry=0x7f7600edb950,
command=COM_QUERY) at /flash12/daoke.wangc/PolarDB_80/sql/sql_parse.cc:1948
#10 0x0000000003a307e4 in do_command(THD*, std::function<bool (THD*, COM_DATA const*, enum_server_command)>*) (
thd=thd@entry=0x628000190100, dispatcher=dispatcher@entry=0x0) at /flash12/daoke.wangc/PolarDB_80/sql/sql_parse.cc:1350
#11 0x0000000003a3091e in do_command (thd=thd@entry=0x628000190100) at /flash12/daoke.wangc/PolarDB_80/sql/sql_parse.cc:1387
#12 0x0000000003f80b24 in handle_connection (arg=arg@entry=0x60f000074440)
at /flash12/daoke.wangc/PolarDB_80/sql/conn_handler/connection_handler_per_thread.cc:313
#13 0x00000000072d1b4e in pfs_spawn_thread (arg=0x614000008660)
at /flash12/daoke.wangc/PolarDB_80/storage/perfschema/pfs.cc:2902
#14 0x00007f79256856e5 in start_thread () from /lib64/libpthread.so.0
#15 0x00007f7923af913d in clone () from /lib64/libc.so.6
How to repeat:
create table departments(department_id int not null, department_name char(30) not null, manager_id int, location_id int, CONSTRAINT dept_id_pk PRIMARY KEY (department_id));
CREATE TABLE jobs(job_id char(10) NOT NULL, job_title char(35) NOT NULL, min_salary int, max_salary int, CONSTRAINT job_id_pk PRIMARY KEY(job_id));
create table employees(employee_id int not null, first_name char(20), last_name char(25) NOT NULL, email char(25) NOT NULL, phone_number char(20), hire_date DATE NOT NULL, job_id char(10) NOT NULL, salary double, commission_pct double, manager_id int, department_id int(11), CONSTRAINT emp_emp_id_pk PRIMARY KEY (employee_id), CONSTRAINT emp_salary_min CHECK (salary > 0), CONSTRAINT emp_email_uk UNIQUE (email), CONSTRAINT emp_dept_fk FOREIGN KEY (department_id) REFERENCES departments(department_id), CONSTRAINT emp_job_fk FOREIGN KEY (job_id) REFERENCES jobs(job_id), CONSTRAINT emp_manager_fk FOREIGN KEY (manager_id) REFERENCES employees(employee_id));
ALTER TABLE departments ADD(CONSTRAINT dept_mgr_fk FOREIGN KEY (manager_id) REFERENCES employees(employee_id));