Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 21 additions & 4 deletions contrib/pax_storage/src/cpp/catalog/pax_aux_table.cc
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,11 @@ void CPaxCreateMicroPartitionTable(Relation rel) {
pax_relid = RelationGetRelid(rel);

// 1. create blocks table.
//
// The aux relation always lives in pg_ext_aux, regardless of the
// parent's persistence. See the persistence selection comment on
// the heap_create_with_catalog call below for why TEMP parents'
// aux is clamped to PERMANENT rather than passed through.
snprintf(aux_relname, sizeof(aux_relname), "pg_pax_blocks_%u", pax_relid);
aux_namespace_id = PG_EXTAUX_NAMESPACE;
aux_relid = GetNewOidForRelation(pg_class_desc, ClassOidIndexId,
Expand Down Expand Up @@ -121,14 +126,26 @@ void CPaxCreateMicroPartitionTable(Relation rel) {
attr->attnotnull = true;
}

// FIXME: temporary table in aux namespace is not supported yet.
/*
* Aux inherits the parent's persistence for PERMANENT / UNLOGGED.
* TEMP is clamped down to PERMANENT: the aux lives in pg_ext_aux
* (NOT in pg_temp_<N>), so a TEMP-persistence row there would
* mis-trigger RELATION_IS_OTHER_TEMP — relcache sets
* rd_islocaltemp=false because pg_ext_aux is not a temp namespace,
* and any reindex_index() path on the aux (or anything that walks
* the catalog and stumbles on it) bails with "cannot reindex
* temporary tables of other sessions". Clamping to PERMANENT
* avoids that mis-classification; the trade-off is that the aux
* of a TEMP PAX table outlives the session (already a known
* limitation — see the long-standing FIXME further up the file).
*/
relid = heap_create_with_catalog(
aux_relname, aux_namespace_id, InvalidOid, aux_relid, InvalidOid,
InvalidOid, rel->rd_rel->relowner, HEAP_TABLE_AM_OID, tupdesc, NIL,
RELKIND_RELATION,
rel->rd_rel->relpersistence == RELPERSISTENCE_UNLOGGED
? RELPERSISTENCE_UNLOGGED
: RELPERSISTENCE_PERMANENT,
rel->rd_rel->relpersistence == RELPERSISTENCE_TEMP
? RELPERSISTENCE_PERMANENT
: rel->rd_rel->relpersistence,
rel->rd_rel->relisshared, RelationIsMapped(rel), ONCOMMIT_NOOP,
NULL, /* GP Policy */
(Datum)0, false, /* use _user_acl */
Expand Down
9 changes: 7 additions & 2 deletions src/backend/catalog/toasting.c
Original file line number Diff line number Diff line change
Expand Up @@ -167,11 +167,16 @@ create_toast_table(Relation rel, Oid toastOid, Oid toastIndexOid,
/*
* Toast tables for regular relations go in pg_toast; those for temp
* relations go into the per-backend temp-toast-table namespace.
*
* Cloudberry used to have a third branch here that routed TOAST
* for relations whose parent namespace was pg_ext_aux back into
* pg_ext_aux too — this was inconsistent with how every other
* Cloudberry / Postgres relation handles toasting. Treat
* pg_ext_aux parents like any other regular schema; their TOAST
* lands in pg_toast.
*/
if (isTempOrTempToastNamespace(rel->rd_rel->relnamespace))
namespaceid = GetTempToastNamespace();
else if (IsExtAuxNamespace(rel->rd_rel->relnamespace))
namespaceid = PG_EXTAUX_NAMESPACE;
else
namespaceid = PG_TOAST_NAMESPACE;

Expand Down
Loading