set session/global 增强

This commit is contained in:
suncan
2022-08-30 15:55:22 +08:00
parent 61c70527a9
commit b4a6881506
28 changed files with 1542 additions and 37 deletions

View File

@ -48,6 +48,8 @@
#include "utils/plpgsql.h"
#include "utils/xml.h"
#include "funcapi.h"
#include "utils/guc.h"
#include "utils/guc_tables.h"
extern Node* makeAConst(Value* v, int location);
extern Value* makeStringValue(char* str);
@ -80,6 +82,7 @@ static Node* transformWholeRowRef(ParseState* pstate, RangeTblEntry* rte, int lo
static Node* transformIndirection(ParseState* pstate, Node* basenode, List* indirection);
static Node* transformTypeCast(ParseState* pstate, TypeCast* tc);
static Node* transformCollateClause(ParseState* pstate, CollateClause* c);
static Node* transformSetVariableExpr(SetVariableExpr* set);
static Node* make_row_comparison_op(ParseState* pstate, List* opname, List* largs, List* rargs, int location);
static Node* make_row_distinct_op(ParseState* pstate, List* opname, RowExpr* lrow, RowExpr* rrow, int location);
static Node* convertStarToCRef(RangeTblEntry* rte, char* catname, char* nspname, char* relname, int location);
@ -317,6 +320,10 @@ Node* transformExpr(ParseState* pstate, Node* expr)
result = transformPrefixKey(pstate, (PrefixKey*)expr);
break;
case T_SetVariableExpr:
result = transformSetVariableExpr((SetVariableExpr*)expr);
break;
/*********************************************
* Quietly accept node types that may be presented when we are
* called on an already-transformed tree.
@ -1840,6 +1847,23 @@ static Node* transformCaseExpr(ParseState* pstate, CaseExpr* c)
return (Node*)newc;
}
/*
* transformSetVariableExpr gets variable's value according to name and saves it in ConstExpr
*/
static Node* transformSetVariableExpr(SetVariableExpr* set)
{
SetVariableExpr *result = makeNode(SetVariableExpr);
result->name = set->name;
result->is_session = set->is_session;
result->is_global = set->is_global;
Const *values = setValueToConstExpr(set);
result->value = (Expr*)copyObject(values);
return (Node *)result;
}
static Node* transformSubLink(ParseState* pstate, SubLink* sublink)
{
Node* result = (Node*)sublink;