summaryrefslogtreecommitdiff
blob: 9e8b77a21efa589ba85bb55ff41e99b5d9ef0452 (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
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
--- test/e_expr.test
+++ test/e_expr.test
@@ -937,8 +937,14 @@
 # 'a' LIKE 'A' is TRUE but
 # 'æ' LIKE 'Æ' is FALSE.
 #
+#   The restriction to ASCII characters does not apply if the ICU
+#   library is compiled in. When ICU is enabled SQLite does not act
+#   as it does "by default".
+#
 do_execsql_test e_expr-14.5.1 { SELECT 'A' LIKE 'a'         } 1
-do_execsql_test e_expr-14.5.2 "SELECT '\u00c6' LIKE '\u00e6'" 0
+ifcapable !icu {
+  do_execsql_test e_expr-14.5.2 "SELECT '\u00c6' LIKE '\u00e6'" 0
+}
 
 # EVIDENCE-OF: R-56683-13731 If the optional ESCAPE clause is present,
 # then the expression following the ESCAPE keyword must evaluate to a
@@ -985,7 +991,8 @@
   eval lappend ::likeargs $args
   return 1
 }
-db func like likefunc
+db func like -argcount 2 likefunc
+db func like -argcount 3 likefunc
 set ::likeargs [list]
 do_execsql_test e_expr-15.1.1 { SELECT 'abc' LIKE 'def' } 1
 do_test         e_expr-15.1.2 { set likeargs } {def abc}
@@ -1056,12 +1063,16 @@
 # default and so use of the REGEXP operator will normally result in an
 # error message.
 #
-do_catchsql_test e_expr-18.1.1 { 
-  SELECT regexp('abc', 'def') 
-} {1 {no such function: regexp}}
-do_catchsql_test e_expr-18.1.2 { 
-  SELECT 'abc' REGEXP 'def'
-} {1 {no such function: REGEXP}}
+#   There is a regexp function if ICU is enabled though.
+#
+ifcapable !icu {
+  do_catchsql_test e_expr-18.1.1 { 
+    SELECT regexp('abc', 'def') 
+  } {1 {no such function: regexp}}
+  do_catchsql_test e_expr-18.1.2 { 
+    SELECT 'abc' REGEXP 'def'
+  } {1 {no such function: REGEXP}}
+}
 
 # EVIDENCE-OF: R-33693-50180 The REGEXP operator is a special syntax for
 # the regexp() user function.
--- test/like.test
+++ test/like.test
@@ -115,7 +115,7 @@
   proc test_regexp {a b} {
     return [regexp $a $b]
   }
-  db function regexp test_regexp
+  db function regexp -argcount 2 test_regexp
   execsql {
     SELECT x FROM t1 WHERE x REGEXP 'abc' ORDER BY 1;
   }
@@ -608,7 +608,7 @@
 } {1 abcdef 1 ghijkl 1 mnopqr 2 abcdef 2 ghijkl 2 mnopqr}
 
 
-ifcapable like_opt {
+ifcapable like_opt&&!icu {
   # Evaluate SQL.  Return the result set followed by the
   # and the number of full-scan steps.
   #
@@ -673,110 +673,110 @@
       regexp {INDEX i2} $res
     } {1}
   }
-}
-
-# Do an SQL statement.  Append the search count to the end of the result.
-#
-proc count sql {
-  set ::sqlite_search_count 0
-  set ::sqlite_like_count 0
-  return [concat [execsql $sql] scan $::sqlite_search_count \
-           like $::sqlite_like_count]
-}
 
