Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit aebeb47

Browse files
committed
Remove vestigial resolveUnknown arguments from transformSortClause etc.
There's really no situation where we don't want these unknown-to-text conversions to happen. The alternative is failure anyway, and the one caller that was passing "false" did so only because it expected the case could not arise. Might as well simplify the code. Discussion: https://postgr.es/m/CAH2L28uwwbL9HUM-WR=hromW1Cvamkn7O-g8fPY2m=_7muJ0oA@mail.gmail.com
1 parent 87ecf2d commit aebeb47

File tree

4 files changed

+12
-37
lines changed

4 files changed

+12
-37
lines changed

src/backend/parser/analyze.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1232,7 +1232,6 @@ transformSelectStmt(ParseState *pstate, SelectStmt *stmt)
12321232
stmt->sortClause,
12331233
&qry->targetList,
12341234
EXPR_KIND_ORDER_BY,
1235-
true /* fix unknowns */ ,
12361235
false /* allow SQL92 rules */ );
12371236

12381237
qry->groupClause = transformGroupClause(pstate,
@@ -1512,7 +1511,6 @@ transformValuesClause(ParseState *pstate, SelectStmt *stmt)
15121511
stmt->sortClause,
15131512
&qry->targetList,
15141513
EXPR_KIND_ORDER_BY,
1515-
true /* fix unknowns */ ,
15161514
false /* allow SQL92 rules */ );
15171515

15181516
qry->limitOffset = transformLimitClause(pstate, stmt->limitOffset,
@@ -1736,7 +1734,6 @@ transformSetOperationStmt(ParseState *pstate, SelectStmt *stmt)
17361734
sortClause,
17371735
&qry->targetList,
17381736
EXPR_KIND_ORDER_BY,
1739-
false /* no unknowns expected */ ,
17401737
false /* allow SQL92 rules */ );
17411738

17421739
/* restore namespace, remove jrte from rtable */

src/backend/parser/parse_agg.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -155,8 +155,7 @@ transformAggregateCall(ParseState *pstate, Aggref *agg,
155155
tlist = lappend(tlist, tle);
156156

157157
torder = addTargetToSortList(pstate, tle,
158-
torder, tlist, sortby,
159-
true /* fix unknowns */ );
158+
torder, tlist, sortby);
160159
}
161160

162161
/* Never any DISTINCT in an ordered-set agg */
@@ -196,7 +195,6 @@ transformAggregateCall(ParseState *pstate, Aggref *agg,
196195
aggorder,
197196
&tlist,
198197
EXPR_KIND_ORDER_BY,
199-
true /* fix unknowns */ ,
200198
true /* force SQL99 rules */ );
201199

202200
/*

src/backend/parser/parse_clause.c

Lines changed: 9 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,7 @@ static int get_matching_location(int sortgroupref,
8989
static List *resolve_unique_index_expr(ParseState *pstate, InferClause *infer,
9090
Relation heapRel);
9191
static List *addTargetToGroupList(ParseState *pstate, TargetEntry *tle,
92-
List *grouplist, List *targetlist, int location,
93-
bool resolveUnknown);
92+
List *grouplist, List *targetlist, int location);
9493
static WindowClause *findWindowClause(List *wclist, const char *name);
9594
static Node *transformFrameOffset(ParseState *pstate, int frameOptions,
9695
Node *clause);
@@ -2011,8 +2010,7 @@ transformGroupClauseExpr(List **flatresult, Bitmapset *seen_local,
20112010
if (!found)
20122011
*flatresult = addTargetToGroupList(pstate, tle,
20132012
*flatresult, *targetlist,
2014-
exprLocation(gexpr),
2015-
true);
2013+
exprLocation(gexpr));
20162014

20172015
/*
20182016
* _something_ must have assigned us a sortgroupref by now...
@@ -2300,7 +2298,6 @@ transformSortClause(ParseState *pstate,
23002298
List *orderlist,
23012299
List **targetlist,
23022300
ParseExprKind exprKind,
2303-
bool resolveUnknown,
23042301
bool useSQL99)
23052302
{
23062303
List *sortlist = NIL;
@@ -2319,8 +2316,7 @@ transformSortClause(ParseState *pstate,
23192316
targetlist, exprKind);
23202317

23212318
sortlist = addTargetToSortList(pstate, tle,
2322-
sortlist, *targetlist, sortby,
2323-
resolveUnknown);
2319+
sortlist, *targetlist, sortby);
23242320
}
23252321

23262322
return sortlist;
@@ -2382,7 +2378,6 @@ transformWindowDefinitions(ParseState *pstate,
23822378
windef->orderClause,
23832379
targetlist,
23842380
EXPR_KIND_WINDOW_ORDER,
2385-
true /* fix unknowns */ ,
23862381
true /* force SQL99 rules */ );
23872382
partitionClause = transformGroupClause(pstate,
23882383
windef->partitionClause,
@@ -2553,8 +2548,7 @@ transformDistinctClause(ParseState *pstate,
25532548
continue; /* ignore junk */
25542549
result = addTargetToGroupList(pstate, tle,
25552550
result, *targetlist,
2556-
exprLocation((Node *) tle->expr),
2557-
true);
2551+
exprLocation((Node *) tle->expr));
25582552
}
25592553

