Removed dependency from EnsureTableOwner (#5676)

Removed dependency for EnsureTableOwner. Also removed pg_fini() and columnar_tableam_finish() Still need to remove CheckCitusVersion dependency to make Columnar_tableam.h dependency free from Citus.
pull/5686/head
Ying Xu 2022-02-04 12:45:07 -08:00 committed by GitHub
parent 79442df1b7
commit b5c116449b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 28 additions and 30 deletions

View File

@ -1913,13 +1913,6 @@ columnar_tableam_init()
}
void
columnar_tableam_finish()
{
object_access_hook = PrevObjectAccessHook;
}
/*
* Get the number of chunks filtered out during the given scan.
*/
@ -2334,7 +2327,11 @@ alter_columnar_table_set(PG_FUNCTION_ARGS)
quote_identifier(RelationGetRelationName(rel)))));
}
EnsureTableOwner(relationId);
if (!pg_class_ownercheck(relationId, GetUserId()))
{
aclcheck_error(ACLCHECK_NOT_OWNER, OBJECT_TABLE,
get_rel_name(relationId));
}
ColumnarOptions options = { 0 };
if (!ReadColumnarOptions(relationId, &options))
@ -2454,7 +2451,11 @@ alter_columnar_table_reset(PG_FUNCTION_ARGS)
quote_identifier(RelationGetRelationName(rel)))));
}
EnsureTableOwner(relationId);
if (!pg_class_ownercheck(relationId, GetUserId()))
{
aclcheck_error(ACLCHECK_NOT_OWNER, OBJECT_TABLE,
get_rel_name(relationId));
}
ColumnarOptions options = { 0 };
if (!ReadColumnarOptions(relationId, &options))

View File

@ -28,10 +28,3 @@ columnar_init(void)
columnar_init_gucs();
columnar_tableam_init();
}
void
columnar_fini(void)
{
columnar_tableam_finish();
}

View File

@ -108,7 +108,6 @@ static GucStringAssignHook OldApplicationNameAssignHook = NULL;
void _PG_init(void);
void _PG_fini(void);
static void DoInitialCleanup(void);
static void ResizeStackToMaximumDepth(void);
@ -358,14 +357,6 @@ _PG_init(void)
}
/* shared library deconstruction function */
void
_PG_fini(void)
{
columnar_fini();
}
/*
* DoInitialCleanup does cleanup at start time.
* Currently it:

View File

@ -7,9 +7,9 @@
#include "access/tableam.h"
#include "access/skey.h"
#include "nodes/bitmapset.h"
#include "distributed/coordinator_protocol.h"
#include "access/heapam.h"
#include "catalog/indexing.h"
#include "utils/acl.h"
/*
* Number of valid ItemPointer Offset's for "row number" <> "ItemPointer"
@ -50,8 +50,7 @@ typedef struct ColumnarScanDescData *ColumnarScanDesc;
const TableAmRoutine * GetColumnarTableAmRoutine(void);
extern void columnar_tableam_init(void);
extern void columnar_tableam_finish(void);
extern bool CheckCitusVersion(int elevel);
extern TableScanDesc columnar_beginscan_extended(Relation relation, Snapshot snapshot,
int nkeys, ScanKey key,
ParallelTableScanDesc parallel_scan,

View File

@ -283,6 +283,14 @@ SELECT * FROM columnar_table;
1
(2 rows)
-- Fail to alter a columnar table that is created by a different user
SET ROLE full_access;
SELECT alter_columnar_table_set('columnar_table', chunk_group_row_limit => 2000);
ERROR: must be owner of table columnar_table
-- Fail to reset a columnar table value created by a different user
SELECT alter_columnar_table_reset('columnar_table', chunk_group_row_limit => true);
ERROR: must be owner of table columnar_table
SET ROLE read_access;
-- and drop it
DROP TABLE columnar_table;
-- cannot modify columnar metadata table as unprivileged user

View File

@ -169,6 +169,12 @@ SELECT alter_columnar_table_set('columnar_table', chunk_group_row_limit => 2000)
-- insert some data and read
INSERT INTO columnar_table VALUES (1), (1);
SELECT * FROM columnar_table;
-- Fail to alter a columnar table that is created by a different user
SET ROLE full_access;
SELECT alter_columnar_table_set('columnar_table', chunk_group_row_limit => 2000);
-- Fail to reset a columnar table value created by a different user
SELECT alter_columnar_table_reset('columnar_table', chunk_group_row_limit => true);
SET ROLE read_access;
-- and drop it
DROP TABLE columnar_table;