File: name_const_replacement.test

package info (click to toggle)
mariadb 1%3A11.8.2-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 765,428 kB
  • sloc: ansic: 2,382,827; cpp: 1,803,532; asm: 378,315; perl: 63,176; sh: 46,496; pascal: 40,776; java: 39,363; yacc: 20,428; python: 19,506; sql: 17,864; xml: 12,463; ruby: 8,544; makefile: 6,059; cs: 5,855; ada: 1,700; lex: 1,193; javascript: 1,039; objc: 80; tcl: 73; awk: 46; php: 22
file content (46 lines) | stat: -rw-r--r-- 1,127 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#
# MDEV-33971 Using NAME_CONST() changes the plan
#

create table t1 (a int, b int);
insert into t1 values (1,1),(2,2);

--source include/explain-no-costs.inc
explain format=json
select * from t1 where a=name_const('varname',1);
--source include/explain-no-costs.inc
explain format=json
select * from t1 left join t1 as t2 on t1.a=name_const('varname',1) and t1.b=t2.b;


create table t2 (
  a varchar(100) collate utf8_unicode_ci,
  b int
);
insert into t2 values ('foo', 1),('bar', 1);
create procedure p1(var1 varchar(10))
  update t2 set b=b+1 where a=var1;
call p1('foo');
call p1('foo');
call p1('foo');
select * from t2;


create table t3 (
  a varchar(100) collate utf8_unicode_ci,
  b int
);
insert into t3 values ('foo', 1),('bar', 1);
select * from t3;
--source include/explain-no-costs.inc
explain format=json
update t3 set b=b+1 where a= NAME_CONST('var1',_latin1'foo' COLLATE 'latin1_swedish_ci');
#
# enable after fixing MDEV-27904
#
--disable_view_protocol
select * from t3 where a= NAME_CONST('var1',_latin1'foo' COLLATE 'latin1_swedish_ci');
--enable_view_protocol

drop procedure p1;
drop table t1, t2, t3;