25602554
/*
@@ -2671,8 +2665,7 @@ transformDistinctOnClause(ParseState *pstate, List *distinctlist,
26712665
parser_errposition(pstate, exprLocation(dexpr))));
26722666
result = addTargetToGroupList(pstate, tle,
26732667
result, *targetlist,
2674-
exprLocation(dexpr),
2675-
true);
2668+
exprLocation(dexpr));
26762669
}
26772670

26782671
/*
@@ -2906,17 +2899,11 @@ transformOnConflictArbiter(ParseState *pstate,
29062899
* list, add it to the end of the list, using the given sort ordering
29072900
* info.
29082901
*
2909-
* If resolveUnknown is TRUE, convert TLEs of type UNKNOWN to TEXT. If not,
2910-
* do nothing (which implies the search for a sort operator will fail).
2911-
* pstate should be provided if resolveUnknown is TRUE, but can be NULL
2912-
* otherwise.
2913-
*
29142902
* Returns the updated SortGroupClause list.
29152903
*/
29162904
List *
29172905
addTargetToSortList(ParseState *pstate, TargetEntry *tle,
2918-
List *sortlist, List *targetlist, SortBy *sortby,
2919-
bool resolveUnknown)
2906+
List *sortlist, List *targetlist, SortBy *sortby)
29202907
{
29212908
Oid restype = exprType((Node *) tle->expr);
29222909
Oid sortop;
@@ -2927,7 +2914,7 @@ addTargetToSortList(ParseState *pstate, TargetEntry *tle,
29272914
ParseCallbackState pcbstate;
29282915

29292916
/* if tlist item is an UNKNOWN literal, change it to TEXT */
2930-
if (restype == UNKNOWNOID && resolveUnknown)
2917+
if (restype == UNKNOWNOID)
29312918
{
29322919
tle->expr = (Expr *) coerce_type(pstate, (Node *) tle->expr,
29332920
restype, TEXTOID, -1,
@@ -3055,22 +3042,16 @@ addTargetToSortList(ParseState *pstate, TargetEntry *tle,
30553042
* to a SELECT item that matches the GROUP BY item; it'd be pretty confusing
30563043
* to report such a location.
30573044
*
3058-
* If resolveUnknown is TRUE, convert TLEs of type UNKNOWN to TEXT. If not,
3059-
* do nothing (which implies the search for an equality operator will fail).
3060-
* pstate should be provided if resolveUnknown is TRUE, but can be NULL
3061-
* otherwise.
3062-
*
30633045
* Returns the updated SortGroupClause list.
30643046
*/
30653047
static List *
30663048
addTargetToGroupList(ParseState *pstate, TargetEntry *tle,
3067-
List *grouplist, List *targetlist, int location,
3068-
bool resolveUnknown)
3049+
List *grouplist, List *targetlist, int location)
30693050
{
30703051
Oid restype = exprType((Node *) tle->expr);
30713052

30723053
/* if tlist item is an UNKNOWN literal, change it to TEXT */
3073-
if (restype == UNKNOWNOID && resolveUnknown)
3054+
if (restype == UNKNOWNOID)
30743055
{
30753056
tle->expr = (Expr *) coerce_type(pstate, (Node *) tle->expr,
30763057
restype, TEXTOID, -1,

src/include/parser/parse_clause.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ extern List *transformGroupClause(ParseState *pstate, List *grouplist,
3131
ParseExprKind exprKind, bool useSQL99);
3232
extern List *transformSortClause(ParseState *pstate, List *orderlist,
3333
List **targetlist, ParseExprKind exprKind,
34-
bool resolveUnknown, bool useSQL99);
34+
bool useSQL99);
3535

3636
extern List *transformWindowDefinitions(ParseState *pstate,
3737
List *windowdefs,
@@ -47,8 +47,7 @@ extern void transformOnConflictArbiter(ParseState *pstate,
4747
Oid *constraint);
4848

4949
extern List *addTargetToSortList(ParseState *pstate, TargetEntry *tle,
50-
List *sortlist, List *targetlist, SortBy *sortby,
51-
bool resolveUnknown);
50+
List *sortlist, List *targetlist, SortBy *sortby);
5251
extern Index assignSortGroupRef(TargetEntry *tle, List *tlist);
5352
extern bool targetIsInSortList(TargetEntry *tle, Oid sortop, List *sortList);
5453

0 commit comments

Comments
 (0)