forked from huawei/openGauss-server
suspend warning if column can be found in upper query
This commit is contained in:
parent
588299a50a
commit
ccc875f391
|
|
@ -122,8 +122,8 @@ static void transformStartWithClause(StartWithTransformContext *context, SelectS
|
||||||
|
|
||||||
static List *expandAllTargetList(List *targetRelInfoList);
|
static List *expandAllTargetList(List *targetRelInfoList);
|
||||||
|
|
||||||
static List *ExtractColumnRefStartInfo(ParseState *pstate, ColumnRef *column,
|
static List *ExtractColumnRefStartInfo(ParseState *pstate, ColumnRef *column, char *relname, char *colname,
|
||||||
char *relname, char *colname);
|
Node *preResult);
|
||||||
static void HandleSWCBColumnRef(StartWithTransformContext* context, Node *node);
|
static void HandleSWCBColumnRef(StartWithTransformContext* context, Node *node);
|
||||||
static void StartWithWalker(StartWithTransformContext *context, Node *expr);
|
static void StartWithWalker(StartWithTransformContext *context, Node *expr);
|
||||||
static void AddWithClauseToBranch(ParseState *pstate, SelectStmt *stmt, List *relInfoList);
|
static void AddWithClauseToBranch(ParseState *pstate, SelectStmt *stmt, List *relInfoList);
|
||||||
|
|
@ -534,6 +534,21 @@ static bool preSkipPLSQLParams(ParseState *pstate, ColumnRef *cref)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param preResult Var struct
|
||||||
|
* @return true if is a upper query column
|
||||||
|
*/
|
||||||
|
static inline bool IsAUpperQueryColumn(Node *preResult)
|
||||||
|
{
|
||||||
|
if (IsA(preResult, Var)) {
|
||||||
|
Var *varNode = (Var *)preResult;
|
||||||
|
if (!IS_SPECIAL_VARNO(varNode->varno) && varNode->varlevelsup >= 1) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* --------------------------------------------------------------------------------------
|
* --------------------------------------------------------------------------------------
|
||||||
* @Brief: to be input
|
* @Brief: to be input
|
||||||
|
|
@ -543,8 +558,8 @@ static bool preSkipPLSQLParams(ParseState *pstate, ColumnRef *cref)
|
||||||
* @Return: to be input
|
* @Return: to be input
|
||||||
* --------------------------------------------------------------------------------------
|
* --------------------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
static List *ExtractColumnRefStartInfo(ParseState *pstate, ColumnRef *column,
|
static List *ExtractColumnRefStartInfo(ParseState *pstate, ColumnRef *column, char *relname, char *colname,
|
||||||
char *relname, char *colname)
|
Node *preResult)
|
||||||
{
|
{
|
||||||
ListCell *lc1 = NULL;
|
ListCell *lc1 = NULL;
|
||||||
ListCell *lc2 = NULL;
|
ListCell *lc2 = NULL;
|
||||||
|
|
@ -613,7 +628,7 @@ static List *ExtractColumnRefStartInfo(ParseState *pstate, ColumnRef *column,
|
||||||
errmsg("column reference \"%s\" is ambiguous.", colname)));
|
errmsg("column reference \"%s\" is ambiguous.", colname)));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (list_length(extract_infos) == 0) {
|
if (list_length(extract_infos) == 0 && !IsAUpperQueryColumn(preResult)) {
|
||||||
ereport(WARNING,
|
ereport(WARNING,
|
||||||
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
||||||
errmsg("Cannot match table with startwith/connectby column %s.%s, maybe it is a upper query column",
|
errmsg("Cannot match table with startwith/connectby column %s.%s, maybe it is a upper query column",
|
||||||
|
|
@ -678,7 +693,7 @@ static void HandleSWCBColumnRef(StartWithTransformContext *context, Node *node)
|
||||||
* which will be helpful for after SWCB rewrite. So here columnref will contain
|
* which will be helpful for after SWCB rewrite. So here columnref will contain
|
||||||
* two fields after ExtractColumnRefStartInfo.
|
* two fields after ExtractColumnRefStartInfo.
|
||||||
*/
|
*/
|
||||||
result = ExtractColumnRefStartInfo(pstate, column, NULL, colname);
|
result = ExtractColumnRefStartInfo(pstate, column, NULL, colname, preResult);
|
||||||
|
|
||||||
if (prior) {
|
if (prior) {
|
||||||
char *dummy = makeStartWithDummayColname(
|
char *dummy = makeStartWithDummayColname(
|
||||||
|
|
@ -700,7 +715,7 @@ static void HandleSWCBColumnRef(StartWithTransformContext *context, Node *node)
|
||||||
relname = strVal(field1);
|
relname = strVal(field1);
|
||||||
colname = strVal(field2);
|
colname = strVal(field2);
|
||||||
|
|
||||||
result = ExtractColumnRefStartInfo(pstate, column, relname, colname);
|
result = ExtractColumnRefStartInfo(pstate, column, relname, colname, preResult);
|
||||||
|
|
||||||
if (prior) {
|
if (prior) {
|
||||||
char *dummy = makeStartWithDummayColname(strVal(linitial(column->fields)),
|
char *dummy = makeStartWithDummayColname(strVal(linitial(column->fields)),
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue