diff options
author | Peter Eisentraut <peter@eisentraut.org> | 2019-03-29 08:25:20 +0100 |
---|---|---|
committer | Peter Eisentraut <peter@eisentraut.org> | 2019-03-29 08:26:33 +0100 |
commit | 5dc92b844e680c54a7ecd68de0ba53c949c3d605 (patch) | |
tree | a6cd95f2b00c7568491e2feebbfb4b8c58c3b51b /src/bin/psql/common.c | |
parent | d25f519107bff602e1ebc81853fe592d020c118d (diff) | |
download | postgresql-5dc92b844e680c54a7ecd68de0ba53c949c3d605.tar.gz postgresql-5dc92b844e680c54a7ecd68de0ba53c949c3d605.zip |
REINDEX CONCURRENTLY
This adds the CONCURRENTLY option to the REINDEX command. A REINDEX
CONCURRENTLY on a specific index creates a new index (like CREATE
INDEX CONCURRENTLY), then renames the old index away and the new index
in place and adjusts the dependencies, and then drops the old
index (like DROP INDEX CONCURRENTLY). The REINDEX command also has
the capability to run its other variants (TABLE, DATABASE) with the
CONCURRENTLY option (but not SYSTEM).
The reindexdb command gets the --concurrently option.
Author: Michael Paquier, Andreas Karlsson, Peter Eisentraut
Reviewed-by: Andres Freund, Fujii Masao, Jim Nasby, Sergei Kornilov
Discussion: https://www.postgresql.org/message-id/flat/60052986-956b-4478-45ed-8bd119e9b9cf%402ndquadrant.com#74948a1044c56c5e817a5050f554ddee
Diffstat (limited to 'src/bin/psql/common.c')
-rw-r--r-- | src/bin/psql/common.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/bin/psql/common.c b/src/bin/psql/common.c index 5d8634d8186..82511e34ac3 100644 --- a/src/bin/psql/common.c +++ b/src/bin/psql/common.c @@ -2192,6 +2192,22 @@ command_no_begin(const char *query) return true; if (wordlen == 10 && pg_strncasecmp(query, "tablespace", 10) == 0) return true; + if (wordlen == 5 && (pg_strncasecmp(query, "index", 5) == 0 || + pg_strncasecmp(query, "table", 5) == 0)) + { + query += wordlen; + query = skip_white_space(query); + wordlen = 0; + while (isalpha((unsigned char) query[wordlen])) + wordlen += PQmblen(&query[wordlen], pset.encoding); + + /* + * REINDEX [ TABLE | INDEX ] CONCURRENTLY are not allowed in + * xacts. + */ + if (wordlen == 12 && pg_strncasecmp(query, "concurrently", 12) == 0) + return true; + } /* DROP INDEX CONCURRENTLY isn't allowed in xacts */ if (wordlen == 5 && pg_strncasecmp(query, "index", 5) == 0) |