Files
threshold/internal/db/sqltest/tests/index/update_time.sql
T
5bfc8a88b1 Add indexes on update_time (#3974)
* Add indexes on update_time

Co-authored-by: Johan Brandhorst-Satzkorn <johan.brandhorst@gmail.com>
Co-authored-by: Michael Gaffney <mike@gaffney.cc>
2024-01-05 07:43:20 -08:00

28 lines
765 B
PL/PgSQL

-- Copyright (c) HashiCorp, Inc.
-- SPDX-License-Identifier: BUSL-1.1
begin;
create function op_table(deletion_table_name name) returns text
as $$
select split_part(deletion_table_name, '_deleted', 1);
$$ language sql;
create function has_update_time_index(table_name name) returns text
as $$
select * from collect_tap(
has_index(table_name, table_name || '_update_time_idx', 'update_time')
);
$$ language sql;
-- the op table for each deletion table should be tested for the index
select plan(a.table_count::integer)
from (
select count(*) as table_count
from get_deletion_tables()
) as a;
select has_update_time_index(op_table(a))
from get_deletion_tables() a;
select * from finish();
rollback;