@ -5532,9 +5532,21 @@ get_insert_query_def(Query *query, deparse_context *context)
/* Add a WHERE clause (for partial indexes) if given */
if ( confl - > arbiterWhere ! = NULL )
{
bool save_varprefix ;
/*
* Force non - prefixing of Vars , since parser assumes that they
* belong to target relation . WHERE clause does not use
* InferenceElem , so this is separately required .
*/
save_varprefix = context - > varprefix ;
context - > varprefix = false ;
appendContextKeyword ( context , " WHERE " ,
- PRETTYINDENT_STD , PRETTYINDENT_STD , 1 ) ;
get_rule_expr ( confl - > arbiterWhere , context , false ) ;
context - > varprefix = save_varprefix ;
}
}
else if ( confl - > constraint ! = InvalidOid )
@ -7956,13 +7968,14 @@ get_rule_expr(Node *node, deparse_context *context,
case T_InferenceElem :
{
InferenceElem * iexpr = ( InferenceElem * ) node ;
bool varprefix = context - > varprefix ;
bool save_ varprefix;
bool need_parens ;
/*
* InferenceElem can only refer to target relation , so a
* prefix is never useful .
* prefix is not useful , and indeed would cause parse errors .
*/
save_varprefix = context - > varprefix ;
context - > varprefix = false ;
/*
@ -7982,7 +7995,7 @@ get_rule_expr(Node *node, deparse_context *context,
if ( need_parens )
appendStringInfoChar ( buf , ' ) ' ) ;
context - > varprefix = varprefix ;
context - > varprefix = save_ varprefix;
if ( iexpr - > infercollid )
appendStringInfo ( buf , " COLLATE %s " ,