-# The LIKE and GLOB optimizations do not work on columns with
-# affinity other than TEXT.
-# Ticket #3901
-#
-do_test like-10.1 {
-  db close
-  sqlite3 db test.db
-  execsql {
-    CREATE TABLE t10(
-      a INTEGER PRIMARY KEY,
-      b INTEGER COLLATE nocase UNIQUE,
-      c NUMBER COLLATE nocase UNIQUE,
-      d BLOB COLLATE nocase UNIQUE,
-      e COLLATE nocase UNIQUE,
-      f TEXT COLLATE nocase UNIQUE
-    );
-    INSERT INTO t10 VALUES(1,1,1,1,1,1);
-    INSERT INTO t10 VALUES(12,12,12,12,12,12);
-    INSERT INTO t10 VALUES(123,123,123,123,123,123);
-    INSERT INTO t10 VALUES(234,234,234,234,234,234);
-    INSERT INTO t10 VALUES(345,345,345,345,345,345);
-    INSERT INTO t10 VALUES(45,45,45,45,45,45);
-  }
-  count {
-    SELECT a FROM t10 WHERE b LIKE '12%' ORDER BY a;
-  }
-} {12 123 scan 5 like 6}
-do_test like-10.2 {
-  count {
-    SELECT a FROM t10 WHERE c LIKE '12%' ORDER BY a;
-  }
-} {12 123 scan 5 like 6}
-do_test like-10.3 {
-  count {
-    SELECT a FROM t10 WHERE d LIKE '12%' ORDER BY a;
-  }
-} {12 123 scan 5 like 6}
-do_test like-10.4 {
-  count {
-    SELECT a FROM t10 WHERE e LIKE '12%' ORDER BY a;
-  }
-} {12 123 scan 5 like 6}
-do_test like-10.5 {
-  count {
-    SELECT a FROM t10 WHERE f LIKE '12%' ORDER BY a;
-  }
-} {12 123 scan 3 like 0}
-do_test like-10.6 {
-  count {
-    SELECT a FROM t10 WHERE a LIKE '12%' ORDER BY a;
-  }
-} {12 123 scan 5 like 6}
-do_test like-10.10 {
-  execsql {
-    CREATE TABLE t10b(
-      a INTEGER PRIMARY KEY,
-      b INTEGER UNIQUE,
-      c NUMBER UNIQUE,
-      d BLOB UNIQUE,
-      e UNIQUE,
-      f TEXT UNIQUE
-    );
-    INSERT INTO t10b SELECT * FROM t10;
-  }
-  count {
-    SELECT a FROM t10b WHERE b GLOB '12*' ORDER BY a;
-  }
-} {12 123 scan 5 like 6}
-do_test like-10.11 {
-  count {
-    SELECT a FROM t10b WHERE c GLOB '12*' ORDER BY a;
-  }
-} {12 123 scan 5 like 6}
-do_test like-10.12 {
-  count {
-    SELECT a FROM t10b WHERE d GLOB '12*' ORDER BY a;
-  }
-} {12 123 scan 5 like 6}
-do_test like-10.13 {
-  count {
-    SELECT a FROM t10b WHERE e GLOB '12*' ORDER BY a;
-  }
-} {12 123 scan 5 like 6}
-do_test like-10.14 {
-  count {
-    SELECT a FROM t10b WHERE f GLOB '12*' ORDER BY a;
-  }
-} {12 123 scan 3 like 0}
-do_test like-10.15 {
-  count {
-    SELECT a FROM t10b WHERE a GLOB '12*' ORDER BY a;
+  # Do an SQL statement.  Append the search count to the end of the result.
+  #
+  proc count sql {
+    set ::sqlite_search_count 0
+    set ::sqlite_like_count 0
+    return [concat [execsql $sql] scan $::sqlite_search_count \
+             like $::sqlite_like_count]
   }
-} {12 123 scan 5 like 6}
+
+  # The LIKE and GLOB optimizations do not work on columns with
+  # affinity other than TEXT.
+  # Ticket #3901
+  #
+  do_test like-10.1 {
+    db close
+    sqlite3 db test.db
+    execsql {
+      CREATE TABLE t10(
+        a INTEGER PRIMARY KEY,
+        b INTEGER COLLATE nocase UNIQUE,
+        c NUMBER COLLATE nocase UNIQUE,
+        d BLOB COLLATE nocase UNIQUE,
+        e COLLATE nocase UNIQUE,
+        f TEXT COLLATE nocase UNIQUE
+      );
+      INSERT INTO t10 VALUES(1,1,1,1,1,1);
+      INSERT INTO t10 VALUES(12,12,12,12,12,12);
+      INSERT INTO t10 VALUES(123,123,123,123,123,123);
+      INSERT INTO t10 VALUES(234,234,234,234,234,234);
+      INSERT INTO t10 VALUES(345,345,345,345,345,345);
+      INSERT INTO t10 VALUES(45,45,45,45,45,45);
+    }
+    count {
+      SELECT a FROM t10 WHERE b LIKE '12%' ORDER BY a;
+    }
+  } {12 123 scan 5 like 6}
+  do_test like-10.2 {
+    count {
+      SELECT a FROM t10 WHERE c LIKE '12%' ORDER BY a;
+    }
+  } {12 123 scan 5 like 6}
+  do_test like-10.3 {
+    count {
+      SELECT a FROM t10 WHERE d LIKE '12%' ORDER BY a;
+    }
+  } {12 123 scan 5 like 6}
+  do_test like-10.4 {
+    count {
+      SELECT a FROM t10 WHERE e LIKE '12%' ORDER BY a;
+    }
+  } {12 123 scan 5 like 6}
+  do_test like-10.5 {
+    count {
+      SELECT a FROM t10 WHERE f LIKE '12%' ORDER BY a;
+    }
+  } {12 123 scan 3 like 0}
+  do_test like-10.6 {
+    count {
+      SELECT a FROM t10 WHERE a LIKE '12%' ORDER BY a;
+    }
+  } {12 123 scan 5 like 6}
+  do_test like-10.10 {
+    execsql {
+      CREATE TABLE t10b(
+        a INTEGER PRIMARY KEY,
+        b INTEGER UNIQUE,
+        c NUMBER UNIQUE,
+        d BLOB UNIQUE,
+        e UNIQUE,
+        f TEXT UNIQUE
+      );
+      INSERT INTO t10b SELECT * FROM t10;
+    }
+    count {
+      SELECT a FROM t10b WHERE b GLOB '12*' ORDER BY a;
+    }
+  } {12 123 scan 5 like 6}
+  do_test like-10.11 {
+    count {
+      SELECT a FROM t10b WHERE c GLOB '12*' ORDER BY a;
+    }
+  } {12 123 scan 5 like 6}
+  do_test like-10.12 {
+    count {
+      SELECT a FROM t10b WHERE d GLOB '12*' ORDER BY a;
+    }
+  } {12 123 scan 5 like 6}
+  do_test like-10.13 {
+    count {
+      SELECT a FROM t10b WHERE e GLOB '12*' ORDER BY a;
+    }
+  } {12 123 scan 5 like 6}
+  do_test like-10.14 {
+    count {
+      SELECT a FROM t10b WHERE f GLOB '12*' ORDER BY a;
+    }
+  } {12 123 scan 3 like 0}
+  do_test like-10.15 {
+    count {
+      SELECT a FROM t10b WHERE a GLOB '12*' ORDER BY a;
+    }
+  } {12 123 scan 5 like 6}
+}
 
 # LIKE and GLOB where the default collating sequence is not appropriate
 # but an index with the appropriate collating sequence exists.