1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-05 07:21:24 +03:00

REINDEX SCHEMA

Add new SCHEMA option to REINDEX and reindexdb.

Sawada Masahiko

Reviewed by Michael Paquier and Fabrízio de Royes Mello
This commit is contained in:
Simon Riggs
2014-12-09 00:28:00 +09:00
parent 8001fe67a3
commit fe263d115a
12 changed files with 253 additions and 61 deletions

View File

@ -2831,3 +2831,34 @@ explain (costs off)
Index Cond: ((thousand = 1) AND (tenthous = 1001))
(2 rows)
--
-- REINDEX SCHEMA
--
REINDEX SCHEMA schema_to_reindex; -- failure, schema does not exist
ERROR: schema "schema_to_reindex" does not exist
CREATE SCHEMA schema_to_reindex;
CREATE TABLE schema_to_reindex.table1(col1 SERIAL PRIMARY KEY);
CREATE TABLE schema_to_reindex.table2(col1 SERIAL PRIMARY KEY, col2 VARCHAR(100) NOT NULL);
CREATE INDEX ON schema_to_reindex.table2(col2);
REINDEX SCHEMA schema_to_reindex;
NOTICE: table "schema_to_reindex.table1" was reindexed
NOTICE: table "schema_to_reindex.table2" was reindexed
BEGIN;
REINDEX SCHEMA schema_to_reindex; -- failure, cannot run in a transaction
ERROR: REINDEX SCHEMA cannot run inside a transaction block
END;
-- Failure for unauthorized user
CREATE ROLE reindexuser login;
SET SESSION ROLE user_reindex;
ERROR: role "user_reindex" does not exist
REINDEX SCHEMA schema_to_reindex;
NOTICE: table "schema_to_reindex.table1" was reindexed
NOTICE: table "schema_to_reindex.table2" was reindexed
-- Clean up
RESET ROLE;
DROP ROLE user_reindex;
ERROR: role "user_reindex" does not exist
DROP SCHEMA schema_to_reindex CASCADE;
NOTICE: drop cascades to 2 other objects
DETAIL: drop cascades to table schema_to_reindex.table1
drop cascades to table schema_to_reindex.table2

View File

@ -964,3 +964,26 @@ RESET enable_indexscan;
explain (costs off)
select * from tenk1 where (thousand, tenthous) in ((1,1001), (null,null));
--
-- REINDEX SCHEMA
--
REINDEX SCHEMA schema_to_reindex; -- failure, schema does not exist
CREATE SCHEMA schema_to_reindex;
CREATE TABLE schema_to_reindex.table1(col1 SERIAL PRIMARY KEY);
CREATE TABLE schema_to_reindex.table2(col1 SERIAL PRIMARY KEY, col2 VARCHAR(100) NOT NULL);
CREATE INDEX ON schema_to_reindex.table2(col2);
REINDEX SCHEMA schema_to_reindex;
BEGIN;
REINDEX SCHEMA schema_to_reindex; -- failure, cannot run in a transaction
END;
-- Failure for unauthorized user
CREATE ROLE reindexuser login;
SET SESSION ROLE user_reindex;
REINDEX SCHEMA schema_to_reindex;
-- Clean up
RESET ROLE;
DROP ROLE user_reindex;
DROP SCHEMA schema_to_reindex CASCADE;