fix-deparse-stmt-qualify
Onur Tirtir 2023-10-03 16:41:41 +03:00
parent 0dca65c84d
commit a2738438bf
2 changed files with 15 additions and 0 deletions

View File

@ -18,6 +18,7 @@
#include "distributed/coordinator_protocol.h" #include "distributed/coordinator_protocol.h"
#include "distributed/listutils.h" #include "distributed/listutils.h"
#include "distributed/metadata_cache.h" #include "distributed/metadata_cache.h"
#include "distributed/namespace_utils.h"
#include "miscadmin.h" #include "miscadmin.h"
#include "nodes/makefuncs.h" #include "nodes/makefuncs.h"
#include "parser/parse_clause.h" #include "parser/parse_clause.h"
@ -146,15 +147,21 @@ CreatePolicyCommandForPolicy(Oid relationId, RowSecurityPolicy *policy)
if (policy->qual) if (policy->qual)
{ {
int saveNestLevel = PushEmptySearchPath();
char *qualString = deparse_expression((Node *) (policy->qual), char *qualString = deparse_expression((Node *) (policy->qual),
relationContext, false, false); relationContext, false, false);
PopEmptySearchPath(saveNestLevel);
appendStringInfo(createPolicyCommand, " USING (%s)", qualString); appendStringInfo(createPolicyCommand, " USING (%s)", qualString);
} }
if (policy->with_check_qual) if (policy->with_check_qual)
{ {
int saveNestLevel = PushEmptySearchPath();
char *withCheckQualString = deparse_expression( char *withCheckQualString = deparse_expression(
(Node *) (policy->with_check_qual), relationContext, false, false); (Node *) (policy->with_check_qual), relationContext, false, false);
PopEmptySearchPath(saveNestLevel);
appendStringInfo(createPolicyCommand, " WITH CHECK (%s)", appendStringInfo(createPolicyCommand, " WITH CHECK (%s)",
withCheckQualString); withCheckQualString);
} }
@ -380,7 +387,10 @@ PreprocessAlterPolicyStmt(Node *node, const char *queryString,
{ {
ErrorIfUnsupportedPolicyExpr(qual); ErrorIfUnsupportedPolicyExpr(qual);
int saveNestLevel = PushEmptySearchPath();
char *qualString = deparse_expression(qual, relationContext, false, false); char *qualString = deparse_expression(qual, relationContext, false, false);
PopEmptySearchPath(saveNestLevel);
appendStringInfo(&ddlString, " USING (%s)", qualString); appendStringInfo(&ddlString, " USING (%s)", qualString);
} }
@ -394,9 +404,12 @@ PreprocessAlterPolicyStmt(Node *node, const char *queryString,
{ {
ErrorIfUnsupportedPolicyExpr(with_check_qual); ErrorIfUnsupportedPolicyExpr(with_check_qual);
int saveNestLevel = PushEmptySearchPath();
char *withCheckString = deparse_expression(with_check_qual, relationContext, char *withCheckString = deparse_expression(with_check_qual, relationContext,
false, false,
false); false);
PopEmptySearchPath(saveNestLevel);
appendStringInfo(&ddlString, " WITH CHECK (%s)", withCheckString); appendStringInfo(&ddlString, " WITH CHECK (%s)", withCheckString);
} }

View File

@ -312,7 +312,9 @@ AppendAlterTableCmdConstraint(StringInfo buf, Constraint *constraint,
char *relationName = get_rel_name(leftRelationId); char *relationName = get_rel_name(leftRelationId);
List *relationCtx = deparse_context_for(relationName, leftRelationId); List *relationCtx = deparse_context_for(relationName, leftRelationId);
int saveNestLevel = PushEmptySearchPath();
char *exprSql = deparse_expression(exprCooked, relationCtx, false, false); char *exprSql = deparse_expression(exprCooked, relationCtx, false, false);
PopEmptySearchPath(saveNestLevel);
relation_close(relation, NoLock); relation_close(relation, NoLock);