# Author: Andrew Klychkov <aaklyckov@mail.ru>
# 16-07-2018

diff --git a/src/backend/commands/cluster.c b/src/backend/commands/cluster.c
index 482d463..47e20d5 100644
--- a/src/backend/commands/cluster.c
+++ b/src/backend/commands/cluster.c
@@ -1658,14 +1658,14 @@ finish_heap_swap(Oid OIDOldHeap, Oid OIDNewHeap,
 			snprintf(NewToastName, NAMEDATALEN, "pg_toast_%u",
 					 OIDOldHeap);
 			RenameRelationInternal(newrel->rd_rel->reltoastrelid,
-								   NewToastName, true);
+								   NewToastName, true, false);
 
 			/* ... and its valid index too. */
 			snprintf(NewToastName, NAMEDATALEN, "pg_toast_%u_index",
 					 OIDOldHeap);
 
 			RenameRelationInternal(toastidx,
-								   NewToastName, true);
+								   NewToastName, true, false);
 		}
 		relation_close(newrel, NoLock);
 	}
diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c
index 22e81e7..ead4f26 100644
--- a/src/backend/commands/tablecmds.c
+++ b/src/backend/commands/tablecmds.c
@@ -3012,7 +3012,7 @@ rename_constraint_internal(Oid myrelid,
 			|| con->contype == CONSTRAINT_UNIQUE
 			|| con->contype == CONSTRAINT_EXCLUSION))
 		/* rename the index; this renames the constraint as well */
-		RenameRelationInternal(con->conindid, newconname, false);
+		RenameRelationInternal(con->conindid, newconname, false, false);
 	else
 		RenameConstraintById(constraintOid, newconname);
 
@@ -3082,7 +3082,9 @@ RenameRelation(RenameStmt *stmt)
 {
 	Oid			relid;
 	ObjectAddress address;
+    LOCKMODE    lockmode;
 
+    lockmode = stmt->concurrent ? ShareUpdateExclusiveLock : AccessExclusiveLock;
 	/*
 	 * Grab an exclusive lock on the target table, index, sequence, view,
 	 * materialized view, or foreign table, which we will NOT release until
@@ -3091,7 +3093,7 @@ RenameRelation(RenameStmt *stmt)
 	 * Lock level used here should match RenameRelationInternal, to avoid lock
 	 * escalation.
 	 */
-	relid = RangeVarGetRelidExtended(stmt->relation, AccessExclusiveLock,
+	relid = RangeVarGetRelidExtended(stmt->relation, lockmode,
 									 stmt->missing_ok ? RVR_MISSING_OK : 0,
 									 RangeVarCallbackForAlterRelation,
 									 (void *) stmt);
@@ -3105,7 +3107,7 @@ RenameRelation(RenameStmt *stmt)
 	}
 
 	/* Do the work */
-	RenameRelationInternal(relid, stmt->newname, false);
+	RenameRelationInternal(relid, stmt->newname, false, stmt->concurrent);
 
 	ObjectAddressSet(address, RelationRelationId, relid);
 
@@ -3122,20 +3124,22 @@ RenameRelation(RenameStmt *stmt)
  *			  sequence, AFAIK there's no need for it to be there.
  */
 void
-RenameRelationInternal(Oid myrelid, const char *newrelname, bool is_internal)
+RenameRelationInternal(Oid myrelid, const char *newrelname, bool is_internal, bool concurrent)
 {
 	Relation	targetrelation;
 	Relation	relrelation;	/* for RELATION relation */
 	HeapTuple	reltup;
 	Form_pg_class relform;
 	Oid			namespaceId;
+    LOCKMODE    lockmode;
 
 	/*
 	 * Grab an exclusive lock on the target table, index, sequence, view,
 	 * materialized view, or foreign table, which we will NOT release until
 	 * end of transaction.
 	 */
-	targetrelation = relation_open(myrelid, AccessExclusiveLock);
+    lockmode = concurrent ? ShareUpdateExclusiveLock : AccessExclusiveLock;
+	targetrelation = relation_open(myrelid, lockmode);
 	namespaceId = RelationGetNamespace(targetrelation);
 
 	/*
@@ -7039,7 +7043,7 @@ ATExecAddIndexConstraint(AlteredTableInfo *tab, Relation rel,
 		ereport(NOTICE,
 				(errmsg("ALTER TABLE / ADD CONSTRAINT USING INDEX will rename index \"%s\" to \"%s\"",
 						indexName, constraintName)));
-		RenameRelationInternal(index_oid, constraintName, false);
+		RenameRelationInternal(index_oid, constraintName, false, false);
 	}
 
 	/* Extra checks needed if making primary key */
diff --git a/src/backend/commands/typecmds.c b/src/backend/commands/typecmds.c
index 175ecc8..f7f3ce2 100644
--- a/src/backend/commands/typecmds.c
+++ b/src/backend/commands/typecmds.c
@@ -3280,7 +3280,7 @@ RenameType(RenameStmt *stmt)
 	 * RenameRelationInternal will call RenameTypeInternal automatically.
 	 */
 	if (typTup->typtype == TYPTYPE_COMPOSITE)
-		RenameRelationInternal(typTup->typrelid, newTypeName, false);
+		RenameRelationInternal(typTup->typrelid, newTypeName, false, false);
 	else
 		RenameTypeInternal(typeOid, newTypeName,
 						   typTup->typnamespace);
diff --git a/src/backend/parser/gram.y b/src/backend/parser/gram.y
index 90dfac2..ed6658b 100644
--- a/src/backend/parser/gram.y
+++ b/src/backend/parser/gram.y
@@ -8457,6 +8457,7 @@ RenameStmt: ALTER AGGREGATE aggregate_with_argtypes RENAME TO name
 					n->object = (Node *) $3;
 					n->newname = $6;
 					n->missing_ok = false;
+                    n->concurrent = false;
 					$$ = (Node *)n;
 				}
 			| ALTER COLLATION any_name RENAME TO name
@@ -8466,6 +8467,7 @@ RenameStmt: ALTER AGGREGATE aggregate_with_argtypes RENAME TO name
 					n->object = (Node *) $3;
 					n->newname = $6;
 					n->missing_ok = false;
+                    n->concurrent = false;
 					$$ = (Node *)n;
 				}
 			| ALTER CONVERSION_P any_name RENAME TO name
