summaryrefslogtreecommitdiff
path: root/mysql-test/main/gis-debug.test
blob: 1c6bf5fcb197754cca62afe37638d45fbeefd2e0 (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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
--source include/have_geometry.inc
--source include/have_debug.inc

SET @tmp=ST_GIS_DEBUG(1);

--source include/gis_debug.inc


--echo #
--echo # Start of 10.2 tests
--echo #

--echo #
--echo # MDEV-10134 Add full support for DEFAULT
--echo #

--error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
CREATE TABLE t1 (a INT DEFAULT ST_GIS_DEBUG(1));

--echo #
--echo # End of 10.2 tests
--echo #

--echo #
--echo # Start of 10.3 tests
--echo #

--echo #
--echo # Comparison data type aggregation for pluggable data types
--echo #

SET SESSION debug_dbug="+d,Item_func_in";
SET SESSION debug_dbug="+d,Predicant_to_list_comparator";

CREATE TABLE t1 (a POINT);
INSERT INTO t1 VALUES (POINT(1,1)),(POINT(1,2)),(POINT(1,3));
SELECT COUNT(*) FROM t1 WHERE a IN (POINT(1,1),POINT(10,20),POINT(10,30));
SELECT COUNT(*) FROM t1 WHERE a IN (POINT(1,1),POINT(10,20),POINT(10,30),'test');
SELECT COUNT(*) FROM t1 WHERE a IN ('test','test1');
DROP TABLE t1;

CREATE TABLE t1 (a TEXT);
INSERT INTO t1 VALUES ('test'),('test1'),('test2');
SELECT * FROM t1 WHERE a IN ('test',POINT(1,1));
DROP TABLE t1;

SET SESSION debug_dbug="-d,Predicant_to_list_comparator";
SET SESSION debug_dbug="-d,Item_func_in";


--echo #
--echo # MDEV-12238 Add Type_handler::Item_func_{plus|minus|mul|div|mod}_fix_length_and_dec()
--echo #

# This tests is to check that operators '+' and '*' are commutative,
# while operators '/', '-' and 'MOD' are not commutative.
#
# It forces substitution of type_aggregator_for_{plus|minus|mul|div|mod} to
# type_aggregator_for_result / type_aggregator_non_commutative_test,
# which have pairs:
#  (GEOMETRY,GEOMETRY)->GEOMETRY
#  (GEOMETRY,VARCHAR)->GEOMETRY
# Note, they don't not have a pair:
#  (VARCHAR,GEOMETRY)->GEOMETRY
#
# Commutative operators should work for all these argument type combinations:
# (GEOMETRY,GEOMETRY), (GEOMETRY,VARCHAR), (VARCHAR,GEOMETRY).
# Non-commutative operators should work for:
# (GEOMETRY,GEOMETRY), (GEOMETRY,VARCHAR),
# but should fail for (VARCHAR,GEOMETRY).
#
# Note, LIMIT 0 is needed to avoid calling str_op(), which does DBUG_ASSERT(0).

SET debug_dbug='+d,num_op';

# (GEOMETRY,GEOMETRY) goes through
# Type_collection_geometry::aggregate_for_num_op() which fails.

--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION
SELECT POINT(0,0)+POINT(0,0);
--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION
SELECT POINT(0,0)-POINT(0,0);
--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION
SELECT POINT(0,0)*POINT(0,0);
--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION
SELECT POINT(0,0)/POINT(0,0);
--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION
SELECT POINT(0,0) MOD POINT(0,0);

# (GEOMETRY,VARCHAR) gives GEOMETRY for all operators
CREATE TABLE t1 AS SELECT
  POINT(0,0)+'0',
  POINT(0,0)-'0',
  POINT(0,0)*'0',
  POINT(0,0)/'0',
  POINT(0,0) MOD '0' LIMIT 0;
SHOW CREATE TABLE t1;
DROP TABLE t1;

# (VARCHAR,GEOMETRY) gives GEOMETRY for commutative operators
CREATE TABLE t1 AS SELECT
  '0'+POINT(0,0),
  '0'*POINT(0,0) LIMIT 0;
SHOW CREATE TABLE t1;
DROP TABLE t1;

# (VARCHAR,GEOMETRY) gives an error for non-commutative operators
--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION
CREATE TABLE t1 AS SELECT '0'-POINT(0,0) LIMIT 0;

--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION
CREATE TABLE t1 AS SELECT '0'/POINT(0,0) LIMIT 0;

--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION
CREATE TABLE t1 AS SELECT '0' MOD POINT(0,0) LIMIT 0;

SET debug_dbug='-d,num_op';

--echo #
--echo # End of 10.3 tests
--echo #


--echo #
--echo # Start of 10.4 tests
--echo #

--echo #
--echo # MDEV-16454 Bad results for IN with ROW
--echo #

SET SESSION debug_dbug="+d,cmp_item";
SET SESSION debug_dbug="+d,Item_func_in";
SET SESSION debug_dbug="+d,Predicant_to_list_comparator";

SELECT (POINT(1,1),0) IN ((POINT(1,1),0),((POINT(1,1)),1));
SELECT (1,(POINT(1,1),0)) IN ((1,(POINT(1,1),0)),(0,(POINT(1,1),0)));

--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION
SELECT (1,0) IN ((POINT(1,1),0),(0,0));
SHOW WARNINGS;

--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION
SELECT (1,(0,0)) IN ((1,(POINT(1,1),0)),(0,(0,0)));
SHOW WARNINGS;

SET SESSION debug_dbug="-d,Predicant_to_list_comparator";
SET SESSION debug_dbug="-d,Item_func_in";
SET SESSION debug_dbug="-d,cmp_item";

--echo #
--echo # End of 10.4 tests
--echo #


--echo #
--echo # Start of 10.5 tests
--echo #

--echo #
--echo # MDEV-19994 Add class Function_collection
--echo #

--disable_service_connection
SET SESSION debug_dbug="+d,make_item_func_call_native_simulate_not_found";
--error ER_PARSE_ERROR
SELECT CONTAINS(POINT(1,1),POINT(1,1));
--error ER_PARSE_ERROR
SELECT WITHIN(POINT(1,1),POINT(1,1));
SET SESSION debug_dbug="-d,make_item_func_call_native_simulate_not_found";
--enable_service_connection

--echo #
--echo # MDEV-20009 Add CAST(expr AS pluggable_type)
--echo #

SET SESSION debug_dbug="+d,emulate_geometry_create_typecast_item";
SELECT AsText(CAST('POINT(0 0)' AS GEOMETRY));
SET SESSION debug_dbug="-d,emulate_geometry_create_typecast_item";


--echo #
--echo # End of 10.5 tests
--echo #