mariadb/mysql-test/r/replace.result
unknown 683ebcd101 Fixed bug#19789: REPLACE was allowed for a VIEW with CHECK OPTION enabled.
The st_lex::which_check_option_applicable() function controls for which 
statements WITH CHECK OPTION clause should be taken into account. REPLACE and
REPLACE_SELECT wasn't in the list which results in allowing REPLACE to insert
wrong rows in a such view.

The st_lex::which_check_option_applicable() now includes REPLACE and 
REPLACE_SELECT in the list of statements for which WITH CHECK OPTION clause is
applicable.


mysql-test/t/replace.test:
  Added test case for bug#19789: REPLACE was allowed for a VIEW with CHECK OPTION enabled.
mysql-test/r/replace.result:
  Added test case for bug#19789: REPLACE was allowed for a VIEW with CHECK OPTION enabled.
sql/sql_lex.h:
  Fixed bug#19789: REPLACE was allowed for a VIEW with CHECK OPTION enabled.
  The st_lex::which_check_option_applicable() now includes REPLACE and 
  REPLACE_SELECT in the list of statements for which WITH CHECK OPTION clause is
  applicable.
2006-06-07 16:17:56 +04:00

32 lines
1.1 KiB
Text

drop table if exists t1;
CREATE TABLE t1 (
gesuchnr int(11) DEFAULT '0' NOT NULL,
benutzer_id int(11) DEFAULT '0' NOT NULL,
PRIMARY KEY (gesuchnr,benutzer_id)
);
replace into t1 (gesuchnr,benutzer_id) values (2,1);
replace into t1 (gesuchnr,benutzer_id) values (1,1);
replace into t1 (gesuchnr,benutzer_id) values (1,1);
alter table t1 engine=heap;
replace into t1 (gesuchnr,benutzer_id) values (1,1);
drop table t1;
create table t1 (a tinyint not null auto_increment primary key, b char(20) default "default_value");
insert into t1 values (126,"first"),(63, "middle"),(0,"last");
insert into t1 values (0,"error");
ERROR 23000: Duplicate entry '127' for key 1
replace into t1 values (0,"error");
ERROR 23000: Duplicate entry '127' for key 1
replace into t1 values (126,"first updated");
replace into t1 values (63,default);
select * from t1;
a b
126 first updated
63 default_value
127 last
drop table t1;
CREATE TABLE t1 (f1 INT);
CREATE VIEW v1 AS SELECT f1 FROM t1 WHERE f1 = 0 WITH CHECK OPTION;
REPLACE INTO v1 (f1) VALUES (1);
ERROR HY000: CHECK OPTION failed 'test.v1'
DROP TABLE t1;
DROP VIEW v1;