Bug #6852 prepared INSERT, updatable VIEW with check option, crash
Submitted: 26 Nov 2004 19:51 Modified: 14 Jun 2005 19:12
Reporter: Matthias Leich Email Updates:
Status: Can't repeat Impact on me:
None 
Category:MySQL Server Severity:S2 (Serious)
Version:5.0 OS:
Assigned to: Oleksandr Byelkin CPU Architecture:Any

[26 Nov 2004 19:51] Matthias Leich
Description:
Extreme simplified example from the NIST tests 
('sql/cdr027', sub test case 0447):
CREATE TABLE t1 ( col1 CHAR );
   # Some observations
  # 1. The check option is needed
  # 2. The <cond1> AND/OR <cond2> is needed
  # 3. It does not play any role if the complete check gives
  #    true or false.
  # 4. The non prepared version does not crash the server.
  CREATE VIEW v1 AS
  SELECT col1
  FROM t1
  WHERE 1 AND 1
  WITH CHECK OPTION;

  # nonprepared version INSERT INTO v1 VALUES('A');

  PREPARE stmt1 FROM "INSERT INTO v1 VALUES('A')" ;

  # This execute crashes the server !!
   EXECUTE stmt1;

My environment:
   - Intel PC with Linux(SuSE 9.1)
   - MySQL compiled from source
        Version 5.0 ChangeSet@1.1684, 2004-11-25

How to repeat:
Please use my attached test file xnist1.test , copy it to mysql-test/t
  ./mysql-test-run xnist1

This file contains also the original NIST test case .
[26 Nov 2004 19:53] Matthias Leich
test case

Attachment: xnist1.test (application/test, text), 1.79 KiB.

[27 Nov 2004 23:10] MySQL Verification Team
Thank you for the bug report I was able to repeat with
latest BK source 5.0.
[29 Nov 2004 19:21] Peter Gulutzan
I get a crash in similar circumstances (view with check option, OR in WHERE condition) 
without needing "prepare". Example: 
 
mysql> delimiter // 
 
mysql> create table ti2 (s1 char(2))// 
Query OK, 0 rows affected (0.31 sec) 
 
mysql> create view vi2 as select s1 from ti2 where s1 like '%' or s1 like '%' with check 
option// 
Query OK, 0 rows affected (0.01 sec) 
 
mysql> create procedure pi2 (param1 char(2)) begin insert  into vi2 values (param1); end;// 
Query OK, 0 rows affected (0.00 sec) 
 
mysql> call pi2('a''5')// 
Query OK, 1 row affected, 1 warning (0.00 sec) 
 
mysql> call pi2('b`7')// 
ERROR 2013 (HY000): Lost connection to MySQL server during query
[10 Jan 2005 13:12] Matthias Leich
I checked this bug with a fresh pulled and compiled MySQL 5.0 again.
ChangeSet@1.1740, 2005-01-09

The bug disappeared.
[14 Jun 2005 19:12] Oleksandr Byelkin
Yes it is not repeatable any more, thank you for bugreport!