@@ -8475,6 +8477,7 @@ RenameStmt: ALTER AGGREGATE aggregate_with_argtypes RENAME TO name
 					n->object = (Node *) $3;
 					n->newname = $6;
 					n->missing_ok = false;
+                    n->concurrent = false;
 					$$ = (Node *)n;
 				}
 			| ALTER DATABASE database_name RENAME TO database_name
@@ -8484,6 +8487,7 @@ RenameStmt: ALTER AGGREGATE aggregate_with_argtypes RENAME TO name
 					n->subname = $3;
 					n->newname = $6;
 					n->missing_ok = false;
+                    n->concurrent = false;
 					$$ = (Node *)n;
 				}
 			| ALTER DOMAIN_P any_name RENAME TO name
@@ -8493,6 +8497,7 @@ RenameStmt: ALTER AGGREGATE aggregate_with_argtypes RENAME TO name
 					n->object = (Node *) $3;
 					n->newname = $6;
 					n->missing_ok = false;
+                    n->concurrent = false;
 					$$ = (Node *)n;
 				}
 			| ALTER DOMAIN_P any_name RENAME CONSTRAINT name TO name
@@ -8502,6 +8507,7 @@ RenameStmt: ALTER AGGREGATE aggregate_with_argtypes RENAME TO name
 					n->object = (Node *) $3;
 					n->subname = $6;
 					n->newname = $8;
+                    n->concurrent = false;
 					$$ = (Node *)n;
 				}
 			| ALTER FOREIGN DATA_P WRAPPER name RENAME TO name
@@ -8511,6 +8517,7 @@ RenameStmt: ALTER AGGREGATE aggregate_with_argtypes RENAME TO name
 					n->object = (Node *) makeString($5);
 					n->newname = $8;
 					n->missing_ok = false;
+                    n->concurrent = false;
 					$$ = (Node *)n;
 				}
 			| ALTER FUNCTION function_with_argtypes RENAME TO name
@@ -8520,6 +8527,7 @@ RenameStmt: ALTER AGGREGATE aggregate_with_argtypes RENAME TO name
 					n->object = (Node *) $3;
 					n->newname = $6;
 					n->missing_ok = false;
+                    n->concurrent = false;
 					$$ = (Node *)n;
 				}
 			| ALTER GROUP_P RoleId RENAME TO RoleId
@@ -8529,6 +8537,7 @@ RenameStmt: ALTER AGGREGATE aggregate_with_argtypes RENAME TO name
 					n->subname = $3;
 					n->newname = $6;
 					n->missing_ok = false;
+                    n->concurrent = false;
 					$$ = (Node *)n;
 				}
 			| ALTER opt_procedural LANGUAGE name RENAME TO name
@@ -8538,6 +8547,7 @@ RenameStmt: ALTER AGGREGATE aggregate_with_argtypes RENAME TO name
 					n->object = (Node *) makeString($4);
 					n->newname = $7;
 					n->missing_ok = false;
+                    n->concurrent = false;
 					$$ = (Node *)n;
 				}
 			| ALTER OPERATOR CLASS any_name USING access_method RENAME TO name
@@ -8547,6 +8557,7 @@ RenameStmt: ALTER AGGREGATE aggregate_with_argtypes RENAME TO name
 					n->object = (Node *) lcons(makeString($6), $4);
 					n->newname = $9;
 					n->missing_ok = false;
+                    n->concurrent = false;
 					$$ = (Node *)n;
 				}
 			| ALTER OPERATOR FAMILY any_name USING access_method RENAME TO name
@@ -8556,6 +8567,7 @@ RenameStmt: ALTER AGGREGATE aggregate_with_argtypes RENAME TO name
 					n->object = (Node *) lcons(makeString($6), $4);
 					n->newname = $9;
 					n->missing_ok = false;
+                    n->concurrent = false;
 					$$ = (Node *)n;
 				}
 			| ALTER POLICY name ON qualified_name RENAME TO name
@@ -8566,6 +8578,7 @@ RenameStmt: ALTER AGGREGATE aggregate_with_argtypes RENAME TO name
 					n->subname = $3;
 					n->newname = $8;
 					n->missing_ok = false;
+                    n->concurrent = false;
 					$$ = (Node *)n;
 				}
 			| ALTER POLICY IF_P EXISTS name ON qualified_name RENAME TO name
@@ -8576,6 +8589,7 @@ RenameStmt: ALTER AGGREGATE aggregate_with_argtypes RENAME TO name
 					n->subname = $5;
 					n->newname = $10;
 					n->missing_ok = true;
+                    n->concurrent = false;
 					$$ = (Node *)n;
 				}
 			| ALTER PROCEDURE function_with_argtypes RENAME TO name
@@ -8585,6 +8599,7 @@ RenameStmt: ALTER AGGREGATE aggregate_with_argtypes RENAME TO name
 					n->object = (Node *) $3;
 					n->newname = $6;
 					n->missing_ok = false;
+                    n->concurrent = false;
 					$$ = (Node *)n;
 				}
 			| ALTER PUBLICATION name RENAME TO name
@@ -8594,6 +8609,7 @@ RenameStmt: ALTER AGGREGATE aggregate_with_argtypes RENAME TO name
 					n->object = (Node *) makeString($3);
 					n->newname = $6;
 					n->missing_ok = false;
+                    n->concurrent = false;
 					$$ = (Node *)n;
 				}
 			| ALTER ROUTINE function_with_argtypes RENAME TO name
@@ -8603,6 +8619,7 @@ RenameStmt: ALTER AGGREGATE aggregate_with_argtypes RENAME TO name
 					n->object = (Node *) $3;
 					n->newname = $6;
 					n->missing_ok = false;
