From 79f4fdbc8992a74e8f207c4d10056830774f9a7b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philip=20Dub=C3=A9?= Date: Fri, 27 Sep 2019 02:52:29 +0000 Subject: [PATCH] Use pg_dist_object, remove pg_dist_enabled_custom_aggregates --- .../planner/multi_logical_optimizer.c | 32 ++++--------------- .../sql/citus--9.0-1--9.0-customagg.sql | 6 ---- .../distributed/utils/metadata_cache.c | 12 ------- .../pg_dist_enabled_custom_aggregates.h | 17 ---------- .../expected/multi_metadata_access.out | 7 ++-- 5 files changed, 9 insertions(+), 65 deletions(-) delete mode 100644 src/include/distributed/pg_dist_enabled_custom_aggregates.h diff --git a/src/backend/distributed/planner/multi_logical_optimizer.c b/src/backend/distributed/planner/multi_logical_optimizer.c index 361080f04..4123d6fa8 100644 --- a/src/backend/distributed/planner/multi_logical_optimizer.c +++ b/src/backend/distributed/planner/multi_logical_optimizer.c @@ -34,7 +34,6 @@ #include "distributed/multi_logical_planner.h" #include "distributed/multi_physical_planner.h" #include "distributed/pg_dist_partition.h" -#include "distributed/pg_dist_enabled_custom_aggregates.h" #include "distributed/worker_protocol.h" #include "distributed/version_compat.h" #include "nodes/makefuncs.h" @@ -253,7 +252,7 @@ static List * WorkerAggregateExpressionList(Aggref *originalAggregate, WorkerAggregateWalkerContext *walkerContextry); static AggregateType GetAggregateType(Oid aggFunctionId); static Oid AggregateArgumentType(Aggref *aggregate); -static bool AggregateEnabledCustom(const char *functionName); +static bool AggregateEnabledCustom(Oid aggregateOid); static Oid AggregateFunctionOidWithoutInput(const char *functionName); static Oid AggregateFunctionOid(const char *functionName, Oid inputType); static Oid TypeOid(Oid schemaId, const char *typeName); @@ -3014,7 +3013,7 @@ GetAggregateType(Oid aggFunctionId) aggFunctionId))); } - if (AggregateEnabledCustom(aggregateProcName)) + if (AggregateEnabledCustom(aggFunctionId)) { return AGGREGATE_CUSTOM; } @@ -3058,31 +3057,12 @@ AggregateArgumentType(Aggref *aggregate) static bool -AggregateEnabledCustom(const char *functionName) +AggregateEnabledCustom(Oid aggregateOid) { - SysScanDesc scanDescriptor = NULL; - ScanKeyData scanKey[1]; - bool enabled = false; - HeapTuple heapTuple = NULL; - Relation pgDistEnabledCustomAggregates = NULL; + DistObjectCacheEntry *cacheEntry = LookupDistObjectCacheEntry(AggregateRelationId, + aggregateOid, 0); - ScanKeyInit(&scanKey[0], Anum_pg_dist_enabled_custom_aggregates_name, - BTEqualStrategyNumber, F_NAMEEQ, CStringGetDatum(functionName)); - - pgDistEnabledCustomAggregates = heap_open(DistEnabledCustomAggregatesId(), - AccessShareLock); - - scanDescriptor = systable_beginscan(pgDistEnabledCustomAggregates, InvalidOid, false, - NULL, 1, scanKey); - - heapTuple = systable_getnext(scanDescriptor); - - enabled = HeapTupleIsValid(heapTuple); - - systable_endscan(scanDescriptor); - heap_close(pgDistEnabledCustomAggregates, AccessShareLock); - - return enabled; + return cacheEntry != NULL; } diff --git a/src/backend/distributed/sql/citus--9.0-1--9.0-customagg.sql b/src/backend/distributed/sql/citus--9.0-1--9.0-customagg.sql index 6cf46cfdf..35f2e8d43 100644 --- a/src/backend/distributed/sql/citus--9.0-1--9.0-customagg.sql +++ b/src/backend/distributed/sql/citus--9.0-1--9.0-customagg.sql @@ -62,10 +62,4 @@ CREATE AGGREGATE coord_combine_agg(oid, bytea, anyelement) ( PARALLEL = SAFE ); -CREATE TABLE citus.pg_dist_enabled_custom_aggregates ( - name text not null primary key -); -ALTER TABLE citus.pg_dist_enabled_custom_aggregates SET SCHEMA pg_catalog; -GRANT SELECT ON pg_catalog.pg_dist_node_metadata TO public; - RESET search_path; diff --git a/src/backend/distributed/utils/metadata_cache.c b/src/backend/distributed/utils/metadata_cache.c index 7e04472ce..3672f7371 100644 --- a/src/backend/distributed/utils/metadata_cache.c +++ b/src/backend/distributed/utils/metadata_cache.c @@ -128,7 +128,6 @@ typedef struct MetadataCacheData Oid distPlacementShardidIndexId; Oid distPlacementPlacementidIndexId; Oid distPlacementGroupidIndexId; - Oid distEnabledCustomAggregatesId; Oid distTransactionRelationId; Oid distTransactionGroupIndexId; Oid distTransactionRecordIndexId; @@ -2114,17 +2113,6 @@ DistPlacementGroupidIndexId(void) } -/* return oid of pg_dist_enabled_custom_aggregates relation */ -Oid -DistEnabledCustomAggregatesId(void) -{ - CachedRelationLookup("pg_dist_enabled_custom_aggregates", - &MetadataCache.distEnabledCustomAggregatesId); - - return MetadataCache.distEnabledCustomAggregatesId; -} - - /* return oid of the read_intermediate_result(text,citus_copy_format) function */ Oid CitusReadIntermediateResultFuncId(void) diff --git a/src/include/distributed/pg_dist_enabled_custom_aggregates.h b/src/include/distributed/pg_dist_enabled_custom_aggregates.h deleted file mode 100644 index 7c4e603ab..000000000 --- a/src/include/distributed/pg_dist_enabled_custom_aggregates.h +++ /dev/null @@ -1,17 +0,0 @@ -/*------------------------------------------------------------------------- - * - * pg_dist_enabled_custom_aggregates.h - * definition of the relation that lists which aggregates to treat as custom aggregates. - * - * Copyright (c) 2012-2019, Citus Data, Inc. - * - *------------------------------------------------------------------------- - */ - -#ifndef PG_DIST_ENABLED_CUSTOM_AGGREGATES_H -#define PG_DIST_ENABLED_CUSTOM_AGGREGATES_H - -#define Natts_pg_dist_node 1 -#define Anum_pg_dist_enabled_custom_aggregates_name 1 - -#endif /* PG_DIST_ENABLED_CUSTOM_AGGREGATES_H */ diff --git a/src/test/regress/expected/multi_metadata_access.out b/src/test/regress/expected/multi_metadata_access.out index 8f880c5c8..fa6e09250 100644 --- a/src/test/regress/expected/multi_metadata_access.out +++ b/src/test/regress/expected/multi_metadata_access.out @@ -18,11 +18,10 @@ WHERE AND ext.extname = 'citus' AND nsp.nspname = 'pg_catalog' AND NOT has_table_privilege(pg_class.oid, 'select'); - oid ------------------------------------ - pg_dist_enabled_custom_aggregates + oid +------------------ pg_dist_authinfo -(2 rows) +(1 row) RESET role; DROP USER no_access;