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

Commitcdbdf85

Browse files
committed
Fix some probably-minor oversights in readfuncs.c.
The system expects TABLEFUNC RTEs to have coltypes, coltypmods, andcolcollations lists, but outfuncs doesn't dump them and readfuncs doesn'trestore them. This doesn't cause obvious failures, because the only thingsthat look at those fields are expandRTE() and get_rte_attribute_type(),which are mostly used during parse analysis, before anything would'vepassed the parsetree through outfuncs/readfuncs. But expandRTE() is usedin build_physical_tlist(), which means that that function will return awrong answer for a TABLEFUNC RTE that came from a view. Very accidentally,this doesn't cause serious problems, because what it will return is NILwhich callers will interpret as "couldn't build a physical tlist becauseof dropped columns". So you still get a plan that works, though it'smarginally less efficient than it could be. There are also some otherexpandRTE() calls associated with transformation of whole-row Vars inthe planner. I have been unable to exhibit misbehavior from that, andit may be unreachable in any case that anyone would care about ... butI'm not entirely convinced, so this seems like something we should back-patch a fix for. Fortunately, we can fix it without forcing a changeof stored rules and a catversion bump, because we can just copy theselists from the subsidiary TableFunc object.readfuncs.c was also missing support for NamedTuplestoreScan plan nodes.This accidentally fails to break parallel query because a query usinga named tuplestore would never be considered parallel-safe anyway.However, project policy since parallel query came in is that all plannode types should have outfuncs/readfuncs support, so this is clearlyan oversight that should be repaired.Noted while fooling around with a patch to test outfuncs/readfuncs morethoroughly. That exposed some other issues too, but these are the onlyones that seem worth back-patching.Back-patch to v10 where both of these features came in.Discussion:https://postgr.es/m/17114.1537138992@sss.pgh.pa.us
1 parent7167fa8 commitcdbdf85

File tree

2 files changed

+30
-2
lines changed

2 files changed

+30
-2
lines changed

‎src/backend/nodes/readfuncs.c

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1355,6 +1355,15 @@ _readRangeTblEntry(void)
13551355
break;
13561356
caseRTE_TABLEFUNC:
13571357
READ_NODE_FIELD(tablefunc);
1358+
/* The RTE must have a copy of the column type info, if any */
1359+
if (local_node->tablefunc)
1360+
{
1361+
TableFunc*tf=local_node->tablefunc;
1362+
1363+
local_node->coltypes=tf->coltypes;
1364+
local_node->coltypmods=tf->coltypmods;
1365+
local_node->colcollations=tf->colcollations;
1366+
}
13581367
break;
13591368
caseRTE_VALUES:
13601369
READ_NODE_FIELD(values_lists);
@@ -1889,6 +1898,21 @@ _readCteScan(void)
18891898
READ_DONE();
18901899
}
18911900

1901+
/*
1902+
* _readNamedTuplestoreScan
1903+
*/
1904+
staticNamedTuplestoreScan*
1905+
_readNamedTuplestoreScan(void)
1906+
{
1907+
READ_LOCALS(NamedTuplestoreScan);
1908+
1909+
ReadCommonScan(&local_node->scan);
1910+
1911+
READ_STRING_FIELD(enrname);
1912+
1913+
READ_DONE();
1914+
}
1915+
18921916
/*
18931917
* _readWorkTableScan
18941918
*/
@@ -2605,6 +2629,8 @@ parseNodeString(void)
26052629
return_value=_readTableFuncScan();
26062630
elseif (MATCH("CTESCAN",7))
26072631
return_value=_readCteScan();
2632+
elseif (MATCH("NAMEDTUPLESTORESCAN",19))
2633+
return_value=_readNamedTuplestoreScan();
26082634
elseif (MATCH("WORKTABLESCAN",13))
26092635
return_value=_readWorkTableScan();
26102636
elseif (MATCH("FOREIGNSCAN",11))

‎src/include/nodes/parsenodes.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1019,15 +1019,17 @@ typedef struct RangeTblEntry
10191019
boolself_reference;/* is this a recursive self-reference? */
10201020

10211021
/*
1022-
* Fields valid fortable functions, values, CTEandENR RTEs (else NIL):
1022+
* Fields valid forCTE, VALUES, ENR,andTableFunc RTEs (else NIL):
10231023
*
10241024
* We need these for CTE RTEs so that the types of self-referential
10251025
* columns are well-defined. For VALUES RTEs, storing these explicitly
10261026
* saves having to re-determine the info by scanning the values_lists. For
10271027
* ENRs, we store the types explicitly here (we could get the information
10281028
* from the catalogs if 'relid' was supplied, but we'd still need these
10291029
* for TupleDesc-based ENRs, so we might as well always store the type
1030-
* info here).
1030+
* info here). For TableFuncs, these fields are redundant with data in
1031+
* the TableFunc node, but keeping them here allows some code sharing with
1032+
* the other cases.
10311033
*
10321034
* For ENRs only, we have to consider the possibility of dropped columns.
10331035
* A dropped column is included in these lists, but it will have zeroes in

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp