aboutsummaryrefslogtreecommitdiffstats
path: root/yql/essentials/tests/postgresql/cases/text.err
blob: d41c3081bb28baf57bcefe8d1cd1b916599499e2 (plain) (blame)
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
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
<sql-statement>
--
-- TEXT
--
SELECT text 'this is a text string' = text 'this is a text string' AS true;
</sql-statement>
<sql-statement>
SELECT text 'this is a text string' = text 'this is a text strin' AS false;
</sql-statement>
<sql-statement>
CREATE TABLE TEXT_TBL (f1 text);
</sql-statement>
<sql-statement>
INSERT INTO TEXT_TBL VALUES ('doh!');
</sql-statement>
<sql-statement>
INSERT INTO TEXT_TBL VALUES ('hi de ho neighbor');
</sql-statement>
<sql-statement>
SELECT * FROM TEXT_TBL;
</sql-statement>
<sql-statement>
-- As of 8.3 we have removed most implicit casts to text, so that for example
-- this no longer works:
select length(42);
</sql-statement>
-stdin-:<main>: Error: Type annotation

    -stdin-:<main>:1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem, At function: PgResultItem
    	-- As of 8.3 we have removed most implicit casts to text, so that for example
	^
        -stdin-:<main>:3:8: Error: At function: PgCall
        	select length(42);
	       ^
            -stdin-:<main>:3:8: Error: Unable to find an overload for proc length with given argument types: (int4)
            	select length(42);
	       ^
<sql-statement>
-- But as a special exception for usability's sake, we still allow implicit
-- casting to text in concatenations, so long as the other input is text or
-- an unknown literal.  So these work:
select 'four: '::text || 2+2;
</sql-statement>
-stdin-:<main>: Error: Type annotation

    -stdin-:<main>:1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem, At function: PgResultItem
    	-- But as a special exception for usability's sake, we still allow implicit
	^
        -stdin-:<main>:4:23: Error: At function: PgOp
        	select 'four: '::text || 2+2;
	                      ^
            -stdin-:<main>:4:23: Error: Unable to find an overload for operator || with given argument type(s): (text,int4)
            	select 'four: '::text || 2+2;
	                      ^
<sql-statement>
select 'four: ' || 2+2;
</sql-statement>
-stdin-:<main>: Error: Type annotation

    -stdin-:<main>:1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem, At function: PgResultItem
    	select 'four: ' || 2+2;
	^
        -stdin-:<main>:1:17: Error: At function: PgOp
        	select 'four: ' || 2+2;
	                ^
            -stdin-:<main>:1:17: Error: Unable to find an overload for operator || with given argument type(s): (unknown,int4)
            	select 'four: ' || 2+2;
	                ^
<sql-statement>
-- but not this:
select 3 || 4.0;
</sql-statement>
-stdin-:<main>: Error: Type annotation

    -stdin-:<main>:1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem, At function: PgResultItem
    	-- but not this:
	^
        -stdin-:<main>:2:10: Error: At function: PgOp
        	select 3 || 4.0;
	         ^
            -stdin-:<main>:2:10: Error: Unable to find an overload for operator || with given argument type(s): (int4,numeric)
            	select 3 || 4.0;
	         ^
<sql-statement>
/*
 * various string functions
 */
select concat('one');
</sql-statement>
<sql-statement>
select concat(1,2,3,'hello',true, false, to_date('20100309','YYYYMMDD'));
</sql-statement>
<sql-statement>
select concat_ws('#','one');
</sql-statement>
<sql-statement>
select concat_ws('#',1,2,3,'hello',true, false, to_date('20100309','YYYYMMDD'));
</sql-statement>
<sql-statement>
select concat_ws(',',10,20,null,30);
</sql-statement>
<sql-statement>
select concat_ws('',10,20,null,30);
</sql-statement>
<sql-statement>
select concat_ws(NULL,10,20,null,30) is null;
</sql-statement>
<sql-statement>
select reverse('abcde');
</sql-statement>
<sql-statement>
select i, left('ahoj', i), right('ahoj', i) from generate_series(-5, 5) t(i) order by i;
</sql-statement>
<sql-statement>
select quote_literal('');
</sql-statement>
<sql-statement>
select quote_literal('abc''');
</sql-statement>
<sql-statement>
select quote_literal(e'\\');
</sql-statement>
<sql-statement>
-- check variadic labeled argument
select concat(variadic array[1,2,3]);
</sql-statement>
-stdin-:<main>: Error: Parse Sql

    -stdin-:<main>:2:8: Error: FuncCall: unsupported func_variadic
    	select concat(variadic array[1,2,3]);
	       ^
<sql-statement>
select concat_ws(',', variadic array[1,2,3]);
</sql-statement>
-stdin-:<main>: Error: Parse Sql

    -stdin-:<main>:1:8: Error: FuncCall: unsupported func_variadic
    	select concat_ws(',', variadic array[1,2,3]);
	       ^
<sql-statement>
select concat_ws(',', variadic NULL::int[]);
</sql-statement>
-stdin-:<main>: Error: Parse Sql

    -stdin-:<main>:1:8: Error: FuncCall: unsupported func_variadic
    	select concat_ws(',', variadic NULL::int[]);
	       ^
<sql-statement>
select concat(variadic NULL::int[]) is NULL;
</sql-statement>
-stdin-:<main>: Error: Parse Sql

    -stdin-:<main>:1:8: Error: FuncCall: unsupported func_variadic
    	select concat(variadic NULL::int[]) is NULL;
	       ^
<sql-statement>
select concat(variadic '{}'::int[]) = '';
</sql-statement>
-stdin-:<main>: Error: Parse Sql

    -stdin-:<main>:1:8: Error: FuncCall: unsupported func_variadic
    	select concat(variadic '{}'::int[]) = '';
	       ^
<sql-statement>
--should fail
select concat_ws(',', variadic 10);
</sql-statement>
-stdin-:<main>: Error: Parse Sql

    -stdin-:<main>:2:8: Error: FuncCall: unsupported func_variadic
    	select concat_ws(',', variadic 10);
	       ^
<sql-statement>
/*
 * format
 */
select format(NULL);
</sql-statement>
<sql-statement>
select format('Hello');
</sql-statement>
<sql-statement>
select format('Hello %s', 'World');
</sql-statement>
<sql-statement>
select format('Hello %%');
</sql-statement>
<sql-statement>
select format('Hello %%%%');
</sql-statement>
<sql-statement>
-- should fail
select format('Hello %s %s', 'World');
</sql-statement>
-stdin-:<main>: Fatal: Execution

    -stdin-:<main>:1:1: Fatal: Execution of node: Result
    	-- should fail
	^
        -stdin-:<main>:1:1: Fatal: ERROR:  too few arguments for format()

        	-- should fail
	^
<sql-statement>
select format('Hello %s');
</sql-statement>
-stdin-:<main>: Fatal: Execution

    -stdin-:<main>:1:1: Fatal: Execution of node: Result
    	select format('Hello %s');
	^
        -stdin-:<main>:1:1: Fatal: ERROR:  too few arguments for format()

        	select format('Hello %s');
	^
<sql-statement>
select format('Hello %x', 20);
</sql-statement>
-stdin-:<main>: Fatal: Execution

    -stdin-:<main>:1:1: Fatal: Execution of node: Result
    	select format('Hello %x', 20);
	^
        -stdin-:<main>:1:1: Fatal: ERROR:  unrecognized format() type specifier "x"
HINT:  For a single "%" use "%%".

        	select format('Hello %x', 20);
	^
<sql-statement>
-- check literal and sql identifiers
select format('INSERT INTO %I VALUES(%L,%L)', 'mytab', 10, 'Hello');
</sql-statement>
<sql-statement>
select format('%s%s%s','Hello', NULL,'World');
</sql-statement>
<sql-statement>
select format('INSERT INTO %I VALUES(%L,%L)', 'mytab', 10, NULL);
</sql-statement>
<sql-statement>
select format('INSERT INTO %I VALUES(%L,%L)', 'mytab', NULL, 'Hello');
</sql-statement>
<sql-statement>
-- should fail, sql identifier cannot be NULL
select format('INSERT INTO %I VALUES(%L,%L)', NULL, 10, 'Hello');
</sql-statement>
-stdin-:<main>: Fatal: Execution

    -stdin-:<main>:1:1: Fatal: Execution of node: Result
    	-- should fail, sql identifier cannot be NULL
	^
        -stdin-:<main>:1:1: Fatal: ERROR:  null values cannot be formatted as an SQL identifier

        	-- should fail, sql identifier cannot be NULL
	^
<sql-statement>
-- check positional placeholders
select format('%1$s %3$s', 1, 2, 3);
</sql-statement>
<sql-statement>
select format('%1$s %12$s', 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12);
</sql-statement>
<sql-statement>
-- should fail
select format('%1$s %4$s', 1, 2, 3);
</sql-statement>
-stdin-:<main>: Fatal: Execution

    -stdin-:<main>:1:1: Fatal: Execution of node: Result
    	-- should fail
	^
        -stdin-:<main>:1:1: Fatal: ERROR:  too few arguments for format()

        	-- should fail
	^
<sql-statement>
select format('%1$s %13$s', 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12);
</sql-statement>
-stdin-:<main>: Fatal: Execution

    -stdin-:<main>:1:1: Fatal: Execution of node: Result
    	select format('%1$s %13$s', 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12);
	^
        -stdin-:<main>:1:1: Fatal: ERROR:  too few arguments for format()

        	select format('%1$s %13$s', 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12);
	^
<sql-statement>
select format('%0$s', 'Hello');
</sql-statement>
-stdin-:<main>: Fatal: Execution

    -stdin-:<main>:1:1: Fatal: Execution of node: Result
    	select format('%0$s', 'Hello');
	^
        -stdin-:<main>:1:1: Fatal: ERROR:  format specifies argument 0, but arguments are numbered from 1

        	select format('%0$s', 'Hello');
	^
<sql-statement>
select format('%*0$s', 'Hello');
</sql-statement>
-stdin-:<main>: Fatal: Execution

    -stdin-:<main>:1:1: Fatal: Execution of node: Result
    	select format('%*0$s', 'Hello');
	^
        -stdin-:<main>:1:1: Fatal: ERROR:  format specifies argument 0, but arguments are numbered from 1

        	select format('%*0$s', 'Hello');
	^
<sql-statement>
select format('%1$', 1);
</sql-statement>
-stdin-:<main>: Fatal: Execution

    -stdin-:<main>:1:1: Fatal: Execution of node: Result
    	select format('%1$', 1);
	^
        -stdin-:<main>:1:1: Fatal: ERROR:  unterminated format() type specifier
HINT:  For a single "%" use "%%".

        	select format('%1$', 1);
	^
<sql-statement>
select format('%1$1', 1);
</sql-statement>
-stdin-:<main>: Fatal: Execution

    -stdin-:<main>:1:1: Fatal: Execution of node: Result
    	select format('%1$1', 1);
	^
        -stdin-:<main>:1:1: Fatal: ERROR:  unterminated format() type specifier
HINT:  For a single "%" use "%%".

        	select format('%1$1', 1);
	^
<sql-statement>
-- check mix of positional and ordered placeholders
select format('Hello %s %1$s %s', 'World', 'Hello again');
</sql-statement>
<sql-statement>
select format('Hello %s %s, %2$s %2$s', 'World', 'Hello again');
</sql-statement>
<sql-statement>
-- check variadic labeled arguments
select format('%s, %s', variadic array['Hello','World']);
</sql-statement>
-stdin-:<main>: Error: Parse Sql

    -stdin-:<main>:2:8: Error: FuncCall: unsupported func_variadic
    	select format('%s, %s', variadic array['Hello','World']);
	       ^
<sql-statement>
select format('%s, %s', variadic array[1, 2]);
</sql-statement>
-stdin-:<main>: Error: Parse Sql

    -stdin-:<main>:1:8: Error: FuncCall: unsupported func_variadic
    	select format('%s, %s', variadic array[1, 2]);
	       ^
<sql-statement>
select format('%s, %s', variadic array[true, false]);
</sql-statement>
-stdin-:<main>: Error: Parse Sql

    -stdin-:<main>:1:8: Error: FuncCall: unsupported func_variadic
    	select format('%s, %s', variadic array[true, false]);
	       ^
<sql-statement>
select format('%s, %s', variadic array[true, false]::text[]);
</sql-statement>
-stdin-:<main>: Error: Parse Sql

    -stdin-:<main>:1:8: Error: FuncCall: unsupported func_variadic
    	select format('%s, %s', variadic array[true, false]::text[]);
	       ^
<sql-statement>
-- check variadic with positional placeholders
select format('%2$s, %1$s', variadic array['first', 'second']);
</sql-statement>
-stdin-:<main>: Error: Parse Sql

    -stdin-:<main>:2:8: Error: FuncCall: unsupported func_variadic
    	select format('%2$s, %1$s', variadic array['first', 'second']);
	       ^
<sql-statement>
select format('%2$s, %1$s', variadic array[1, 2]);
</sql-statement>
-stdin-:<main>: Error: Parse Sql

    -stdin-:<main>:1:8: Error: FuncCall: unsupported func_variadic
    	select format('%2$s, %1$s', variadic array[1, 2]);
	       ^
<sql-statement>
-- variadic argument can be array type NULL, but should not be referenced
select format('Hello', variadic NULL::int[]);
</sql-statement>
-stdin-:<main>: Error: Parse Sql

    -stdin-:<main>:2:8: Error: FuncCall: unsupported func_variadic
    	select format('Hello', variadic NULL::int[]);
	       ^
<sql-statement>
-- variadic argument allows simulating more than FUNC_MAX_ARGS parameters
select format(string_agg('%s',','), variadic array_agg(i))
from generate_series(1,200) g(i);
</sql-statement>
-stdin-:<main>: Error: Parse Sql

    -stdin-:<main>:2:8: Error: FuncCall: unsupported func_variadic
    	select format(string_agg('%s',','), variadic array_agg(i))
	       ^
<sql-statement>
-- check field widths and left, right alignment
select format('>>%10s<<', 'Hello');
</sql-statement>
<sql-statement>
select format('>>%10s<<', NULL);
</sql-statement>
<sql-statement>
select format('>>%10s<<', '');
</sql-statement>
<sql-statement>
select format('>>%-10s<<', '');
</sql-statement>
<sql-statement>
select format('>>%-10s<<', 'Hello');
</sql-statement>
<sql-statement>
select format('>>%-10s<<', NULL);
</sql-statement>
<sql-statement>
select format('>>%1$10s<<', 'Hello');
</sql-statement>
<sql-statement>
select format('>>%1$-10I<<', 'Hello');
</sql-statement>
<sql-statement>
select format('>>%2$*1$L<<', 10, 'Hello');
</sql-statement>
<sql-statement>
select format('>>%2$*1$L<<', 10, NULL);
</sql-statement>
<sql-statement>
select format('>>%2$*1$L<<', -10, NULL);
</sql-statement>
<sql-statement>
select format('>>%*s<<', 10, 'Hello');
</sql-statement>
<sql-statement>
select format('>>%*1$s<<', 10, 'Hello');
</sql-statement>
<sql-statement>
select format('>>%-s<<', 'Hello');
</sql-statement>
<sql-statement>
select format('>>%10L<<', NULL);
</sql-statement>
<sql-statement>
select format('>>%2$*1$L<<', NULL, 'Hello');
</sql-statement>
<sql-statement>
select format('>>%2$*1$L<<', 0, 'Hello');
</sql-statement>