summaryrefslogtreecommitdiffstats
path: root/mysql-test/suite/funcs_1/t/row_count_func.test
blob: fb207681bc6bcfbc2eab1846a798fb70eb0481e0 (plain)
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
--echo
--echo # -- 
--echo # -- Test case for Bug#21818.
--echo # -- 
--echo

--disable_warnings
DROP TABLE IF EXISTS t1;
--enable_warnings

CREATE TABLE t1(a INT);
INSERT INTO t1 VALUES (1), (2), (3);

--echo
--echo # -- Check 1.

--disable_warnings
--enable_info
--echo SELECT * FROM t1 INTO OUTFILE "MYSQL_TMP_DIR/bug21818.txt";
--disable_query_log # to avoid $MYSQL_TMP_DIR in query log
--disable_ps2_protocol
--eval SELECT * FROM t1 INTO OUTFILE "$MYSQL_TMP_DIR/bug21818.txt"
--enable_ps2_protocol
--enable_query_log
--disable_info

--echo
--disable_ps2_protocol
SELECT ROW_COUNT();
--enable_ps2_protocol

--echo
--echo # -- Check 2.

--enable_info
SELECT a FROM t1 LIMIT 1 INTO @a;
--disable_info

--echo
--disable_ps2_protocol
SELECT ROW_COUNT();
--enable_ps2_protocol

--enable_warnings
--echo
--echo # -- Check 3.

--disable_warnings
DROP DATABASE IF EXISTS mysqltest1;
--enable_warnings

--enable_info
CREATE DATABASE mysqltest1;
--disable_info

--echo
--disable_ps2_protocol
SELECT ROW_COUNT();
--enable_ps2_protocol

DROP DATABASE mysqltest1;

--echo
--echo # -- Check 4.

DELETE FROM t1;

--enable_info
--echo LOAD DATA INFILE 'MYSQL_TMP_DIR/bug21818.txt' INTO TABLE t1(a);
--disable_query_log # to avoid $MYSQL_TMP_DIR in query log
--eval LOAD DATA INFILE '$MYSQL_TMP_DIR/bug21818.txt' INTO TABLE t1(a)
--enable_query_log
--disable_info

--echo
--disable_ps2_protocol
SELECT ROW_COUNT();
--enable_ps2_protocol

--remove_file $MYSQL_TMP_DIR/bug21818.txt

--echo
--echo # -- Check 5.

--enable_info
ALTER TABLE t1 ADD COLUMN b VARCHAR(255);
--disable_info

--echo
--disable_ps2_protocol
SELECT ROW_COUNT();
--enable_ps2_protocol

--echo
DROP TABLE t1;

--echo
--echo # -- Check 6.

--disable_warnings
DROP TABLE IF EXISTS t2;
--enable_warnings

CREATE TABLE t1(a INT);
CREATE TABLE t2(a INT);

INSERT INTO t1 VALUES (1), (2), (3);
INSERT INTO t2 VALUES (ROW_COUNT());

SELECT * FROM t2;

DROP TABLE t1;
DROP TABLE t2;

--echo
--echo # -- Check 7 (check that SQL errors reset row_count to -1).

CREATE TABLE t1(a INT);

INSERT INTO t1 VALUES (1), (2), (3);
--error ER_SP_DOES_NOT_EXIST
SELECT f1();

--disable_ps2_protocol
SELECT ROW_COUNT();
--enable_ps2_protocol

DROP TABLE t1;

--echo
--echo # -- End of test case for Bug#21818.