+                    n->concurrent = false;
 					$$ = (Node *)n;
 				}
 			| ALTER SCHEMA name RENAME TO name
@@ -8612,6 +8629,7 @@ RenameStmt: ALTER AGGREGATE aggregate_with_argtypes RENAME TO name
 					n->subname = $3;
 					n->newname = $6;
 					n->missing_ok = false;
+                    n->concurrent = false;
 					$$ = (Node *)n;
 				}
 			| ALTER SERVER name RENAME TO name
@@ -8621,6 +8639,7 @@ RenameStmt: ALTER AGGREGATE aggregate_with_argtypes RENAME TO name
 					n->object = (Node *) makeString($3);
 					n->newname = $6;
 					n->missing_ok = false;
+                    n->concurrent = false;
 					$$ = (Node *)n;
 				}
 			| ALTER SUBSCRIPTION name RENAME TO name
@@ -8630,6 +8649,7 @@ RenameStmt: ALTER AGGREGATE aggregate_with_argtypes RENAME TO name
 					n->object = (Node *) makeString($3);
 					n->newname = $6;
 					n->missing_ok = false;
+                    n->concurrent = false;
 					$$ = (Node *)n;
 				}
 			| ALTER TABLE relation_expr RENAME TO name
@@ -8640,6 +8660,7 @@ RenameStmt: ALTER AGGREGATE aggregate_with_argtypes RENAME TO name
 					n->subname = NULL;
 					n->newname = $6;
 					n->missing_ok = false;
+                    n->concurrent = false;
 					$$ = (Node *)n;
 				}
 			| ALTER TABLE IF_P EXISTS relation_expr RENAME TO name
@@ -8650,6 +8671,7 @@ RenameStmt: ALTER AGGREGATE aggregate_with_argtypes RENAME TO name
 					n->subname = NULL;
 					n->newname = $8;
 					n->missing_ok = true;
+                    n->concurrent = false;
 					$$ = (Node *)n;
 				}
 			| ALTER SEQUENCE qualified_name RENAME TO name
@@ -8660,6 +8682,7 @@ RenameStmt: ALTER AGGREGATE aggregate_with_argtypes RENAME TO name
 					n->subname = NULL;
 					n->newname = $6;
 					n->missing_ok = false;
+                    n->concurrent = false;
 					$$ = (Node *)n;
 				}
 			| ALTER SEQUENCE IF_P EXISTS qualified_name RENAME TO name
@@ -8670,6 +8693,7 @@ RenameStmt: ALTER AGGREGATE aggregate_with_argtypes RENAME TO name
 					n->subname = NULL;
 					n->newname = $8;
 					n->missing_ok = true;
+                    n->concurrent = false;
 					$$ = (Node *)n;
 				}
 			| ALTER VIEW qualified_name RENAME TO name
@@ -8680,6 +8704,7 @@ RenameStmt: ALTER AGGREGATE aggregate_with_argtypes RENAME TO name
 					n->subname = NULL;
 					n->newname = $6;
 					n->missing_ok = false;
+                    n->concurrent = false;
 					$$ = (Node *)n;
 				}
 			| ALTER VIEW IF_P EXISTS qualified_name RENAME TO name
@@ -8690,6 +8715,7 @@ RenameStmt: ALTER AGGREGATE aggregate_with_argtypes RENAME TO name
 					n->subname = NULL;
 					n->newname = $8;
 					n->missing_ok = true;
+                    n->concurrent = false;
 					$$ = (Node *)n;
 				}
 			| ALTER MATERIALIZED VIEW qualified_name RENAME TO name
@@ -8700,6 +8726,7 @@ RenameStmt: ALTER AGGREGATE aggregate_with_argtypes RENAME TO name
 					n->subname = NULL;
 					n->newname = $7;
 					n->missing_ok = false;
+                    n->concurrent = false;
 					$$ = (Node *)n;
 				}
 			| ALTER MATERIALIZED VIEW IF_P EXISTS qualified_name RENAME TO name
@@ -8710,6 +8737,7 @@ RenameStmt: ALTER AGGREGATE aggregate_with_argtypes RENAME TO name
 					n->subname = NULL;
 					n->newname = $9;
 					n->missing_ok = true;
