Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add namespace pg_ext_aux for extension #333

Merged
merged 1 commit into from
Dec 14, 2023
Merged
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
1 change: 1 addition & 0 deletions src/backend/access/heap/heapam_visibility.c
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ markDirty(Buffer buffer, Relation relation, HeapTupleHeader tuple, bool isXmin)
*/
if (relation == NULL ||
RelationGetRelid(relation) < FirstNormalObjectId ||
RelationGetNamespace(relation) == PG_EXTAUX_NAMESPACE ||
RelationGetNamespace(relation) == PG_AOSEGMENT_NAMESPACE)
{
MarkBufferDirtyHint(buffer, true);
Expand Down
16 changes: 16 additions & 0 deletions src/backend/catalog/catalog.c
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@
#endif

static bool IsAoSegmentClass(Form_pg_class reltuple);
static bool IsExtAuxClass(Form_pg_class reltuple);

/*
* Like relpath(), but gets the directory containing the data file
Expand Down Expand Up @@ -179,6 +180,7 @@ IsSystemClass(Oid relid, Form_pg_class reltuple)
{
/* IsCatalogRelationOid is a bit faster, so test that first */
return (IsCatalogRelationOid(relid) || IsToastClass(reltuple) ||
IsExtAuxClass(reltuple) ||
IsAoSegmentClass(reltuple));
}

Expand Down Expand Up @@ -285,6 +287,14 @@ IsAoSegmentClass(Form_pg_class reltuple)
return IsAoSegmentNamespace(relnamespace);
}

static bool
IsExtAuxClass(Form_pg_class reltuple)
{
Oid relnamespace = reltuple->relnamespace;

return IsExtAuxNamespace(relnamespace);
}

/*
* IsCatalogNamespace
* True iff namespace is pg_catalog.
Expand Down Expand Up @@ -332,6 +342,12 @@ IsAoSegmentNamespace(Oid namespaceId)
return namespaceId == PG_AOSEGMENT_NAMESPACE;
}

bool
IsExtAuxNamespace(Oid namespaceId)
{
return namespaceId == PG_EXTAUX_NAMESPACE;
}

/*
* IsReservedName
* True iff name starts with the pg_ prefix.
Expand Down
6 changes: 4 additions & 2 deletions src/backend/catalog/heap.c
Original file line number Diff line number Diff line change
Expand Up @@ -1663,8 +1663,9 @@ heap_create_with_catalog(const char *relname,
relkind == RELKIND_PARTITIONED_INDEX ||
relkind == RELKIND_AOSEGMENTS ||
relkind == RELKIND_AOBLOCKDIR ||
relkind == RELKIND_AOVISIMAP) &&
relnamespace != PG_BITMAPINDEX_NAMESPACE)
relkind == RELKIND_AOVISIMAP ||
relnamespace == PG_BITMAPINDEX_NAMESPACE ||
relnamespace == PG_EXTAUX_NAMESPACE))
{
/* OK, so pre-assign a type OID for the array type */
Oid new_array_oid;
Expand Down Expand Up @@ -1934,6 +1935,7 @@ heap_create_with_catalog(const char *relname,
case PG_TOAST_NAMESPACE:
case PG_BITMAPINDEX_NAMESPACE:
case PG_AOSEGMENT_NAMESPACE:
case PG_EXTAUX_NAMESPACE:
doIt = false;
break;
default:
Expand Down
2 changes: 2 additions & 0 deletions src/backend/catalog/index.c
Original file line number Diff line number Diff line change
Expand Up @@ -1104,6 +1104,7 @@ index_create_internal(Relation heapRelation,
case PG_TOAST_NAMESPACE:
case PG_BITMAPINDEX_NAMESPACE:
case PG_AOSEGMENT_NAMESPACE:
case PG_EXTAUX_NAMESPACE:
doIt = false;
break;
default:
Expand Down Expand Up @@ -4011,6 +4012,7 @@ reindex_index(Oid indexId, bool skip_constraint_checks, char persistence,
case PG_TOAST_NAMESPACE:
case PG_BITMAPINDEX_NAMESPACE:
case PG_AOSEGMENT_NAMESPACE:
case PG_EXTAUX_NAMESPACE:
doIt = false;
break;
default:
Expand Down
6 changes: 6 additions & 0 deletions src/backend/catalog/namespace.c
Original file line number Diff line number Diff line change
Expand Up @@ -3060,6 +3060,12 @@ CheckSetNamespace(Oid oldNspOid, Oid nspOid)
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("cannot move objects into or out of AO SEGMENT schema")));

/* same for EXT AUX schema */
if (nspOid == PG_EXTAUX_NAMESPACE || oldNspOid == PG_EXTAUX_NAMESPACE)
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("cannot move objects into or out of namespace pg_ext_aux")));
}

