1--source include/have_geometry.inc
2--source include/have_debug.inc
3
4SET @tmp=ST_GIS_DEBUG(1);
5
6--source include/gis_debug.inc
7
8
9--echo #
10--echo # Start of 10.2 tests
11--echo #
12
13--echo #
14--echo # MDEV-10134 Add full support for DEFAULT
15--echo #
16
17--error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
18CREATE TABLE t1 (a INT DEFAULT ST_GIS_DEBUG(1));
19
20--echo #
21--echo # End of 10.2 tests
22--echo #
23
24--echo #
25--echo # Start of 10.3 tests
26--echo #
27
28--echo #
29--echo # Comparison data type aggregation for pluggable data types
30--echo #
31
32SET SESSION debug_dbug="+d,Item_func_in";
33SET SESSION debug_dbug="+d,Predicant_to_list_comparator";
34
35CREATE TABLE t1 (a POINT);
36INSERT INTO t1 VALUES (POINT(1,1)),(POINT(1,2)),(POINT(1,3));
37SELECT COUNT(*) FROM t1 WHERE a IN (POINT(1,1),POINT(10,20),POINT(10,30));
38SELECT COUNT(*) FROM t1 WHERE a IN (POINT(1,1),POINT(10,20),POINT(10,30),'test');
39SELECT COUNT(*) FROM t1 WHERE a IN ('test','test1');
40DROP TABLE t1;
41
42CREATE TABLE t1 (a TEXT);
43INSERT INTO t1 VALUES ('test'),('test1'),('test2');
44SELECT * FROM t1 WHERE a IN ('test',POINT(1,1));
45DROP TABLE t1;
46
47SET SESSION debug_dbug="-d,Predicant_to_list_comparator";
48SET SESSION debug_dbug="-d,Item_func_in";
49
50
51--echo #
52--echo # MDEV-12238 Add Type_handler::Item_func_{plus|minus|mul|div|mod}_fix_length_and_dec()
53--echo #
54
55# This tests is to check that operators '+' and '*' are commutative,
56# while operators '/', '-' and 'MOD' are not commutative.
57#
58# It forces substitution of type_aggregator_for_{plus|minus|mul|div|mod} to
59# type_aggregator_for_result / type_aggregator_non_commutative_test,
60# which have pairs:
61#  (GEOMETRY,GEOMETRY)->GEOMETRY
62#  (GEOMETRY,VARCHAR)->GEOMETRY
63# Note, they don't not have a pair:
64#  (VARCHAR,GEOMETRY)->GEOMETRY
65#
66# Commutative operators should work for all these argument type combinations:
67# (GEOMETRY,GEOMETRY), (GEOMETRY,VARCHAR), (VARCHAR,GEOMETRY).
68# Non-commutative operators should work for:
69# (GEOMETRY,GEOMETRY), (GEOMETRY,VARCHAR),
70# but should fail for (VARCHAR,GEOMETRY).
71#
72# Note, LIMIT 0 is needed to avoid calling str_op(), which does DBUG_ASSERT(0).
73
74SET debug_dbug='+d,num_op';
75
76# (GEOMETRY,GEOMETRY) gives GEOMETRY for all operators
77CREATE TABLE t1 AS SELECT
78  POINT(0,0)+POINT(0,0),
79  POINT(0,0)-POINT(0,0),
80  POINT(0,0)*POINT(0,0),
81  POINT(0,0)/POINT(0,0),
82  POINT(0,0) MOD POINT(0,0) LIMIT 0;
83SHOW CREATE TABLE t1;
84DROP TABLE t1;
85
86# (GEOMETRY,VARCHAR) gives GEOMETRY for all operators
87CREATE TABLE t1 AS SELECT
88  POINT(0,0)+'0',
89  POINT(0,0)-'0',
90  POINT(0,0)*'0',
91  POINT(0,0)/'0',
92  POINT(0,0) MOD '0' LIMIT 0;
93SHOW CREATE TABLE t1;
94DROP TABLE t1;
95
96# (VARCHAR,GEOMETRY) gives GEOMETRY for commutative operators
97CREATE TABLE t1 AS SELECT
98  '0'+POINT(0,0),
99  '0'*POINT(0,0) LIMIT 0;
100SHOW CREATE TABLE t1;
101DROP TABLE t1;
102
103# (VARCHAR,GEOMETRY) gives an error for non-commutative operators
104--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION
105CREATE TABLE t1 AS SELECT '0'-POINT(0,0) LIMIT 0;
106
107--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION
108CREATE TABLE t1 AS SELECT '0'/POINT(0,0) LIMIT 0;
109
110--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION
111CREATE TABLE t1 AS SELECT '0' MOD POINT(0,0) LIMIT 0;
112
113SET debug_dbug='-d,num_op';
114