citus/src/backend/distributed/operations
Colm d4dd44e715
Propagate SECURITY LABEL on tables and columns. (#7956)
Issue #7709 asks for security labels on columns to be propagated, to
support the `anon` extension. Before, Citus supported security labels
on roles (#7735) and this PR adds support for propagating security
labels on tables and columns.

All scenarios that involve propagating metadata for a Citus table now
include the security labels on the table and on the columns of the
table. These scenarios are:
- When a table becomes distributed using `create_distributed_table()` or
`create_reference_table()`, its security labels (if any) are propageted.
- When a security label is defined on a distributed table, or one of its
columns, the label is propagated.
- When a node is added to a Citus cluster, all distributed tables have
their security labels propagated.
- When a column of a distributed table is dropped, any security labels
on the column are also dropped.
- When a column is added to a distributed table, security labels can be
defined on the column and are propagated.
- Security labels on a distributed table or its columns are not
propagated when `citus.enable_metadata_sync` is enabled.

Regress test `seclabel` is extended with tests to cover these scenarios.
The implementation is somewhat involved because it impacts DDL
propagation of Citus tables, but can be broken down as follows:
- distributed_object_ops has `Role_SecLabel`, `Table_SecLabel` and
`Column_SecLabel` to take care of security labels on roles, tables and
columns. `Any_SecLabel` is used for all other security labels and is
essentially a nop.
- Deparser support - `DeparseRoleSecLabelStmt()`,
`DeparseTableSecLabelStmt()` and `DeparseColumnSecLabelStmt()` take care
of deparsing security label statements on roles, tables and columns
respectively.
- When reconstructing the DDL for a citus table, security labels on the
table or its columns are included by having
`GetPreLoadTableCreationCommands()` call a new function
`CreateSecurityLabelCommands()` to take care of any security labels on
the table or its columns.
- When changing a distributed table name to a shard name before running
a command locally on a worker, function `RelayEventExtendNames()` checks
for security labels on a table or its columns.
2025-04-30 18:03:52 +01:00
..
citus_create_restore_point.c Rename foreach_ macros to foreach_declared_ macros (#7700) 2025-03-12 11:01:49 +03:00
citus_split_shard_by_split_points.c Sort includes (#7326) 2023-11-23 18:19:54 +01:00
citus_tools.c Sort includes (#7326) 2023-11-23 18:19:54 +01:00
create_shards.c Rename foreach_ macros to foreach_declared_ macros (#7700) 2025-03-12 11:01:49 +03:00
delete_protocol.c Rename foreach_ macros to foreach_declared_ macros (#7700) 2025-03-12 11:01:49 +03:00
health_check.c Rename foreach_ macros to foreach_declared_ macros (#7700) 2025-03-12 11:01:49 +03:00
isolate_shards.c Sort includes (#7326) 2023-11-23 18:19:54 +01:00
modify_multiple_shards.c Sort includes (#7326) 2023-11-23 18:19:54 +01:00
node_protocol.c Propagate SECURITY LABEL on tables and columns. (#7956) 2025-04-30 18:03:52 +01:00
partitioning.c Sort includes (#7326) 2023-11-23 18:19:54 +01:00
replicate_none_dist_table_shard.c Rename foreach_ macros to foreach_declared_ macros (#7700) 2025-03-12 11:01:49 +03:00
shard_cleaner.c Rename some more foreach_ptr to foreach_declared_ptr 2025-03-13 15:13:56 +03:00
shard_rebalancer.c Rename foreach_ macros to foreach_declared_ macros (#7700) 2025-03-12 11:01:49 +03:00
shard_split.c Rename foreach_ macros to foreach_declared_ macros (#7700) 2025-03-12 11:01:49 +03:00
shard_transfer.c Rename foreach_ macros to foreach_declared_ macros (#7700) 2025-03-12 11:01:49 +03:00
stage_protocol.c Propagates GRANT/REVOKE rights on table columns (#7918) 2025-04-04 11:54:16 +03:00
worker_copy_table_to_node_udf.c Check for Citus table in worker_copy_table_to_node (#7662) 2025-03-05 14:33:52 +00:00
worker_node_manager.c Rename foreach_ macros to foreach_declared_ macros (#7700) 2025-03-12 11:01:49 +03:00
worker_shard_copy.c Sort includes (#7326) 2023-11-23 18:19:54 +01:00
worker_split_copy_udf.c Rename foreach_ macros to foreach_declared_ macros (#7700) 2025-03-12 11:01:49 +03:00
worker_split_shard_release_dsm_udf.c Sort includes (#7326) 2023-11-23 18:19:54 +01:00
worker_split_shard_replication_setup_udf.c Rename foreach_ macros to foreach_declared_ macros (#7700) 2025-03-12 11:01:49 +03:00