diff options
| author | Tom Lane | 2006-08-25 04:06:58 +0000 |
|---|---|---|
| committer | Tom Lane | 2006-08-25 04:06:58 +0000 |
| commit | e093dcdd2853911ca1ad710581182dfcb6c78ea3 (patch) | |
| tree | 59fc44746f9937abea6ad44e2098a8c3c4b7f7e6 /src/backend/parser | |
| parent | 8f91e2b6071aaeae333f668d0f5d9189c5710a7a (diff) | |
Add the ability to create indexes 'concurrently', that is, without
blocking concurrent writes to the table. Greg Stark, with a little help
from Tom Lane.
Diffstat (limited to 'src/backend/parser')
| -rw-r--r-- | src/backend/parser/analyze.c | 3 | ||||
| -rw-r--r-- | src/backend/parser/gram.y | 36 | ||||
| -rw-r--r-- | src/backend/parser/keywords.c | 3 |
3 files changed, 32 insertions, 10 deletions
diff --git a/src/backend/parser/analyze.c b/src/backend/parser/analyze.c index 8eb50fb573e..ae3469c86c7 100644 --- a/src/backend/parser/analyze.c +++ b/src/backend/parser/analyze.c @@ -6,7 +6,7 @@ * Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/backend/parser/analyze.c,v 1.347 2006/08/21 00:57:24 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/parser/analyze.c,v 1.348 2006/08/25 04:06:51 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -1488,6 +1488,7 @@ transformIndexConstraints(ParseState *pstate, CreateStmtContext *cxt) index->tableSpace = constraint->indexspace; index->indexParams = NIL; index->whereClause = NULL; + index->concurrent = false; /* * Make sure referenced keys exist. If we are making a PRIMARY KEY diff --git a/src/backend/parser/gram.y b/src/backend/parser/gram.y index 60761ae6bca..a77e73a43fc 100644 --- a/src/backend/parser/gram.y +++ b/src/backend/parser/gram.y @@ -11,7 +11,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/parser/gram.y,v 2.557 2006/08/21 00:57:25 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/parser/gram.y,v 2.558 2006/08/25 04:06:51 tgl Exp $ * * HISTORY * AUTHOR DATE MAJOR EVENT @@ -364,7 +364,8 @@ static void doNegateFloat(Value *v); CACHE CALLED CASCADE CASCADED CASE CAST CHAIN CHAR_P CHARACTER CHARACTERISTICS CHECK CHECKPOINT CLASS CLOSE CLUSTER COALESCE COLLATE COLUMN COMMENT COMMIT - COMMITTED CONNECTION CONSTRAINT CONSTRAINTS CONVERSION_P CONVERT COPY CREATE CREATEDB + COMMITTED CONCURRENTLY CONNECTION CONSTRAINT CONSTRAINTS + CONVERSION_P CONVERT COPY CREATE CREATEDB CREATEROLE CREATEUSER CROSS CSV CURRENT_DATE CURRENT_ROLE CURRENT_TIME CURRENT_TIMESTAMP CURRENT_USER CURSOR CYCLE @@ -3638,20 +3639,22 @@ opt_granted_by: GRANTED BY RoleId { $$ = $3; } /***************************************************************************** * - * QUERY: - * create index <indexname> on <relname> - * [ using <access> ] "(" ( <col> [ using <opclass> ] )+ ")" - * [ tablespace <tablespacename> ] [ where <predicate> ] + * QUERY: CREATE INDEX + * + * Note: we can't factor CONCURRENTLY into a separate production without + * making it a reserved word. * * Note: we cannot put TABLESPACE clause after WHERE clause unless we are * willing to make TABLESPACE a fully reserved word. *****************************************************************************/ -IndexStmt: CREATE index_opt_unique INDEX index_name ON qualified_name - access_method_clause '(' index_params ')' opt_definition OptTableSpace where_clause +IndexStmt: CREATE index_opt_unique INDEX index_name + ON qualified_name access_method_clause '(' index_params ')' + opt_definition OptTableSpace where_clause { IndexStmt *n = makeNode(IndexStmt); n->unique = $2; + n->concurrent = false; n->idxname = $4; n->relation = $6; n->accessMethod = $7; @@ -3661,6 +3664,22 @@ IndexStmt: CREATE index_opt_unique INDEX index_name ON qualified_name n->whereClause = $13; $$ = (Node *)n; } + | CREATE index_opt_unique INDEX CONCURRENTLY index_name + ON qualified_name access_method_clause '(' index_params ')' + opt_definition OptTableSpace where_clause + { + IndexStmt *n = makeNode(IndexStmt); + n->unique = $2; + n->concurrent = true; + n->idxname = $5; + n->relation = $7; + n->accessMethod = $8; + n->indexParams = $10; + n->options = $12; + n->tableSpace = $13; + n->whereClause = $14; + $$ = (Node *)n; + } ; index_opt_unique: @@ -8491,6 +8510,7 @@ unreserved_keyword: | COMMENT | COMMIT | COMMITTED + | CONCURRENTLY | CONNECTION | CONSTRAINTS | CONVERSION_P diff --git a/src/backend/parser/keywords.c b/src/backend/parser/keywords.c index e799d68ae69..9867982cdb0 100644 --- a/src/backend/parser/keywords.c +++ b/src/backend/parser/keywords.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/parser/keywords.c,v 1.175 2006/08/12 02:52:05 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/parser/keywords.c,v 1.176 2006/08/25 04:06:52 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -84,6 +84,7 @@ static const ScanKeyword ScanKeywords[] = { {"comment", COMMENT}, {"commit", COMMIT}, {"committed", COMMITTED}, + {"concurrently", CONCURRENTLY}, {"connection", CONNECTION}, {"constraint", CONSTRAINT}, {"constraints", CONSTRAINTS}, |
