[MDEV-10035] DBUG_ASSERT on CREATE VIEW v1 AS SELECT * FROM t1 FOR UPDATE Created: 2016-05-06  Updated: 2017-01-04  Resolved: 2017-01-04

Status: Closed
Project: MariaDB Server
Component/s: Parser, Views
Affects Version/s: 10.0, 10.1
Fix Version/s: 10.0.29, 10.1.21

Type: Bug Priority: Major
Reporter: Alexander Barkov Assignee: Oleksandr Byelkin
Resolution: Fixed Votes: 0
Labels: None

Issue Links:
Relates
relates to MDEV-8909 union parser cleanup Closed
relates to MDEV-10063 VIEWs and subqueries with FOR UPDATE Open
Sprint: 10.2.1-5, 10.2.2-1, 10.2.2-2, 10.0.29

 Description   

This script makes the server crash on assert in debug builds:

DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (a INT);
INSERT INTO t1 VALUES (10);
DROP VIEW IF EXISTS v1;
CREATE VIEW v1 AS SELECT * FROM t1 FOR UPDATE;

mysqld: /home/bar/maria-git/server.10.2/sql/table_cache.cc:853: bool tdc_remove_table(THD*, enum_tdc_remove_table_type, const char*, const char*, bool): Assertion `remove_type == TDC_RT_REMOVE_UNUSED || thd->mdl_context.is_lock_owner(MDL_key::TABLE, db, table_name, MDL_EXCLUSIVE)' failed.
 
Program received signal SIGABRT, Aborted.
[Switching to Thread 0x7ffff7f7cf00 (LWP 29487)]
0x00007ffff5b9ea98 in __GI_raise (sig=sig@entry=6)
    at ../sysdeps/unix/sysv/linux/raise.c:55
55	  return INLINE_SYSCALL (tgkill, 3, pid, selftid, sig);

FOR UPDATE should probably be disallowed in VIEWs.



 Comments   
Comment by Elena Stepanova [ 2016-05-13 ]

Stack trace from 10.0 commit cee9ab9d85a8d75290b0d60bc7af26c8cf179a1d

mysqld: /src/10.0/sql/table_cache.cc:983: bool tdc_remove_table(THD*, enum_tdc_remove_table_type, const char*, const char*, bool): Assertion `remove_type == TDC_RT_REMOVE_UNUSED || thd->mdl_context.is_lock_owner(MDL_key::TABLE, db, table_name, MDL_EXCLUSIVE)' failed.
160514  2:31:50 [ERROR] mysqld got signal 6 ;
 
#7  0x00007f0358a4a1d2 in __assert_fail () from /lib64/libc.so.6
#8  0x00000000007eef3a in tdc_remove_table (thd=0x7f0354be9970, remove_type=TDC_RT_REMOVE_ALL, db=0x7f0351477770 "test", table_name=0x7f0351477158 "v1", kill_delayed_threads=false) at /src/10.0/sql/table_cache.cc:981
#9  0x000000000073d19e in mysql_create_view (thd=0x7f0354be9970, views=0x7f0351477190, mode=VIEW_CREATE_NEW) at /src/10.0/sql/sql_view.cc:625
#10 0x0000000000673ba1 in mysql_execute_command (thd=0x7f0354be9970) at /src/10.0/sql/sql_parse.cc:4946
#11 0x00000000006777cd in mysql_parse (thd=0x7f0354be9970, rawbuf=0x7f0351477088 "CREATE VIEW v1 AS SELECT * FROM t1 FOR UPDATE", length=45, parser_state=0x7f035aaf4650) at /src/10.0/sql/sql_parse.cc:6574
#12 0x000000000066a309 in dispatch_command (command=COM_QUERY, thd=0x7f0354be9970, packet=0x7f035353aa71 "CREATE VIEW v1 AS SELECT * FROM t1 FOR UPDATE", packet_length=45) at /src/10.0/sql/sql_parse.cc:1308
#13 0x00000000006695d6 in do_command (thd=0x7f0354be9970) at /src/10.0/sql/sql_parse.cc:998
#14 0x0000000000787cb2 in do_handle_one_connection (thd_arg=0x7f0354be9970) at /src/10.0/sql/sql_connect.cc:1378
#15 0x0000000000787a24 in handle_one_connection (arg=0x7f0354be9970) at /src/10.0/sql/sql_connect.cc:1293
#16 0x0000000000df561c in pfs_spawn_thread (arg=0x7f03525bf4f0) at /src/10.0/storage/perfschema/pfs.cc:1860
#17 0x00007f035a76d0a4 in start_thread () from /lib64/libpthread.so.0
#18 0x00007f0358b0104d in clone () from /lib64/libc.so.6

Comment by Oleksandr Byelkin [ 2016-05-15 ]

revision-id: 4ffe2295e78538dde93df078421726f0c5a7d2a2 (mariadb-10.2.0-29-g4ffe229)
parent(s): b79944950e5e5db40cf7ad49061edf5f105512c4
committer: Oleksandr Byelkin
timestamp: 2016-05-15 15:25:33 +0200
message:

MDEV-10035: DBUG_ASSERT on CREATE VIEW v1 AS SELECT * FROM t1 FOR UPDATE

Lock type specifications prohibited in a view definition.

Comment by Oleksandr Byelkin [ 2016-05-17 ]

Conclusion after discussion:

1) Allow lock type in view
2) What lock type (view/upper query) should precede is yet unclear.

Comment by Elena Stepanova [ 2016-07-23 ]

Is it really going to be fixed only in 10.2 as the 'Fix version/s' says?

Comment by Sergei Golubchik [ 2016-07-23 ]

Let's decide on that when we'll have a reviewed patch

Comment by Oleksandr Byelkin [ 2016-09-04 ]

It is pushed. If it should be backported to other versions I can do it.

Comment by Elena Stepanova [ 2016-10-03 ]

If it should be in previous versions, why wasn't it pushed there at the first place, and why close the bug now? Re-opened for backporting.

Also, the fix version must be wrong, if it was fixed a month ago it went to 10.2.2, not 10.2.3.

Comment by Oleksandr Byelkin [ 2017-01-04 ]

5.5 it works...

Generated at Thu Feb 08 07:39:11 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.