mirror of
https://github.com/postgres/postgres.git
synced 2025-07-08 11:42:09 +03:00
Add infrastructure to support EphemeralNamedRelation references.
A QueryEnvironment concept is added, which allows new types of objects to be passed into queries from parsing on through execution. At this point, the only thing implemented is a collection of EphemeralNamedRelation objects -- relations which can be referenced by name in queries, but do not exist in the catalogs. The only type of ENR implemented is NamedTuplestore, but provision is made to add more types fairly easily. An ENR can carry its own TupleDesc or reference a relation in the catalogs by relid. Although these features can be used without SPI, convenience functions are added to SPI so that ENRs can easily be used by code run through SPI. The initial use of all this is going to be transition tables in AFTER triggers, but that will be added to each PL as a separate commit. An incidental effect of this patch is to produce a more informative error message if an attempt is made to modify the contents of a CTE from a referencing DML statement. No tests previously covered that possibility, so one is added. Kevin Grittner and Thomas Munro Reviewed by Heikki Linnakangas, David Fetter, and Thomas Munro with valuable comments and suggestions from many others
This commit is contained in:
@ -631,6 +631,16 @@ _outCteScan(StringInfo str, const CteScan *node)
|
||||
WRITE_INT_FIELD(cteParam);
|
||||
}
|
||||
|
||||
static void
|
||||
_outNamedTuplestoreScan(StringInfo str, const NamedTuplestoreScan *node)
|
||||
{
|
||||
WRITE_NODE_TYPE("NAMEDTUPLESTORESCAN");
|
||||
|
||||
_outScanInfo(str, (const Scan *) node);
|
||||
|
||||
WRITE_STRING_FIELD(enrname);
|
||||
}
|
||||
|
||||
static void
|
||||
_outWorkTableScan(StringInfo str, const WorkTableScan *node)
|
||||
{
|
||||
@ -3024,6 +3034,13 @@ _outRangeTblEntry(StringInfo str, const RangeTblEntry *node)
|
||||
WRITE_NODE_FIELD(coltypmods);
|
||||
WRITE_NODE_FIELD(colcollations);
|
||||
break;
|
||||
case RTE_NAMEDTUPLESTORE:
|
||||
WRITE_STRING_FIELD(enrname);
|
||||
WRITE_OID_FIELD(relid);
|
||||
WRITE_NODE_FIELD(coltypes);
|
||||
WRITE_NODE_FIELD(coltypmods);
|
||||
WRITE_NODE_FIELD(colcollations);
|
||||
break;
|
||||
default:
|
||||
elog(ERROR, "unrecognized RTE kind: %d", (int) node->rtekind);
|
||||
break;
|
||||
@ -3621,6 +3638,9 @@ outNode(StringInfo str, const void *obj)
|
||||
case T_CteScan:
|
||||
_outCteScan(str, obj);
|
||||
break;
|
||||
case T_NamedTuplestoreScan:
|
||||
_outNamedTuplestoreScan(str, obj);
|
||||
break;
|
||||
case T_WorkTableScan:
|
||||
_outWorkTableScan(str, obj);
|
||||
break;
|
||||
|
Reference in New Issue
Block a user