+                    n->concurrent = false;
 					$$ = (Node *)n;
 				}
 			| ALTER INDEX qualified_name RENAME TO name
@@ -8720,6 +8748,18 @@ RenameStmt: ALTER AGGREGATE aggregate_with_argtypes RENAME TO name
 					n->subname = NULL;
 					n->newname = $6;
 					n->missing_ok = false;
+                    n->concurrent = false;
+					$$ = (Node *)n;
+				}
+			| ALTER INDEX qualified_name RENAME CONCURRENTLY TO name
+				{
+					RenameStmt *n = makeNode(RenameStmt);
+					n->renameType = OBJECT_INDEX;
+					n->relation = $3;
+					n->subname = NULL;
+					n->newname = $7;
+					n->missing_ok = false;
+                    n->concurrent = true;
 					$$ = (Node *)n;
 				}
 			| ALTER INDEX IF_P EXISTS qualified_name RENAME TO name
@@ -8730,6 +8770,18 @@ RenameStmt: ALTER AGGREGATE aggregate_with_argtypes RENAME TO name
 					n->subname = NULL;
 					n->newname = $8;
 					n->missing_ok = true;
+                    n->concurrent = false;
+					$$ = (Node *)n;
+				}
+			| ALTER INDEX IF_P EXISTS qualified_name RENAME CONCURRENTLY TO name
+				{
+					RenameStmt *n = makeNode(RenameStmt);
+					n->renameType = OBJECT_INDEX;
+					n->relation = $5;
+					n->subname = NULL;
+					n->newname = $9;
+					n->missing_ok = true;
+                    n->concurrent = true;
 					$$ = (Node *)n;
 				}
 			| ALTER FOREIGN TABLE relation_expr RENAME TO name
@@ -8740,6 +8792,7 @@ RenameStmt: ALTER AGGREGATE aggregate_with_argtypes RENAME TO name
 					n->subname = NULL;
 					n->newname = $7;
 					n->missing_ok = false;
+                    n->concurrent = false;
 					$$ = (Node *)n;
 				}
 			| ALTER FOREIGN TABLE IF_P EXISTS relation_expr RENAME TO name
@@ -8750,6 +8803,7 @@ RenameStmt: ALTER AGGREGATE aggregate_with_argtypes RENAME TO name
 					n->subname = NULL;
 					n->newname = $9;
 					n->missing_ok = true;
+                    n->concurrent = false;
 					$$ = (Node *)n;
 				}
 			| ALTER TABLE relation_expr RENAME opt_column name TO name
@@ -8761,6 +8815,7 @@ RenameStmt: ALTER AGGREGATE aggregate_with_argtypes RENAME TO name
 					n->subname = $6;
 					n->newname = $8;
 					n->missing_ok = false;
+                    n->concurrent = false;
 					$$ = (Node *)n;
 				}
 			| ALTER TABLE IF_P EXISTS relation_expr RENAME opt_column name TO name
@@ -8772,6 +8827,7 @@ RenameStmt: ALTER AGGREGATE aggregate_with_argtypes RENAME TO name
 					n->subname = $8;
 					n->newname = $10;
 					n->missing_ok = true;
+                    n->concurrent = false;
 					$$ = (Node *)n;
 				}
 			| ALTER MATERIALIZED VIEW qualified_name RENAME opt_column name TO name
@@ -8783,6 +8839,7 @@ RenameStmt: ALTER AGGREGATE aggregate_with_argtypes RENAME TO name
 					n->subname = $7;
 					n->newname = $9;
 					n->missing_ok = false;
+                    n->concurrent = false;
 					$$ = (Node *)n;
 				}
 			| ALTER MATERIALIZED VIEW IF_P EXISTS qualified_name RENAME opt_column name TO name
@@ -8794,6 +8851,7 @@ RenameStmt: ALTER AGGREGATE aggregate_with_argtypes RENAME TO name
 					n->subname = $9;
 					n->newname = $11;
 					n->missing_ok = true;
+                    n->concurrent = false;
 					$$ = (Node *)n;
 				}
 			| ALTER TABLE relation_expr RENAME CONSTRAINT name TO name
@@ -8804,6 +8862,7 @@ RenameStmt: ALTER AGGREGATE aggregate_with_argtypes RENAME TO name
 					n->subname = $6;
 					n->newname = $8;
 					n->missing_ok = false;
+                    n->concurrent = false;
 					$$ = (Node *)n;
 				}
 			| ALTER TABLE IF_P EXISTS relation_expr RENAME CONSTRAINT name TO name
@@ -8814,6 +8873,7 @@ RenameStmt: ALTER AGGREGATE aggregate_with_argtypes RENAME TO name
 					n->subname = $8;
 					n->newname = $10;
 					n->missing_ok = true;
+                    n->concurrent = false;
 					$$ = (Node *)n;
 				}
 			| ALTER FOREIGN TABLE relation_expr RENAME opt_column name TO name
@@ -8825,6 +8885,7 @@ RenameStmt: ALTER AGGREGATE aggregate_with_argtypes RENAME TO name
 					n->subname = $7;
 					n->newname = $9;
 					n->missing_ok = false;
+                    n->concurrent = false;
 					$$ = (Node *)n;
 				}
 			| ALTER FOREIGN TABLE IF_P EXISTS relation_expr RENAME opt_column name TO name
@@ -8836,6 +8897,7 @@ RenameStmt: ALTER AGGREGATE aggregate_with_argtypes RENAME TO name
 					n->subname = $9;
 					n->newname = $11;
 					n->missing_ok = true;
+                    n->concurrent = false;
 					$$ = (Node *)n;
 				}
 			| ALTER RULE name ON qualified_name RENAME TO name
@@ -8846,6 +8908,7 @@ RenameStmt: ALTER AGGREGATE aggregate_with_argtypes RENAME TO name
 					n->subname = $3;
 					n->newname = $8;
 					n->missing_ok = false;
+                    n->concurrent = false;
 					$$ = (Node *)n;
 				}
 			| ALTER TRIGGER name ON qualified_name RENAME TO name
@@ -8856,6 +8919,7 @@ RenameStmt: ALTER AGGREGATE aggregate_with_argtypes RENAME TO name
 					n->subname = $3;
 					n->newname = $8;
 					n->missing_ok = false;
+                    n->concurrent = false;
 					$$ = (Node *)n;
 				}
 			| ALTER EVENT TRIGGER name RENAME TO name
@@ -8864,6 +8928,7 @@ RenameStmt: ALTER AGGREGATE aggregate_with_argtypes RENAME TO name
 					n->renameType = OBJECT_EVENT_TRIGGER;
 					n->object = (Node *) makeString($4);
 					n->newname = $7;
+                    n->concurrent = false;
 					$$ = (Node *)n;
 				}
 			| ALTER ROLE RoleId RENAME TO RoleId
@@ -8873,6 +8938,7 @@ RenameStmt: ALTER AGGREGATE aggregate_with_argtypes RENAME TO name
 					n->subname = $3;
 					n->newname = $6;
 					n->missing_ok = false;
+                    n->concurrent = false;
 					$$ = (Node *)n;
 				}
 			| ALTER USER RoleId RENAME TO RoleId
@@ -8882,6 +8948,7 @@ RenameStmt: ALTER AGGREGATE aggregate_with_argtypes RENAME TO name
 					n->subname = $3;
 					n->newname = $6;
 					n->missing_ok = false;
+                    n->concurrent = false;
 					$$ = (Node *)n;
 				}
 			| ALTER TABLESPACE name RENAME TO name
@@ -8891,6 +8958,7 @@ RenameStmt: ALTER AGGREGATE aggregate_with_argtypes RENAME TO name
 					n->subname = $3;
 					n->newname = $6;
 					n->missing_ok = false;
+                    n->concurrent = false;
 					$$ = (Node *)n;
 				}
 			| ALTER STATISTICS any_name RENAME TO name
