1################################################################################
2# inc/gcol_handler.inc                                                         #
3#                                                                              #
4# Purpose:                                                                     #
5#  Testing HANDLER.                                                            #
6#                                                                              #
7#                                                                              #
8#                                                                              #
9#------------------------------------------------------------------------------#
10# Original Author: Andrey Zhakov                                               #
11# Original Date: 2008-09-04                                                    #
12# Change Author:                                                               #
13# Change Date:                                                                 #
14# Change:                                                                      #
15################################################################################
16
17create table t1 (a int,
18                 b int generated always as (-a) virtual,
19                 c int generated always as (-a) stored,
20		 d char(1),
21		 index (a),
22		 index (c));
23insert into t1 (a,d) values (4,'a'), (2,'b'), (1,'c'), (3,'d');
24select * from t1;
25
26--echo # HANDLER tbl_name OPEN
27handler t1 open;
28
29--echo # HANDLER tbl_name READ non-gcol_index_name > (value1,value2,...)
30handler t1 read a > (2);
31
32--echo # HANDLER tbl_name READ non-gcol_index_name > (value1,value2,...) WHERE non-gcol_field=expr
33handler t1 read a > (2) where d='c';
34
35--echo # HANDLER tbl_name READ gcol_index_name = (value1,value2,...)
36handler t1 read c = (-2);
37
38--echo # HANDLER tbl_name READ gcol_index_name = (value1,value2,...) WHERE non-gcol_field=expr
39handler t1 read c = (-2) where d='c';
40
41--echo # HANDLER tbl_name READ non-gcol_index_name > (value1,value2,...) WHERE gcol_field=expr
42handler t1 read a > (2) where b=-3 && c=-3;
43
44--echo # HANDLER tbl_name READ gcol_index_name <= (value1,value2,...)
45handler t1 read c <= (-2);
46
47--echo # HANDLER tbl_name READ gcol_index_name > (value1,value2,...) WHERE gcol_field=expr
48handler t1 read c <= (-2) where b=-3;
49
50--echo # HANDLER tbl_name READ gcol_index_name FIRST
51handler t1 read c first;
52
53--echo # HANDLER tbl_name READ gcol_index_name NEXT
54handler t1 read c next;
55
56--echo # HANDLER tbl_name READ gcol_index_name PREV
57handler t1 read c prev;
58
59--echo # HANDLER tbl_name READ gcol_index_name LAST
60handler t1 read c last;
61
62--echo # HANDLER tbl_name READ FIRST where non-gcol=expr
63handler t1 read FIRST where a >= 2;
64
65--echo # HANDLER tbl_name READ FIRST where gcol=expr
66handler t1 read FIRST where b >= -2;
67
68--echo # HANDLER tbl_name READ NEXT where non-gcol=expr
69handler t1 read NEXT where d='c';
70
71--echo # HANDLER tbl_name READ NEXT where gcol=expr
72handler t1 read NEXT where b<=-4;
73
74--echo # HANDLER tbl_name CLOSE
75handler t1 close;
76
77drop table t1;
78