Get ready for Improve index backed constraint creation for online rebalancer

See:
https://github.com/citusdata/citus-enterprise/issues/616
pull/5054/head
Onder Kalaci 2021-06-16 12:23:43 +03:00
parent 27c7d28f7f
commit bc09288651
2 changed files with 22 additions and 16 deletions

View File

@ -799,28 +799,32 @@ GatherIndexAndConstraintDefinitionList(Form_pg_index indexForm, List **indexDDLE
int indexFlags)
{
Oid indexId = indexForm->indexrelid;
char *statementDef = NULL;
bool indexImpliedByConstraint = IndexImpliedByAConstraint(indexForm);
/* get the corresponding constraint or index statement */
if (indexImpliedByConstraint)
{
Oid constraintId = get_index_constraint(indexId);
Assert(constraintId != InvalidOid);
if (indexFlags & INCLUDE_CREATE_CONSTRAINT_STATEMENTS)
{
Oid constraintId = get_index_constraint(indexId);
Assert(constraintId != InvalidOid);
statementDef = pg_get_constraintdef_command(constraintId);
/* include constraints backed by indexes only when explicitly asked */
char *statementDef = pg_get_constraintdef_command(constraintId);
*indexDDLEventList =
lappend(*indexDDLEventList,
makeTableDDLCommandString(statementDef));
}
}
else
else if (indexFlags & INCLUDE_CREATE_INDEX_STATEMENTS)
{
statementDef = pg_get_indexdef_string(indexId);
}
/* append found constraint or index definition to the list */
if (indexFlags & INCLUDE_CREATE_INDEX_STATEMENTS)
{
*indexDDLEventList = lappend(*indexDDLEventList, makeTableDDLCommandString(
statementDef));
/*
* Include indexes that are not backing constraints only when
* explicitly asked.
*/
char *statementDef = pg_get_indexdef_string(indexId);
*indexDDLEventList = lappend(*indexDDLEventList,
makeTableDDLCommandString(statementDef));
}
/* if table is clustered on this index, append definition to the list */

View File

@ -101,9 +101,11 @@ typedef enum TableDDLCommandType
typedef enum IndexDefinitionDeparseFlags
{
INCLUDE_CREATE_INDEX_STATEMENTS = 1 << 0,
INCLUDE_INDEX_CLUSTERED_STATEMENTS = 1 << 1,
INCLUDE_INDEX_STATISTICS_STATEMENTTS = 1 << 2,
INCLUDE_CREATE_CONSTRAINT_STATEMENTS = 1 << 1,
INCLUDE_INDEX_CLUSTERED_STATEMENTS = 1 << 2,
INCLUDE_INDEX_STATISTICS_STATEMENTTS = 1 << 3,
INCLUDE_INDEX_ALL_STATEMENTS = INCLUDE_CREATE_INDEX_STATEMENTS |
INCLUDE_CREATE_CONSTRAINT_STATEMENTS |
INCLUDE_INDEX_CLUSTERED_STATEMENTS |
INCLUDE_INDEX_STATISTICS_STATEMENTTS
} IndexDefinitionDeparseFlags;