mirror of https://github.com/citusdata/citus.git
Support PostgreSQL 18’s new RTE kinds in Citus deparser to fix OID 0
Enhance set_relation_column_names to handle relid validation and support for synthetic PG 18 RTEs Handle unnamed groups in set_rtable_names by using the group's namem3hm3t/pg18_dev_relation_oid_0
parent
3f9e12e010
commit
8aaf7bca34
|
@ -0,0 +1 @@
|
|||
Subproject commit 3376bd6845f0614908ed304f5033bd644c82d3bf
|
|
@ -795,6 +795,11 @@ set_rtable_names(deparse_namespace *dpns, List *parent_namespaces,
|
|||
/* Unnamed join has no refname */
|
||||
refname = NULL;
|
||||
}
|
||||
else if (rte->rtekind == RTE_GROUP)
|
||||
{
|
||||
/* Use the name of the group */
|
||||
refname = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Otherwise use whatever the parser assigned */
|
||||
|
@ -1191,8 +1196,9 @@ set_relation_column_names(deparse_namespace *dpns, RangeTblEntry *rte,
|
|||
* real_colnames[] will be indexed by physical column number, with NULL
|
||||
* entries for dropped columns.
|
||||
*/
|
||||
if (rte->rtekind == RTE_RELATION ||
|
||||
GetRangeTblKind(rte) == CITUS_RTE_SHARD)
|
||||
if ((rte->rtekind == RTE_RELATION ||
|
||||
GetRangeTblKind(rte) == CITUS_RTE_SHARD) &&
|
||||
OidIsValid(rte->relid))
|
||||
{
|
||||
/* Relation --- look to the system catalogs for up-to-date info */
|
||||
Relation rel;
|
||||
|
@ -1214,6 +1220,28 @@ set_relation_column_names(deparse_namespace *dpns, RangeTblEntry *rte,
|
|||
real_colnames[i] = pstrdup(NameStr(attr->attname));
|
||||
}
|
||||
relation_close(rel, AccessShareLock);
|
||||
}
|
||||
else if (GetRangeTblKind(rte) == CITUS_RTE_SHARD)
|
||||
{
|
||||
/* shard RTE without relid (pulled-up clone in PG18) */
|
||||
/* use the column aliases already stored in rte->eref->colnames */
|
||||
|
||||
ncolumns = list_length(rte->eref->colnames);
|
||||
real_colnames = (char **) palloc0(ncolumns * sizeof(char *));
|
||||
|
||||
for (i = 0; i < ncolumns; i++)
|
||||
real_colnames[i] = pstrdup(strVal(list_nth(rte->eref->colnames, i)));
|
||||
|
||||
/* keep changed_any / has_anonymous defaults */
|
||||
}
|
||||
else if (rte->rtekind == RTE_GROUP)
|
||||
{
|
||||
/* ----- synthetic PG 18 RTE for GROUP BY / HAVING ----- */
|
||||
ncolumns = list_length(rte->eref->colnames);
|
||||
real_colnames = (char **) palloc0(ncolumns * sizeof(char *));
|
||||
|
||||
for (i = 0; i < ncolumns; i++)
|
||||
real_colnames[i] = pstrdup(strVal(list_nth(rte->eref->colnames, i)));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue