| 1 |
CREATE EXTENSION intarray; |
| 2 |
-- Check whether any of our opclasses fail amvalidate |
| 3 |
SELECT amname, opcname |
| 4 |
FROM pg_opclass opc LEFT JOIN pg_am am ON am.oid = opcmethod |
| 5 |
WHERE opc.oid >= 16384 AND NOT amvalidate(opc.oid); |
| 6 |
amname | opcname |
| 7 |
--------+--------- |
| 8 |
(0 rows) |
| 9 |
|
| 10 |
SELECT intset(1234); |
| 11 |
intset |
| 12 |
-------- |
| 13 |
{1234} |
| 14 |
(1 row) |
| 15 |
|
| 16 |
SELECT icount('{1234234,234234}'); |
| 17 |
icount |
| 18 |
-------- |
| 19 |
2 |
| 20 |
(1 row) |
| 21 |
|
| 22 |
SELECT sort('{1234234,-30,234234}'); |
| 23 |
sort |
| 24 |
---------------------- |
| 25 |
{-30,234234,1234234} |
| 26 |
(1 row) |
| 27 |
|
| 28 |
SELECT sort('{1234234,-30,234234}','asc'); |
| 29 |
sort |
| 30 |
---------------------- |
| 31 |
{-30,234234,1234234} |
| 32 |
(1 row) |
| 33 |
|
| 34 |
SELECT sort('{1234234,-30,234234}','desc'); |
| 35 |
sort |
| 36 |
---------------------- |
| 37 |
{1234234,234234,-30} |
| 38 |
(1 row) |
| 39 |
|
| 40 |
SELECT sort_asc('{1234234,-30,234234}'); |
| 41 |
sort_asc |
| 42 |
---------------------- |
| 43 |
{-30,234234,1234234} |
| 44 |
(1 row) |
| 45 |
|
| 46 |
SELECT sort_desc('{1234234,-30,234234}'); |
| 47 |
sort_desc |
| 48 |
---------------------- |
| 49 |
{1234234,234234,-30} |
| 50 |
(1 row) |
| 51 |
|
| 52 |
SELECT uniq('{1234234,-30,-30,234234,-30}'); |
| 53 |
uniq |
| 54 |
-------------------------- |
| 55 |
{1234234,-30,234234,-30} |
| 56 |
(1 row) |
| 57 |
|
| 58 |
SELECT uniq(sort_asc('{1234234,-30,-30,234234,-30}')); |
| 59 |
uniq |
| 60 |
---------------------- |
| 61 |
{-30,234234,1234234} |
| 62 |
(1 row) |
| 63 |
|
| 64 |
SELECT idx('{1234234,-30,-30,234234,-30}',-30); |
| 65 |
idx |
| 66 |
----- |
| 67 |
2 |
| 68 |
(1 row) |
| 69 |
|
| 70 |
SELECT subarray('{1234234,-30,-30,234234,-30}',2,3); |
| 71 |
subarray |
| 72 |
------------------ |
| 73 |
{-30,-30,234234} |
| 74 |
(1 row) |
| 75 |
|
| 76 |
SELECT subarray('{1234234,-30,-30,234234,-30}',-1,1); |
| 77 |
subarray |
| 78 |
---------- |
| 79 |
{-30} |
| 80 |
(1 row) |
| 81 |
|
| 82 |
SELECT subarray('{1234234,-30,-30,234234,-30}',0,-1); |
| 83 |
subarray |
| 84 |
-------------------------- |
| 85 |
{1234234,-30,-30,234234} |
| 86 |
(1 row) |
| 87 |
|
| 88 |
SELECT #'{1234234,234234}'::int[]; |
| 89 |
?column? |
| 90 |
---------- |
| 91 |
2 |
| 92 |
(1 row) |
| 93 |
|
| 94 |
SELECT '{123,623,445}'::int[] + 1245; |
| 95 |
?column? |
| 96 |
-------------------- |
| 97 |
{123,623,445,1245} |
| 98 |
(1 row) |
| 99 |
|
| 100 |
SELECT '{123,623,445}'::int[] + 445; |
| 101 |
?column? |
| 102 |
------------------- |
| 103 |
{123,623,445,445} |
| 104 |
(1 row) |
| 105 |
|
| 106 |
SELECT '{123,623,445}'::int[] + '{1245,87,445}'; |
| 107 |
?column? |
| 108 |
--------------------------- |
| 109 |
{123,623,445,1245,87,445} |
| 110 |
(1 row) |
| 111 |
|
| 112 |
SELECT '{123,623,445}'::int[] - 623; |
| 113 |
?column? |
| 114 |
----------- |
| 115 |
{123,445} |
| 116 |
(1 row) |
| 117 |
|
| 118 |
SELECT '{123,623,445}'::int[] - '{1623,623}'; |
| 119 |
?column? |
| 120 |
----------- |
| 121 |
{123,445} |
| 122 |
(1 row) |
| 123 |
|
| 124 |
SELECT '{123,623,445}'::int[] | 623; |
| 125 |
?column? |
| 126 |
--------------- |
| 127 |
{123,445,623} |
| 128 |
(1 row) |
| 129 |
|
| 130 |
SELECT '{123,623,445}'::int[] | 1623; |
| 131 |
?column? |
| 132 |
-------------------- |
| 133 |
{123,445,623,1623} |
| 134 |
(1 row) |
| 135 |
|
| 136 |
SELECT '{123,623,445}'::int[] | '{1623,623}'; |
| 137 |
?column? |
| 138 |
-------------------- |
| 139 |
{123,445,623,1623} |
| 140 |
(1 row) |
| 141 |
|
| 142 |
SELECT '{123,623,445}'::int[] & '{1623,623}'; |
| 143 |
?column? |
| 144 |
---------- |
| 145 |
{623} |
| 146 |
(1 row) |
| 147 |
|
| 148 |
SELECT '{-1,3,1}'::int[] & '{1,2}'; |
| 149 |
?column? |
| 150 |
---------- |
| 151 |
{1} |
| 152 |
(1 row) |
| 153 |
|
| 154 |
SELECT '{1}'::int[] & '{2}'::int[]; |
| 155 |
?column? |
| 156 |
---------- |
| 157 |
{} |
| 158 |
(1 row) |
| 159 |
|
| 160 |
SELECT array_dims('{1}'::int[] & '{2}'::int[]); |
| 161 |
array_dims |
| 162 |
------------ |
| 163 |
|
| 164 |
(1 row) |
| 165 |
|
| 166 |
SELECT ('{1}'::int[] & '{2}'::int[]) = '{}'::int[]; |
| 167 |
?column? |
| 168 |
---------- |
| 169 |
t |
| 170 |
(1 row) |
| 171 |
|
| 172 |
SELECT ('{}'::int[] & '{}'::int[]) = '{}'::int[]; |
| 173 |
?column? |
| 174 |
---------- |
| 175 |
t |
| 176 |
(1 row) |
| 177 |
|
| 178 |
--test query_int |
| 179 |
SELECT '1'::query_int; |
| 180 |
query_int |
| 181 |
----------- |
| 182 |
1 |
| 183 |
(1 row) |
| 184 |
|
| 185 |
SELECT ' 1'::query_int; |
| 186 |
query_int |
| 187 |
----------- |
| 188 |
1 |
| 189 |
(1 row) |
| 190 |
|
| 191 |
SELECT '1 '::query_int; |
| 192 |
query_int |
| 193 |
----------- |
| 194 |
1 |
| 195 |
(1 row) |
| 196 |
|
| 197 |
SELECT ' 1 '::query_int; |
| 198 |
query_int |
| 199 |
----------- |
| 200 |
1 |
| 201 |
(1 row) |
| 202 |
|
| 203 |
SELECT ' ! 1 '::query_int; |
| 204 |
query_int |
| 205 |
----------- |
| 206 |
!1 |
| 207 |
(1 row) |
| 208 |
|
| 209 |
SELECT '!1'::query_int; |
| 210 |
query_int |
| 211 |
----------- |
| 212 |
!1 |
| 213 |
(1 row) |
| 214 |
|
| 215 |
SELECT '1|2'::query_int; |
| 216 |
query_int |
| 217 |
----------- |
| 218 |
1 | 2 |
| 219 |
(1 row) |
| 220 |
|
| 221 |
SELECT '1|!2'::query_int; |
| 222 |
query_int |
| 223 |
----------- |
| 224 |
1 | !2 |
| 225 |
(1 row) |
| 226 |
|
| 227 |
SELECT '!1|2'::query_int; |
| 228 |
query_int |
| 229 |
----------- |
| 230 |
!1 | 2 |
| 231 |
(1 row) |
| 232 |
|
| 233 |
SELECT '!1|!2'::query_int; |
| 234 |
query_int |
| 235 |
----------- |
| 236 |
!1 | !2 |
| 237 |
(1 row) |
| 238 |
|
| 239 |
SELECT '!(!1|!2)'::query_int; |
| 240 |
query_int |
| 241 |
-------------- |
| 242 |
!( !1 | !2 ) |
| 243 |
(1 row) |
| 244 |
|
| 245 |
SELECT '!(!1|2)'::query_int; |
| 246 |
query_int |
| 247 |
------------- |
| 248 |
!( !1 | 2 ) |
| 249 |
(1 row) |
| 250 |
|
| 251 |
SELECT '!(1|!2)'::query_int; |
| 252 |
query_int |
| 253 |
------------- |
| 254 |
!( 1 | !2 ) |
| 255 |
(1 row) |
| 256 |
|
| 257 |
SELECT '!(1|2)'::query_int; |
| 258 |
query_int |
| 259 |
------------ |
| 260 |
!( 1 | 2 ) |
| 261 |
(1 row) |
| 262 |
|
| 263 |
SELECT '1&2'::query_int; |
| 264 |
query_int |
| 265 |
----------- |
| 266 |
1 & 2 |
| 267 |
(1 row) |
| 268 |
|
| 269 |
SELECT '!1&2'::query_int; |
| 270 |
query_int |
| 271 |
----------- |
| 272 |
!1 & 2 |
| 273 |
(1 row) |
| 274 |
|
| 275 |
SELECT '1&!2'::query_int; |
| 276 |
query_int |
| 277 |
----------- |
| 278 |
1 & !2 |
| 279 |
(1 row) |
| 280 |
|
| 281 |
SELECT '!1&!2'::query_int; |
| 282 |
query_int |
| 283 |
----------- |
| 284 |
!1 & !2 |
| 285 |
(1 row) |
| 286 |
|
| 287 |
SELECT '(1&2)'::query_int; |
| 288 |
query_int |
| 289 |
----------- |
| 290 |
1 & 2 |
| 291 |
(1 row) |
| 292 |
|
| 293 |
SELECT '1&(2)'::query_int; |
| 294 |
query_int |
| 295 |
----------- |
| 296 |
1 & 2 |
| 297 |
(1 row) |
| 298 |
|
| 299 |
SELECT '!(1)&2'::query_int; |
| 300 |
query_int |
| 301 |
----------- |
| 302 |
!1 & 2 |
| 303 |
(1 row) |
| 304 |
|
| 305 |
SELECT '!(1&2)'::query_int; |
| 306 |
query_int |
| 307 |
------------ |
| 308 |
!( 1 & 2 ) |
| 309 |
(1 row) |
| 310 |
|
| 311 |
SELECT '1|2&3'::query_int; |
| 312 |
query_int |
| 313 |
----------- |
| 314 |
1 | 2 & 3 |
| 315 |
(1 row) |
| 316 |
|
| 317 |
SELECT '1|(2&3)'::query_int; |
| 318 |
query_int |
| 319 |
----------- |
| 320 |
1 | 2 & 3 |
| 321 |
(1 row) |
| 322 |
|
| 323 |
SELECT '(1|2)&3'::query_int; |
| 324 |
query_int |
| 325 |
--------------- |
| 326 |
( 1 | 2 ) & 3 |
| 327 |
(1 row) |
| 328 |
|
| 329 |
SELECT '1|2&!3'::query_int; |
| 330 |
query_int |
| 331 |
------------ |
| 332 |
1 | 2 & !3 |
| 333 |
(1 row) |
| 334 |
|
| 335 |
SELECT '1|!2&3'::query_int; |
| 336 |
query_int |
| 337 |
------------ |
| 338 |
1 | !2 & 3 |
| 339 |
(1 row) |
| 340 |
|
| 341 |
SELECT '!1|2&3'::query_int; |
| 342 |
query_int |
| 343 |
------------ |
| 344 |
!1 | 2 & 3 |
| 345 |
(1 row) |
| 346 |
|
| 347 |
SELECT '!1|(2&3)'::query_int; |
| 348 |
query_int |
| 349 |
------------ |
| 350 |
!1 | 2 & 3 |
| 351 |
(1 row) |
| 352 |
|
| 353 |
SELECT '!(1|2)&3'::query_int; |
| 354 |
query_int |
| 355 |
---------------- |
| 356 |
!( 1 | 2 ) & 3 |
| 357 |
(1 row) |
| 358 |
|
| 359 |
SELECT '(!1|2)&3'::query_int; |
| 360 |
query_int |
| 361 |
---------------- |
| 362 |
( !1 | 2 ) & 3 |
| 363 |
(1 row) |
| 364 |
|
| 365 |
SELECT '1|(2|(4|(5|6)))'::query_int; |
| 366 |
query_int |
| 367 |
------------------------------- |
| 368 |
1 | ( 2 | ( 4 | ( 5 | 6 ) ) ) |
| 369 |
(1 row) |
| 370 |
|
| 371 |
SELECT '1|2|4|5|6'::query_int; |
| 372 |
query_int |
| 373 |
------------------------------- |
| 374 |
( ( ( 1 | 2 ) | 4 ) | 5 ) | 6 |
| 375 |
(1 row) |
| 376 |
|
| 377 |
SELECT '1&(2&(4&(5&6)))'::query_int; |
| 378 |
query_int |
| 379 |
------------------- |
| 380 |
1 & 2 & 4 & 5 & 6 |
| 381 |
(1 row) |
| 382 |
|
| 383 |
SELECT '1&2&4&5&6'::query_int; |
| 384 |
query_int |
| 385 |
------------------- |
| 386 |
1 & 2 & 4 & 5 & 6 |
| 387 |
(1 row) |
| 388 |
|
| 389 |
SELECT '1&(2&(4&(5|6)))'::query_int; |
| 390 |
query_int |
| 391 |
----------------------- |
| 392 |
1 & 2 & 4 & ( 5 | 6 ) |
| 393 |
(1 row) |
| 394 |
|
| 395 |
SELECT '1&(2&(4&(5|!6)))'::query_int; |
| 396 |
query_int |
| 397 |
------------------------ |
| 398 |
1 & 2 & 4 & ( 5 | !6 ) |
| 399 |
(1 row) |
| 400 |
|
| 401 |
-- Test for overflow of the int16 "left" field in findoprnd(). |
| 402 |
-- This query uses a balanced binary tree to avoid using too much stack. |
| 403 |
DO $$ |
| 404 |
DECLARE |
| 405 |
e text := '1'; |
| 406 |
BEGIN |
| 407 |
FOR i IN 1..15 LOOP |
| 408 |
e := '(' || e || '&' || e || ')'; |
| 409 |
END LOOP; |
| 410 |
PERFORM ('0|' || e)::query_int; |
| 411 |
END; |
| 412 |
$$; |
| 413 |
ERROR: query_int expression is too complex |
| 414 |
CONTEXT: SQL statement "SELECT ('0|' || e)::query_int" |
| 415 |
PL/pgSQL function inline_code_block line 8 at PERFORM |
| 416 |
-- test non-error-throwing input |
| 417 |
SELECT str as "query_int", |
| 418 |
pg_input_is_valid(str,'query_int') as ok, |
| 419 |
errinfo.sql_error_code, |
| 420 |
errinfo.message, |
| 421 |
errinfo.detail, |
| 422 |
errinfo.hint |
| 423 |
FROM (VALUES ('1&(2&(4&(5|6)))'), |
| 424 |
('1#(2&(4&(5&6)))'), |
| 425 |
('foo')) |
| 426 |
AS a(str), |
| 427 |
LATERAL pg_input_error_info(a.str, 'query_int') as errinfo; |
| 428 |
query_int | ok | sql_error_code | message | detail | hint |
| 429 |
-----------------+----+----------------+--------------+--------+------ |
| 430 |
1&(2&(4&(5|6))) | t | | | | |
| 431 |
1#(2&(4&(5&6))) | f | 42601 | syntax error | | |
| 432 |
foo | f | 42601 | syntax error | | |
| 433 |
(3 rows) |
| 434 |
|
| 435 |
CREATE TABLE test__int( a int[] ); |
| 436 |
\copy test__int from 'data/test__int.data' |
| 437 |
ANALYZE test__int; |
| 438 |
SELECT count(*) from test__int WHERE a && '{23,50}'; |
| 439 |
count |
| 440 |
------- |
| 441 |
403 |
| 442 |
(1 row) |
| 443 |
|
| 444 |
SELECT count(*) from test__int WHERE a @@ '23|50'; |
| 445 |
count |
| 446 |
------- |
| 447 |
403 |
| 448 |
(1 row) |
| 449 |
|
| 450 |
SELECT count(*) from test__int WHERE a @> '{23,50}'; |
| 451 |
count |
| 452 |
------- |
| 453 |
12 |
| 454 |
(1 row) |
| 455 |
|
| 456 |
SELECT count(*) from test__int WHERE a @@ '23&50'; |
| 457 |
count |
| 458 |
------- |
| 459 |
12 |
| 460 |
(1 row) |
| 461 |
|
| 462 |
SELECT count(*) from test__int WHERE a @> '{20,23}'; |
| 463 |
count |
| 464 |
------- |
| 465 |
12 |
| 466 |
(1 row) |
| 467 |
|
| 468 |
SELECT count(*) from test__int WHERE a <@ '{73,23,20}'; |
| 469 |
count |
| 470 |
------- |
| 471 |
10 |
| 472 |
(1 row) |
| 473 |
|
| 474 |
SELECT count(*) from test__int WHERE a = '{73,23,20}'; |
| 475 |
count |
| 476 |
------- |
| 477 |
1 |
| 478 |
(1 row) |
| 479 |
|
| 480 |
SELECT count(*) from test__int WHERE a @@ '50&68'; |
| 481 |
count |
| 482 |
------- |
| 483 |
9 |
| 484 |
(1 row) |
| 485 |
|
| 486 |
SELECT count(*) from test__int WHERE a @> '{20,23}' or a @> '{50,68}'; |
| 487 |
count |
| 488 |
------- |
| 489 |
21 |
| 490 |
(1 row) |
| 491 |
|
| 492 |
SELECT count(*) from test__int WHERE a @@ '(20&23)|(50&68)'; |
| 493 |
count |
| 494 |
------- |
| 495 |
21 |
| 496 |
(1 row) |
| 497 |
|
| 498 |
SELECT count(*) from test__int WHERE a @@ '20 | !21'; |
| 499 |
count |
| 500 |
------- |
| 501 |
6567 |
| 502 |
(1 row) |
| 503 |
|
| 504 |
SELECT count(*) from test__int WHERE a @@ '!20 & !21'; |
| 505 |
count |
| 506 |
------- |
| 507 |
6344 |
| 508 |
(1 row) |
| 509 |
|
| 510 |
SELECT count(*) from test__int WHERE a @@ '!2733 & (2738 | 254)'; |
| 511 |
count |
| 512 |
------- |
| 513 |
12 |
| 514 |
(1 row) |
| 515 |
|
| 516 |
SET enable_seqscan = off; -- not all of these would use index by default |
| 517 |
CREATE INDEX text_idx on test__int using gist ( a gist__int_ops ); |
| 518 |
SELECT count(*) from test__int WHERE a && '{23,50}'; |
| 519 |
count |
| 520 |
------- |
| 521 |
403 |
| 522 |
(1 row) |
| 523 |
|
| 524 |
SELECT count(*) from test__int WHERE a @@ '23|50'; |
| 525 |
count |
| 526 |
------- |
| 527 |
403 |
| 528 |
(1 row) |
| 529 |
|
| 530 |
SELECT count(*) from test__int WHERE a @> '{23,50}'; |
| 531 |
count |
| 532 |
------- |
| 533 |
12 |
| 534 |
(1 row) |
| 535 |
|
| 536 |
SELECT count(*) from test__int WHERE a @@ '23&50'; |
| 537 |
count |
| 538 |
------- |
| 539 |
12 |
| 540 |
(1 row) |
| 541 |
|
| 542 |
SELECT count(*) from test__int WHERE a @> '{20,23}'; |
| 543 |
count |
| 544 |
------- |
| 545 |
12 |
| 546 |
(1 row) |
| 547 |
|
| 548 |
SELECT count(*) from test__int WHERE a <@ '{73,23,20}'; |
| 549 |
count |
| 550 |
------- |
| 551 |
10 |
| 552 |
(1 row) |
| 553 |
|
| 554 |
SELECT count(*) from test__int WHERE a = '{73,23,20}'; |
| 555 |
count |
| 556 |
------- |
| 557 |
1 |
| 558 |
(1 row) |
| 559 |
|
| 560 |
SELECT count(*) from test__int WHERE a @@ '50&68'; |
| 561 |
count |
| 562 |
------- |
| 563 |
9 |
| 564 |
(1 row) |
| 565 |
|
| 566 |
SELECT count(*) from test__int WHERE a @> '{20,23}' or a @> '{50,68}'; |
| 567 |
count |
| 568 |
------- |
| 569 |
21 |
| 570 |
(1 row) |
| 571 |
|
| 572 |
SELECT count(*) from test__int WHERE a @@ '(20&23)|(50&68)'; |
| 573 |
count |
| 574 |
------- |
| 575 |
21 |
| 576 |
(1 row) |
| 577 |
|
| 578 |
SELECT count(*) from test__int WHERE a @@ '20 | !21'; |
| 579 |
count |
| 580 |
------- |
| 581 |
6567 |
| 582 |
(1 row) |
| 583 |
|
| 584 |
SELECT count(*) from test__int WHERE a @@ '!20 & !21'; |
| 585 |
count |
| 586 |
------- |
| 587 |
6344 |
| 588 |
(1 row) |
| 589 |
|
| 590 |
SELECT count(*) from test__int WHERE a @@ '!2733 & (2738 | 254)'; |
| 591 |
count |
| 592 |
------- |
| 593 |
12 |
| 594 |
(1 row) |
| 595 |
|
| 596 |
INSERT INTO test__int SELECT array(SELECT x FROM generate_series(1, 1001) x); -- should fail |
| 597 |
ERROR: input array is too big (199 maximum allowed, 1001 current), use gist__intbig_ops opclass instead |
| 598 |
DROP INDEX text_idx; |
| 599 |
CREATE INDEX text_idx on test__int using gist (a gist__int_ops(numranges = 0)); |
| 600 |
ERROR: value 0 out of bounds for option "numranges" |
| 601 |
DETAIL: Valid values are between "1" and "252". |
| 602 |
CREATE INDEX text_idx on test__int using gist (a gist__int_ops(numranges = 253)); |
| 603 |
ERROR: value 253 out of bounds for option "numranges" |
| 604 |
DETAIL: Valid values are between "1" and "252". |
| 605 |
CREATE INDEX text_idx on test__int using gist (a gist__int_ops(numranges = 252)); |
| 606 |
SELECT count(*) from test__int WHERE a && '{23,50}'; |
| 607 |
count |
| 608 |
------- |
| 609 |
403 |
| 610 |
(1 row) |
| 611 |
|
| 612 |
SELECT count(*) from test__int WHERE a @@ '23|50'; |
| 613 |
count |
| 614 |
------- |
| 615 |
403 |
| 616 |
(1 row) |
| 617 |
|
| 618 |
SELECT count(*) from test__int WHERE a @> '{23,50}'; |
| 619 |
count |
| 620 |
------- |
| 621 |
12 |
| 622 |
(1 row) |
| 623 |
|
| 624 |
SELECT count(*) from test__int WHERE a @@ '23&50'; |
| 625 |
count |
| 626 |
------- |
| 627 |
12 |
| 628 |
(1 row) |
| 629 |
|
| 630 |
SELECT count(*) from test__int WHERE a @> '{20,23}'; |
| 631 |
count |
| 632 |
------- |
| 633 |
12 |
| 634 |
(1 row) |
| 635 |
|
| 636 |
SELECT count(*) from test__int WHERE a <@ '{73,23,20}'; |
| 637 |
count |
| 638 |
------- |
| 639 |
10 |
| 640 |
(1 row) |
| 641 |
|
| 642 |
SELECT count(*) from test__int WHERE a = '{73,23,20}'; |
| 643 |
count |
| 644 |
------- |
| 645 |
1 |
| 646 |
(1 row) |
| 647 |
|
| 648 |
SELECT count(*) from test__int WHERE a @@ '50&68'; |
| 649 |
count |
| 650 |
------- |
| 651 |
9 |
| 652 |
(1 row) |
| 653 |
|
| 654 |
SELECT count(*) from test__int WHERE a @> '{20,23}' or a @> '{50,68}'; |
| 655 |
count |
| 656 |
------- |
| 657 |
21 |
| 658 |
(1 row) |
| 659 |
|
| 660 |
SELECT count(*) from test__int WHERE a @@ '(20&23)|(50&68)'; |
| 661 |
count |
| 662 |
------- |
| 663 |
21 |
| 664 |
(1 row) |
| 665 |
|
| 666 |
SELECT count(*) from test__int WHERE a @@ '20 | !21'; |
| 667 |
count |
| 668 |
------- |
| 669 |
6567 |
| 670 |
(1 row) |
| 671 |
|
| 672 |
SELECT count(*) from test__int WHERE a @@ '!20 & !21'; |
| 673 |
count |
| 674 |
------- |
| 675 |
6344 |
| 676 |
(1 row) |
| 677 |
|
| 678 |
SELECT count(*) from test__int WHERE a @@ '!2733 & (2738 | 254)'; |
| 679 |
count |
| 680 |
------- |
| 681 |
12 |
| 682 |
(1 row) |
| 683 |
|
| 684 |
DROP INDEX text_idx; |
| 685 |
CREATE INDEX text_idx on test__int using gist (a gist__intbig_ops(siglen = 0)); |
| 686 |
ERROR: value 0 out of bounds for option "siglen" |
| 687 |
DETAIL: Valid values are between "1" and "2024". |
| 688 |
CREATE INDEX text_idx on test__int using gist (a gist__intbig_ops(siglen = 2025)); |
| 689 |
ERROR: value 2025 out of bounds for option "siglen" |
| 690 |
DETAIL: Valid values are between "1" and "2024". |
| 691 |
CREATE INDEX text_idx on test__int using gist (a gist__intbig_ops(siglen = 2024)); |
| 692 |
SELECT count(*) from test__int WHERE a && '{23,50}'; |
| 693 |
count |
| 694 |
------- |
| 695 |
403 |
| 696 |
(1 row) |
| 697 |
|
| 698 |
SELECT count(*) from test__int WHERE a @@ '23|50'; |
| 699 |
count |
| 700 |
------- |
| 701 |
403 |
| 702 |
(1 row) |
| 703 |
|
| 704 |
SELECT count(*) from test__int WHERE a @> '{23,50}'; |
| 705 |
count |
| 706 |
------- |
| 707 |
12 |
| 708 |
(1 row) |
| 709 |
|
| 710 |
SELECT count(*) from test__int WHERE a @@ '23&50'; |
| 711 |
count |
| 712 |
------- |
| 713 |
12 |
| 714 |
(1 row) |
| 715 |
|
| 716 |
SELECT count(*) from test__int WHERE a @> '{20,23}'; |
| 717 |
count |
| 718 |
------- |
| 719 |
12 |
| 720 |
(1 row) |
| 721 |
|
| 722 |
SELECT count(*) from test__int WHERE a <@ '{73,23,20}'; |
| 723 |
count |
| 724 |
------- |
| 725 |
10 |
| 726 |
(1 row) |
| 727 |
|
| 728 |
SELECT count(*) from test__int WHERE a = '{73,23,20}'; |
| 729 |
count |
| 730 |
------- |
| 731 |
1 |
| 732 |
(1 row) |
| 733 |
|
| 734 |
SELECT count(*) from test__int WHERE a @@ '50&68'; |
| 735 |
count |
| 736 |
------- |
| 737 |
9 |
| 738 |
(1 row) |
| 739 |
|
| 740 |
SELECT count(*) from test__int WHERE a @> '{20,23}' or a @> '{50,68}'; |
| 741 |
count |
| 742 |
------- |
| 743 |
21 |
| 744 |
(1 row) |
| 745 |
|
| 746 |
SELECT count(*) from test__int WHERE a @@ '(20&23)|(50&68)'; |
| 747 |
count |
| 748 |
------- |
| 749 |
21 |
| 750 |
(1 row) |
| 751 |
|
| 752 |
SELECT count(*) from test__int WHERE a @@ '20 | !21'; |
| 753 |
count |
| 754 |
------- |
| 755 |
6567 |
| 756 |
(1 row) |
| 757 |
|
| 758 |
SELECT count(*) from test__int WHERE a @@ '!20 & !21'; |
| 759 |
count |
| 760 |
------- |
| 761 |
6344 |
| 762 |
(1 row) |
| 763 |
|
| 764 |
SELECT count(*) from test__int WHERE a @@ '!2733 & (2738 | 254)'; |
| 765 |
count |
| 766 |
------- |
| 767 |
12 |
| 768 |
(1 row) |
| 769 |
|
| 770 |
DROP INDEX text_idx; |
| 771 |
CREATE INDEX text_idx on test__int using gist ( a gist__intbig_ops ); |
| 772 |
SELECT count(*) from test__int WHERE a && '{23,50}'; |
| 773 |
count |
| 774 |
------- |
| 775 |
403 |
| 776 |
(1 row) |
| 777 |
|
| 778 |
SELECT count(*) from test__int WHERE a @@ '23|50'; |
| 779 |
count |
| 780 |
------- |
| 781 |
403 |
| 782 |
(1 row) |
| 783 |
|
| 784 |
SELECT count(*) from test__int WHERE a @> '{23,50}'; |
| 785 |
count |
| 786 |
------- |
| 787 |
12 |
| 788 |
(1 row) |
| 789 |
|
| 790 |
SELECT count(*) from test__int WHERE a @@ '23&50'; |
| 791 |
count |
| 792 |
------- |
| 793 |
12 |
| 794 |
(1 row) |
| 795 |
|
| 796 |
SELECT count(*) from test__int WHERE a @> '{20,23}'; |
| 797 |
count |
| 798 |
------- |
| 799 |
12 |
| 800 |
(1 row) |
| 801 |
|
| 802 |
SELECT count(*) from test__int WHERE a <@ '{73,23,20}'; |
| 803 |
count |
| 804 |
------- |
| 805 |
10 |
| 806 |
(1 row) |
| 807 |
|
| 808 |
SELECT count(*) from test__int WHERE a = '{73,23,20}'; |
| 809 |
count |
| 810 |
------- |
| 811 |
1 |
| 812 |
(1 row) |
| 813 |
|
| 814 |
SELECT count(*) from test__int WHERE a @@ '50&68'; |
| 815 |
count |
| 816 |
------- |
| 817 |
9 |
| 818 |
(1 row) |
| 819 |
|
| 820 |
SELECT count(*) from test__int WHERE a @> '{20,23}' or a @> '{50,68}'; |
| 821 |
count |
| 822 |
------- |
| 823 |
21 |
| 824 |
(1 row) |
| 825 |
|
| 826 |
SELECT count(*) from test__int WHERE a @@ '(20&23)|(50&68)'; |
| 827 |
count |
| 828 |
------- |
| 829 |
21 |
| 830 |
(1 row) |
| 831 |
|
| 832 |
SELECT count(*) from test__int WHERE a @@ '20 | !21'; |
| 833 |
count |
| 834 |
------- |
| 835 |
6567 |
| 836 |
(1 row) |
| 837 |
|
| 838 |
SELECT count(*) from test__int WHERE a @@ '!20 & !21'; |
| 839 |
count |
| 840 |
------- |
| 841 |
6344 |
| 842 |
(1 row) |
| 843 |
|
| 844 |
SELECT count(*) from test__int WHERE a @@ '!2733 & (2738 | 254)'; |
| 845 |
count |
| 846 |
------- |
| 847 |
12 |
| 848 |
(1 row) |
| 849 |
|
| 850 |
DROP INDEX text_idx; |
| 851 |
CREATE INDEX text_idx on test__int using gin ( a gin__int_ops ); |
| 852 |
SELECT count(*) from test__int WHERE a && '{23,50}'; |
| 853 |
count |
| 854 |
------- |
| 855 |
403 |
| 856 |
(1 row) |
| 857 |
|
| 858 |
SELECT count(*) from test__int WHERE a @@ '23|50'; |
| 859 |
count |
| 860 |
------- |
| 861 |
403 |
| 862 |
(1 row) |
| 863 |
|
| 864 |
SELECT count(*) from test__int WHERE a @> '{23,50}'; |
| 865 |
count |
| 866 |
------- |
| 867 |
12 |
| 868 |
(1 row) |
| 869 |
|
| 870 |
SELECT count(*) from test__int WHERE a @@ '23&50'; |
| 871 |
count |
| 872 |
------- |
| 873 |
12 |
| 874 |
(1 row) |
| 875 |
|
| 876 |
SELECT count(*) from test__int WHERE a @> '{20,23}'; |
| 877 |
count |
| 878 |
------- |
| 879 |
12 |
| 880 |
(1 row) |
| 881 |
|
| 882 |
SELECT count(*) from test__int WHERE a <@ '{73,23,20}'; |
| 883 |
count |
| 884 |
------- |
| 885 |
10 |
| 886 |
(1 row) |
| 887 |
|
| 888 |
SELECT count(*) from test__int WHERE a = '{73,23,20}'; |
| 889 |
count |
| 890 |
------- |
| 891 |
1 |
| 892 |
(1 row) |
| 893 |
|
| 894 |
SELECT count(*) from test__int WHERE a @@ '50&68'; |
| 895 |
count |
| 896 |
------- |
| 897 |
9 |
| 898 |
(1 row) |
| 899 |
|
| 900 |
SELECT count(*) from test__int WHERE a @> '{20,23}' or a @> '{50,68}'; |
| 901 |
count |
| 902 |
------- |
| 903 |
21 |
| 904 |
(1 row) |
| 905 |
|
| 906 |
SELECT count(*) from test__int WHERE a @@ '(20&23)|(50&68)'; |
| 907 |
count |
| 908 |
------- |
| 909 |
21 |
| 910 |
(1 row) |
| 911 |
|
| 912 |
SELECT count(*) from test__int WHERE a @@ '20 | !21'; |
| 913 |
count |
| 914 |
------- |
| 915 |
6567 |
| 916 |
(1 row) |
| 917 |
|
| 918 |
SELECT count(*) from test__int WHERE a @@ '!20 & !21'; |
| 919 |
count |
| 920 |
------- |
| 921 |
6344 |
| 922 |
(1 row) |
| 923 |
|
| 924 |
SELECT count(*) from test__int WHERE a @@ '!2733 & (2738 | 254)'; |
| 925 |
count |
| 926 |
------- |
| 927 |
12 |
| 928 |
(1 row) |
| 929 |
|
| 930 |
DROP INDEX text_idx; |
| 931 |
-- Repeat the same queries with an extended data set. The data set is the |
| 932 |
-- same that we used before, except that each element in the array is |
| 933 |
-- repeated three times, offset by 1000 and 2000. For example, {1, 5} |
| 934 |
-- becomes {1, 1001, 2001, 5, 1005, 2005}. |
| 935 |
-- |
| 936 |
-- That has proven to be unreasonably effective at exercising codepaths in |
| 937 |
-- core GiST code related to splitting parent pages, which is not covered by |
| 938 |
-- other tests. This is a bit out-of-place as the point is to test core GiST |
| 939 |
-- code rather than this extension, but there is no suitable GiST opclass in |
| 940 |
-- core that would reach the same codepaths. |
| 941 |
CREATE TABLE more__int AS SELECT |
| 942 |
-- Leave alone NULLs, empty arrays and the one row that we use to test |
| 943 |
-- equality; also skip INT_MAX |
| 944 |
CASE WHEN a IS NULL OR a = '{}' OR a = '{73,23,20}' THEN a ELSE |
| 945 |
(select array_agg(u) || array_agg(u + 1000) || array_agg(u + 2000) |
| 946 |
from unnest(a) u where u < 2000000000) |
| 947 |
END AS a, a as b |
| 948 |
FROM test__int; |
| 949 |
CREATE INDEX ON more__int using gist (a gist__int_ops(numranges = 252)); |
| 950 |
SELECT count(*) from more__int WHERE a && '{23,50}'; |
| 951 |
count |
| 952 |
------- |
| 953 |
403 |
| 954 |
(1 row) |
| 955 |
|
| 956 |
SELECT count(*) from more__int WHERE a @@ '23|50'; |
| 957 |
count |
| 958 |
------- |
| 959 |
403 |
| 960 |
(1 row) |
| 961 |
|
| 962 |
SELECT count(*) from more__int WHERE a @> '{23,50}'; |
| 963 |
count |
| 964 |
------- |
| 965 |
12 |
| 966 |
(1 row) |
| 967 |
|
| 968 |
SELECT count(*) from more__int WHERE a @@ '23&50'; |
| 969 |
count |
| 970 |
------- |
| 971 |
12 |
| 972 |
(1 row) |
| 973 |
|
| 974 |
SELECT count(*) from more__int WHERE a @> '{20,23}'; |
| 975 |
count |
| 976 |
------- |
| 977 |
12 |
| 978 |
(1 row) |
| 979 |
|
| 980 |
SELECT count(*) from more__int WHERE a <@ '{73,23,20}'; |
| 981 |
count |
| 982 |
------- |
| 983 |
10 |
| 984 |
(1 row) |
| 985 |
|
| 986 |
SELECT count(*) from more__int WHERE a = '{73,23,20}'; |
| 987 |
count |
| 988 |
------- |
| 989 |
1 |
| 990 |
(1 row) |
| 991 |
|
| 992 |
SELECT count(*) from more__int WHERE a @@ '50&68'; |
| 993 |
count |
| 994 |
------- |
| 995 |
9 |
| 996 |
(1 row) |
| 997 |
|
| 998 |
SELECT count(*) from more__int WHERE a @> '{20,23}' or a @> '{50,68}'; |
| 999 |
count |
| 1000 |
------- |
| 1001 |
21 |
| 1002 |
(1 row) |
| 1003 |
|
| 1004 |
SELECT count(*) from more__int WHERE a @@ '(20&23)|(50&68)'; |
| 1005 |
count |
| 1006 |
------- |
| 1007 |
21 |
| 1008 |
(1 row) |
| 1009 |
|
| 1010 |
SELECT count(*) from more__int WHERE a @@ '20 | !21'; |
| 1011 |
count |
| 1012 |
------- |
| 1013 |
6567 |
| 1014 |
(1 row) |
| 1015 |
|
| 1016 |
SELECT count(*) from more__int WHERE a @@ '!20 & !21'; |
| 1017 |
count |
| 1018 |
------- |
| 1019 |
6344 |
| 1020 |
(1 row) |
| 1021 |
|
| 1022 |
SELECT count(*) from test__int WHERE a @@ '!2733 & (2738 | 254)'; |
| 1023 |
count |
| 1024 |
------- |
| 1025 |
12 |
| 1026 |
(1 row) |
| 1027 |
|
| 1028 |
RESET enable_seqscan; |