/* * IsToastClass * Like the above, but takes a Form_pg_class as argument. * Used when we do not want to open the relation and have to * search pg_class directly. */ bool IsToastClass(Form_pg_class reltuple) { Oid relnamespace = reltuple->relnamespace; return IsToastNamespace(relnamespace); }
/* * IsSystemRelation * True iff the relation is a system catalog relation. * * NB: TOAST relations are considered system relations by this test * for compatibility with the old IsSystemRelationName function. * This is appropriate in many places but not all. Where it's not, * also check IsToastRelation. * * We now just test if the relation is in the system catalog namespace; * so it's no longer necessary to forbid user relations from having * names starting with pg_. */ bool IsSystemRelation(Relation relation) { return IsSystemNamespace(RelationGetNamespace(relation)) || IsToastNamespace(RelationGetNamespace(relation)) || IsAoSegmentNamespace(RelationGetNamespace(relation)); }
/* * IsCatalogClass * True iff the relation is a system catalog relation. * * Check IsCatalogRelation() for details. */ bool IsCatalogClass(Oid relid, Form_pg_class reltuple) { Oid relnamespace = reltuple->relnamespace; /* * Never consider relations outside pg_catalog/pg_toast to be catalog * relations. */ if (!IsSystemNamespace(relnamespace) && !IsToastNamespace(relnamespace)) return false; /* ---- * Check whether the oid was assigned during initdb, when creating the * initial template database. Minus the relations in information_schema * excluded above, these are integral part of the system. * We could instead check whether the relation is pinned in pg_depend, but * this is noticeably cheaper and doesn't require catalog access. * * This test is safe since even an oid wraparound will preserve this * property (c.f. GetNewObjectId()) and it has the advantage that it works * correctly even if a user decides to create a relation in the pg_catalog * namespace. * ---- */ return relid < FirstNormalObjectId; }
/* * IsSystemClass * Like the above, but takes a Form_pg_class as argument. * Used when we do not want to open the relation and have to * search pg_class directly. */ bool IsSystemClass(Form_pg_class reltuple) { Oid relnamespace = reltuple->relnamespace; return IsSystemNamespace(relnamespace) || IsToastNamespace(relnamespace) || IsAoSegmentNamespace(relnamespace); }
/** * Method determines if a relation is master-only or distributed among segments. * Input: * relationOid * Output: * true if masteronly */ bool isMasterOnly(Oid relationOid) { Assert(relationOid != InvalidOid); Oid schemaOid = get_rel_namespace(relationOid); GpPolicy *distributionPolicy = GpPolicyFetch(CurrentMemoryContext, relationOid); bool masterOnly = (Gp_role == GP_ROLE_UTILITY || IsSystemNamespace(schemaOid) || IsToastNamespace(schemaOid) || IsAoSegmentNamespace(schemaOid) || (distributionPolicy == NULL) || (distributionPolicy->ptype == POLICYTYPE_ENTRY)); return masterOnly; }
/* * IsToastRelation * True iff relation is a TOAST support relation (or index). */ bool IsToastRelation(Relation relation) { return IsToastNamespace(RelationGetNamespace(relation)); }