/*
Expand Down
2 changes: 2 additions & 0 deletions src/backend/commands/tablecmds.c
Original file line number Diff line number Diff line change
Expand Up @@ -1519,6 +1519,7 @@ DefineRelation(CreateStmt *stmt, char relkind, Oid ownerId,
#define METATRACK_VALIDNAMESPACE(namespaceId) \
(namespaceId != PG_TOAST_NAMESPACE && \
namespaceId != PG_BITMAPINDEX_NAMESPACE && \
namespaceId != PG_EXTAUX_NAMESPACE && \
namespaceId != PG_AOSEGMENT_NAMESPACE )

/* check for valid namespace and valid relkind */
Expand Down Expand Up @@ -15263,6 +15264,7 @@ ATExecChangeOwner(Oid relationOid, Oid newOwnerId, bool recursing, LOCKMODE lock
tuple_class->relkind == RELKIND_PARTITIONED_TABLE ||
tuple_class->relkind == RELKIND_MATVIEW ||
tuple_class->relkind == RELKIND_TOASTVALUE ||
tuple_class->relnamespace == PG_EXTAUX_NAMESPACE ||
IsAppendonlyMetadataRelkind(tuple_class->relkind))
{
List *index_oid_list;
Expand Down
1 change: 1 addition & 0 deletions src/backend/commands/vacuum.c
Original file line number Diff line number Diff line change
Expand Up @@ -3324,6 +3324,7 @@ vacuumStatement_IsTemporary(Relation onerel)
case PG_TOAST_NAMESPACE:
case PG_BITMAPINDEX_NAMESPACE:
case PG_AOSEGMENT_NAMESPACE:
case PG_EXTAUX_NAMESPACE:
bTemp = true;
break;
default:
Expand Down
1 change: 1 addition & 0 deletions src/include/catalog/catalog.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ extern bool IsCatalogRelationOid(Oid relid);
extern bool IsCatalogNamespace(Oid namespaceId);
extern bool IsToastNamespace(Oid namespaceId);
extern bool IsAoSegmentNamespace(Oid namespaceId);
extern bool IsExtAuxNamespace(Oid namespaceId);

extern bool IsReservedName(const char *name);
extern char* GetReservedPrefix(const char *name);
Expand Down
3 changes: 3 additions & 0 deletions src/include/catalog/pg_namespace.dat
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@
{ oid => '7012', oid_symbol => 'PG_BITMAPINDEX_NAMESPACE',
descr => 'Reserved schema for internal relations of bitmap indexes',
nspname => 'pg_bitmapindex', nspacl => '_null_' },
{ oid => '7094', oid_symbol => 'PG_EXTAUX_NAMESPACE',
descr => 'Reserved schema for internal relations for extensions',
nspname => 'pg_ext_aux', nspacl => '_null_' },

# prototypes for functions in pg_namespace.c

Expand Down
3 changes: 2 additions & 1 deletion src/include/catalog/pg_namespace.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,9 @@ typedef FormData_pg_namespace *Form_pg_namespace;
#define IsBuiltInNameSpace(namespaceId) \
(namespaceId == PG_CATALOG_NAMESPACE || \
namespaceId == PG_TOAST_NAMESPACE || \
namespaceId == PG_BITMAPINDEX_NAMESPACE || \
namespaceId == PG_PUBLIC_NAMESPACE || \
namespaceId == PG_EXTAUX_NAMESPACE || \
namespaceId == PG_BITMAPINDEX_NAMESPACE || \
namespaceId == PG_AOSEGMENT_NAMESPACE)

DECLARE_TOAST(pg_namespace, 4163, 4164);
Expand Down