Skip to content

Commit 436451b

Browse files
committed
add test for issue_1
1 parent 7e6d58c commit 436451b

File tree

4 files changed

+36
-2
lines changed

4 files changed

+36
-2
lines changed

index_advisor--0.1.0--0.1.1.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,6 @@ begin
9696
and (select array_agg(x) from unnest(pi.indkey) v(x)) = array[pa.attnum]
9797
and pi.indexprs is null -- ignore expression indexes
9898
and pi.indpred is null -- ignore partial indexes
99-
and pa.atttypid in (20,16,1082,1184,1114,701,23,21,700,1083,2950,1700,25,18,1042,1043)
10099
where
101100
pc.relnamespace::regnamespace::text not in ( -- ignore schema list
102101
'pg_catalog', 'pg_toast', 'information_schema'
@@ -107,6 +106,7 @@ begin
107106
and pa.attnum > 0
108107
and not pa.attisdropped
109108
and pi.indrelid is null
109+
and pa.atttypid in (20,16,1082,1184,1114,701,23,21,700,1083,2950,1700,25,18,1042,1043)
110110
)
111111
loop
112112
-- Create the hypothetical index

index_advisor--0.1.1.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,6 @@ begin
9494
and (select array_agg(x) from unnest(pi.indkey) v(x)) = array[pa.attnum]
9595
and pi.indexprs is null -- ignore expression indexes
9696
and pi.indpred is null -- ignore partial indexes
97-
and pa.atttypid in (20,16,1082,1184,1114,701,23,21,700,1083,2950,1700,25,18,1042,1043)
9897
where
9998
pc.relnamespace::regnamespace::text not in ( -- ignore schema list
10099
'pg_catalog', 'pg_toast', 'information_schema'
@@ -105,6 +104,7 @@ begin
105104
and pa.attnum > 0
106105
and not pa.attisdropped
107106
and pi.indrelid is null
107+
and pa.atttypid in (20,16,1082,1184,1114,701,23,21,700,1083,2950,1700,25,18,1042,1043)
108108
)
109109
loop
110110
-- Create the hypothetical index

test/expected/issue_1.out

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
begin;
2+
create extension index_advisor version '0.1.1' cascade;
3+
NOTICE: installing required extension "hypopg"
4+
create table public.book(
5+
id int,
6+
-- json type is not btree indexable. In version 0.1.1 this raises the error
7+
-- ERROR: data type json has no default operator class for access method "btree"
8+
meta json
9+
);
10+
select index_advisor($$
11+
select * from book where id = $1
12+
$$);
13+
index_advisor
14+
------------------------------------------------------------------------------
15+
(0.00,4.07,25.88,13.54,"{""CREATE INDEX ON public.book USING btree (id)""}")
16+
(1 row)
17+
18+
rollback;

test/sql/issue_1.sql

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
begin;
2+
3+
create extension index_advisor version '0.1.1' cascade;
4+
5+
create table public.book(
6+
id int,
7+
-- json type is not btree indexable. In version 0.1.1 this raises the error
8+
-- ERROR: data type json has no default operator class for access method "btree"
9+
meta json
10+
);
11+
12+
select index_advisor($$
13+
select * from book where id = $1
14+
$$);
15+
16+
rollback;

0 commit comments

Comments
 (0)