@@ -8900,6 +8968,7 @@ RenameStmt: ALTER AGGREGATE aggregate_with_argtypes RENAME TO name
 					n->object = (Node *) $3;
 					n->newname = $6;
 					n->missing_ok = false;
+                    n->concurrent = false;
 					$$ = (Node *)n;
 				}
 			| ALTER TEXT_P SEARCH PARSER any_name RENAME TO name
@@ -8909,6 +8978,7 @@ RenameStmt: ALTER AGGREGATE aggregate_with_argtypes RENAME TO name
 					n->object = (Node *) $5;
 					n->newname = $8;
 					n->missing_ok = false;
+                    n->concurrent = false;
 					$$ = (Node *)n;
 				}
 			| ALTER TEXT_P SEARCH DICTIONARY any_name RENAME TO name
@@ -8918,6 +8988,7 @@ RenameStmt: ALTER AGGREGATE aggregate_with_argtypes RENAME TO name
 					n->object = (Node *) $5;
 					n->newname = $8;
 					n->missing_ok = false;
+                    n->concurrent = false;
 					$$ = (Node *)n;
 				}
 			| ALTER TEXT_P SEARCH TEMPLATE any_name RENAME TO name
@@ -8927,6 +8998,7 @@ RenameStmt: ALTER AGGREGATE aggregate_with_argtypes RENAME TO name
 					n->object = (Node *) $5;
 					n->newname = $8;
 					n->missing_ok = false;
+                    n->concurrent = false;
 					$$ = (Node *)n;
 				}
 			| ALTER TEXT_P SEARCH CONFIGURATION any_name RENAME TO name
@@ -8936,6 +9008,7 @@ RenameStmt: ALTER AGGREGATE aggregate_with_argtypes RENAME TO name
 					n->object = (Node *) $5;
 					n->newname = $8;
 					n->missing_ok = false;
+                    n->concurrent = false;
 					$$ = (Node *)n;
 				}
 			| ALTER TYPE_P any_name RENAME TO name
@@ -8945,6 +9018,7 @@ RenameStmt: ALTER AGGREGATE aggregate_with_argtypes RENAME TO name
 					n->object = (Node *) $3;
 					n->newname = $6;
 					n->missing_ok = false;
+                    n->concurrent = false;
 					$$ = (Node *)n;
 				}
 			| ALTER TYPE_P any_name RENAME ATTRIBUTE name TO name opt_drop_behavior
@@ -8957,6 +9031,7 @@ RenameStmt: ALTER AGGREGATE aggregate_with_argtypes RENAME TO name
 					n->newname = $8;
 					n->behavior = $9;
 					n->missing_ok = false;
+                    n->concurrent = false;
 					$$ = (Node *)n;
 				}
 		;
diff --git a/src/include/commands/tablecmds.h b/src/include/commands/tablecmds.h
index 138de84..0e44958 100644
--- a/src/include/commands/tablecmds.h
+++ b/src/include/commands/tablecmds.h
@@ -67,7 +67,8 @@ extern ObjectAddress RenameConstraint(RenameStmt *stmt);
 extern ObjectAddress RenameRelation(RenameStmt *stmt);
 
 extern void RenameRelationInternal(Oid myrelid,
-					   const char *newrelname, bool is_internal);
+					   const char *newrelname, bool is_internal,
+                       bool concurrent);
 
 extern void find_composite_type_dependencies(Oid typeOid,
 								 Relation origRelation,
diff --git a/src/include/nodes/parsenodes.h b/src/include/nodes/parsenodes.h
index 2a2b17d..7609633 100644
--- a/src/include/nodes/parsenodes.h
+++ b/src/include/nodes/parsenodes.h
@@ -2849,6 +2849,7 @@ typedef struct RenameStmt
 	char	   *newname;		/* the new name */
 	DropBehavior behavior;		/* RESTRICT or CASCADE behavior */
 	bool		missing_ok;		/* skip error if missing? */
+    bool        concurrent;     /* for "RENAME CONCURRENTLY TO" */
 } RenameStmt;
 
 /* ----------------------
