Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit7665e7b

Browse files
author
Thomas G. Lockhart
committed
Allows the following query to succeed: "SELECT NULL ORDER BY 1;"
There are three or four cases in transformSortClause() and I had fixedonly one case for UNION. A second case is now fixed, in the same way; Iassigned INT4OID to the column type for the "won't actually happen"sort. Didn't want to skip the code entirely, since the backend needs to_try_ a sort to get the NULLs right. I'm not certain under whatcircumstances the other cases are invoked and these are not yetfixed up, though perhaps they don't need to be...
1 parent39844ac commit7665e7b

File tree

1 file changed

+35
-1
lines changed

1 file changed

+35
-1
lines changed

‎src/backend/parser/parse_clause.c

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/parser/parse_clause.c,v 1.21 1998/07/14 03:51:42 thomas Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/parser/parse_clause.c,v 1.22 1998/08/02 13:34:26 thomas Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -317,6 +317,10 @@ transformSortClause(ParseState *pstate,
317317
{
318318
List*s=NIL;
319319

320+
#ifdefPARSEDEBUG
321+
printf("transformSortClause: entering\n");
322+
#endif
323+
320324
while (orderlist!=NIL)
321325
{
322326
SortGroupBy*sortby=lfirst(orderlist);
@@ -326,7 +330,17 @@ transformSortClause(ParseState *pstate,
326330

327331
restarget=find_targetlist_entry(pstate,sortby,targetlist);
328332

333+
#ifdefPARSEDEBUG
334+
printf("transformSortClause: find sorting operator for type %d\n",
335+
restarget->resdom->restype);
336+
#endif
337+
329338
sortcl->resdom=resdom=restarget->resdom;
339+
340+
/* if we have InvalidOid, then this is a NULL field and don't need to sort */
341+
if (resdom->restype==InvalidOid)
342+
resdom->restype=INT4OID;
343+
330344
sortcl->opoid=oprid(oper(sortby->useOp,
331345
resdom->restype,
332346
resdom->restype, false));
@@ -389,6 +403,14 @@ transformSortClause(ParseState *pstate,
389403
/* not a member of the sortclauses yet */
390404
SortClause*sortcl=makeNode(SortClause);
391405

406+
#ifdefPARSEDEBUG
407+
printf("transformSortClause: (2) find sorting operator for type %d\n",
408+
tlelt->resdom->restype);
409+
#endif
410+
411+
if (tlelt->resdom->restype==InvalidOid)
412+
tlelt->resdom->restype=INT4OID;
413+
392414
sortcl->resdom=tlelt->resdom;
393415
sortcl->opoid=any_ordering_op(tlelt->resdom->restype);
394416

@@ -423,6 +445,11 @@ transformSortClause(ParseState *pstate,
423445
/* not a member of the sortclauses yet */
424446
SortClause*sortcl=makeNode(SortClause);
425447

448+
#ifdefPARSEDEBUG
449+
printf("transformSortClause: try sorting type %d\n",
450+
tlelt->resdom->restype);
451+
#endif
452+
426453
sortcl->resdom=tlelt->resdom;
427454
sortcl->opoid=any_ordering_op(tlelt->resdom->restype);
428455

@@ -485,6 +512,13 @@ printf("transformUnionClause: types are %d -> %d\n", itype, otype);
485512
{
486513
((TargetEntry*)lfirst(prev_target))->resdom->restype=itype;
487514
}
515+
#ifFALSE
516+
else
517+
{
518+
((TargetEntry*)lfirst(prev_target))->resdom->restype=UNKNOWNOID;
519+
((TargetEntry*)lfirst(next_target))->resdom->restype=UNKNOWNOID;
520+
}
521+
#endif
488522
}
489523
elseif (itype==InvalidOid)
490524
{

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp