mirror of
https://github.com/postgres/postgres.git
synced 2025-07-31 22:04:40 +03:00
config
contrib
adminpack
amcheck
auth_delay
auto_explain
bloom
btree_gin
btree_gist
citext
cube
dblink
dict_int
dict_xsyn
earthdistance
file_fdw
fuzzystrmatch
hstore
hstore_plperl
hstore_plpython
intagg
intarray
bench
data
expected
sql
_int.sql
.gitignore
Makefile
_int.h
_int_bool.c
_int_gin.c
_int_gist.c
_int_op.c
_int_selfuncs.c
_int_tool.c
_intbig_gist.c
intarray--1.0--1.1.sql
intarray--1.1--1.2.sql
intarray--1.2.sql
intarray--unpackaged--1.0.sql
intarray.control
isn
jsonb_plperl
jsonb_plpython
lo
ltree
ltree_plpython
oid2name
pageinspect
passwordcheck
pg_buffercache
pg_freespacemap
pg_prewarm
pg_standby
pg_stat_statements
pg_trgm
pg_visibility
pgcrypto
pgrowlocks
pgstattuple
postgres_fdw
seg
sepgsql
spi
sslinfo
start-scripts
tablefunc
tcn
test_decoding
tsm_system_rows
tsm_system_time
unaccent
uuid-ossp
vacuumlo
xml2
Makefile
README
contrib-global.mk
doc
src
.dir-locals.el
.gitattributes
.gitignore
COPYRIGHT
GNUmakefile.in
HISTORY
Makefile
README
README.git
aclocal.m4
configure
configure.in
Commit716ea626a
attempted to fix the problem of building 1-D zero-size arrays once and for all. But it turns out that contrib/intarray has some code that doesn't use construct_array() but just builds arrays by hand, so it didn't get the memo. This appears to affect all of subarray(), intset_subtract(), inner_int_union(), inner_int_inter(), and intarray_concat_arrays(). Back-patch into v11. In the past we've not back-patched this type of change, but since v11 is still in beta it seems all right to include this fix in it. Besides it's more consistent to make the fix in v11 where716ea626a
appeared. Report and patch by Alexey Kryuchkov, some cosmetic adjustments by me Report: https://postgr.es/m/153053285112.13258.434620894305716755@wrigleys.postgresql.org Discussion: https://postgr.es/m/CAN85JcYphDLYt4CpMDLZjjNVqGDrFJ5eS3YF=wLAhFoDQuBsyg@mail.gmail.com
126 lines
4.5 KiB
SQL
126 lines
4.5 KiB
SQL
CREATE EXTENSION intarray;
|
|
|
|
-- Check whether any of our opclasses fail amvalidate
|
|
SELECT amname, opcname
|
|
FROM pg_opclass opc LEFT JOIN pg_am am ON am.oid = opcmethod
|
|
WHERE opc.oid >= 16384 AND NOT amvalidate(opc.oid);
|
|
|
|
SELECT intset(1234);
|
|
SELECT icount('{1234234,234234}');
|
|
SELECT sort('{1234234,-30,234234}');
|
|
SELECT sort('{1234234,-30,234234}','asc');
|
|
SELECT sort('{1234234,-30,234234}','desc');
|
|
SELECT sort_asc('{1234234,-30,234234}');
|
|
SELECT sort_desc('{1234234,-30,234234}');
|
|
SELECT uniq('{1234234,-30,-30,234234,-30}');
|
|
SELECT uniq(sort_asc('{1234234,-30,-30,234234,-30}'));
|
|
SELECT idx('{1234234,-30,-30,234234,-30}',-30);
|
|
SELECT subarray('{1234234,-30,-30,234234,-30}',2,3);
|
|
SELECT subarray('{1234234,-30,-30,234234,-30}',-1,1);
|
|
SELECT subarray('{1234234,-30,-30,234234,-30}',0,-1);
|
|
|
|
SELECT #'{1234234,234234}'::int[];
|
|
SELECT '{123,623,445}'::int[] + 1245;
|
|
SELECT '{123,623,445}'::int[] + 445;
|
|
SELECT '{123,623,445}'::int[] + '{1245,87,445}';
|
|
SELECT '{123,623,445}'::int[] - 623;
|
|
SELECT '{123,623,445}'::int[] - '{1623,623}';
|
|
SELECT '{123,623,445}'::int[] | 623;
|
|
SELECT '{123,623,445}'::int[] | 1623;
|
|
SELECT '{123,623,445}'::int[] | '{1623,623}';
|
|
SELECT '{123,623,445}'::int[] & '{1623,623}';
|
|
SELECT '{-1,3,1}'::int[] & '{1,2}';
|
|
SELECT '{1}'::int[] & '{2}'::int[];
|
|
SELECT array_dims('{1}'::int[] & '{2}'::int[]);
|
|
SELECT ('{1}'::int[] & '{2}'::int[]) = '{}'::int[];
|
|
SELECT ('{}'::int[] & '{}'::int[]) = '{}'::int[];
|
|
|
|
|
|
--test query_int
|
|
SELECT '1'::query_int;
|
|
SELECT ' 1'::query_int;
|
|
SELECT '1 '::query_int;
|
|
SELECT ' 1 '::query_int;
|
|
SELECT ' ! 1 '::query_int;
|
|
SELECT '!1'::query_int;
|
|
SELECT '1|2'::query_int;
|
|
SELECT '1|!2'::query_int;
|
|
SELECT '!1|2'::query_int;
|
|
SELECT '!1|!2'::query_int;
|
|
SELECT '!(!1|!2)'::query_int;
|
|
SELECT '!(!1|2)'::query_int;
|
|
SELECT '!(1|!2)'::query_int;
|
|
SELECT '!(1|2)'::query_int;
|
|
SELECT '1&2'::query_int;
|
|
SELECT '!1&2'::query_int;
|
|
SELECT '1&!2'::query_int;
|
|
SELECT '!1&!2'::query_int;
|
|
SELECT '(1&2)'::query_int;
|
|
SELECT '1&(2)'::query_int;
|
|
SELECT '!(1)&2'::query_int;
|
|
SELECT '!(1&2)'::query_int;
|
|
SELECT '1|2&3'::query_int;
|
|
SELECT '1|(2&3)'::query_int;
|
|
SELECT '(1|2)&3'::query_int;
|
|
SELECT '1|2&!3'::query_int;
|
|
SELECT '1|!2&3'::query_int;
|
|
SELECT '!1|2&3'::query_int;
|
|
SELECT '!1|(2&3)'::query_int;
|
|
SELECT '!(1|2)&3'::query_int;
|
|
SELECT '(!1|2)&3'::query_int;
|
|
SELECT '1|(2|(4|(5|6)))'::query_int;
|
|
SELECT '1|2|4|5|6'::query_int;
|
|
SELECT '1&(2&(4&(5&6)))'::query_int;
|
|
SELECT '1&2&4&5&6'::query_int;
|
|
SELECT '1&(2&(4&(5|6)))'::query_int;
|
|
SELECT '1&(2&(4&(5|!6)))'::query_int;
|
|
|
|
|
|
CREATE TABLE test__int( a int[] );
|
|
\copy test__int from 'data/test__int.data'
|
|
ANALYZE test__int;
|
|
|
|
SELECT count(*) from test__int WHERE a && '{23,50}';
|
|
SELECT count(*) from test__int WHERE a @@ '23|50';
|
|
SELECT count(*) from test__int WHERE a @> '{23,50}';
|
|
SELECT count(*) from test__int WHERE a @@ '23&50';
|
|
SELECT count(*) from test__int WHERE a @> '{20,23}';
|
|
SELECT count(*) from test__int WHERE a @@ '50&68';
|
|
SELECT count(*) from test__int WHERE a @> '{20,23}' or a @> '{50,68}';
|
|
SELECT count(*) from test__int WHERE a @@ '(20&23)|(50&68)';
|
|
|
|
CREATE INDEX text_idx on test__int using gist ( a gist__int_ops );
|
|
|
|
SELECT count(*) from test__int WHERE a && '{23,50}';
|
|
SELECT count(*) from test__int WHERE a @@ '23|50';
|
|
SELECT count(*) from test__int WHERE a @> '{23,50}';
|
|
SELECT count(*) from test__int WHERE a @@ '23&50';
|
|
SELECT count(*) from test__int WHERE a @> '{20,23}';
|
|
SELECT count(*) from test__int WHERE a @@ '50&68';
|
|
SELECT count(*) from test__int WHERE a @> '{20,23}' or a @> '{50,68}';
|
|
SELECT count(*) from test__int WHERE a @@ '(20&23)|(50&68)';
|
|
|
|
DROP INDEX text_idx;
|
|
CREATE INDEX text_idx on test__int using gist ( a gist__intbig_ops );
|
|
|
|
SELECT count(*) from test__int WHERE a && '{23,50}';
|
|
SELECT count(*) from test__int WHERE a @@ '23|50';
|
|
SELECT count(*) from test__int WHERE a @> '{23,50}';
|
|
SELECT count(*) from test__int WHERE a @@ '23&50';
|
|
SELECT count(*) from test__int WHERE a @> '{20,23}';
|
|
SELECT count(*) from test__int WHERE a @@ '50&68';
|
|
SELECT count(*) from test__int WHERE a @> '{20,23}' or a @> '{50,68}';
|
|
SELECT count(*) from test__int WHERE a @@ '(20&23)|(50&68)';
|
|
|
|
DROP INDEX text_idx;
|
|
CREATE INDEX text_idx on test__int using gin ( a gin__int_ops );
|
|
|
|
SELECT count(*) from test__int WHERE a && '{23,50}';
|
|
SELECT count(*) from test__int WHERE a @@ '23|50';
|
|
SELECT count(*) from test__int WHERE a @> '{23,50}';
|
|
SELECT count(*) from test__int WHERE a @@ '23&50';
|
|
SELECT count(*) from test__int WHERE a @> '{20,23}';
|
|
SELECT count(*) from test__int WHERE a @@ '50&68';
|
|
SELECT count(*) from test__int WHERE a @> '{20,23}' or a @> '{50,68}';
|
|
SELECT count(*) from test__int WHERE a @@ '(20&23)|(50&68)';
|