Skip to content

Commit

Permalink
add test for issue_1
Browse files Browse the repository at this point in the history
  • Loading branch information
olirice committed Apr 7, 2023
1 parent 7e6d58c commit 436451b
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 2 deletions.
2 changes: 1 addition & 1 deletion index_advisor--0.1.0--0.1.1.sql
Expand Up @@ -96,7 +96,6 @@ begin
and (select array_agg(x) from unnest(pi.indkey) v(x)) = array[pa.attnum]
and pi.indexprs is null -- ignore expression indexes
and pi.indpred is null -- ignore partial indexes
and pa.atttypid in (20,16,1082,1184,1114,701,23,21,700,1083,2950,1700,25,18,1042,1043)
where
pc.relnamespace::regnamespace::text not in ( -- ignore schema list
'pg_catalog', 'pg_toast', 'information_schema'
Expand All @@ -107,6 +106,7 @@ begin
and pa.attnum > 0
and not pa.attisdropped
and pi.indrelid is null
and pa.atttypid in (20,16,1082,1184,1114,701,23,21,700,1083,2950,1700,25,18,1042,1043)
)
loop
-- Create the hypothetical index
Expand Down
2 changes: 1 addition & 1 deletion index_advisor--0.1.1.sql
Expand Up @@ -94,7 +94,6 @@ begin
and (select array_agg(x) from unnest(pi.indkey) v(x)) = array[pa.attnum]
and pi.indexprs is null -- ignore expression indexes
and pi.indpred is null -- ignore partial indexes
and pa.atttypid in (20,16,1082,1184,1114,701,23,21,700,1083,2950,1700,25,18,1042,1043)
where
pc.relnamespace::regnamespace::text not in ( -- ignore schema list
'pg_catalog', 'pg_toast', 'information_schema'
Expand All @@ -105,6 +104,7 @@ begin
and pa.attnum > 0
and not pa.attisdropped
and pi.indrelid is null
and pa.atttypid in (20,16,1082,1184,1114,701,23,21,700,1083,2950,1700,25,18,1042,1043)
)
loop
-- Create the hypothetical index
Expand Down
18 changes: 18 additions & 0 deletions test/expected/issue_1.out
@@ -0,0 +1,18 @@
begin;
create extension index_advisor version '0.1.1' cascade;
NOTICE: installing required extension "hypopg"
create table public.book(
id int,
-- json type is not btree indexable. In version 0.1.1 this raises the error
-- ERROR: data type json has no default operator class for access method "btree"
meta json
);
select index_advisor($$
select * from book where id = $1
$$);
index_advisor
------------------------------------------------------------------------------
(0.00,4.07,25.88,13.54,"{""CREATE INDEX ON public.book USING btree (id)""}")
(1 row)

rollback;
16 changes: 16 additions & 0 deletions test/sql/issue_1.sql
@@ -0,0 +1,16 @@
begin;

create extension index_advisor version '0.1.1' cascade;

create table public.book(
id int,
-- json type is not btree indexable. In version 0.1.1 this raises the error
-- ERROR: data type json has no default operator class for access method "btree"
meta json
);

select index_advisor($$
select * from book where id = $1
$$);

rollback;

0 comments on commit 436451b

Please sign in to comment.