Skip to content

Commit 593f47a

Browse files
committed
drop_range_partition(): check that it's indeed a RANGE partition, allow unprivileged user to change GUC variable pg_pathman_enable_partition_filter
1 parent e0cfda6 commit 593f47a

File tree

4 files changed

+15
-4
lines changed

4 files changed

+15
-4
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -533,7 +533,7 @@ SELECT detach_range_partition('journal_archive');
533533
```
534534

535535
Here's an example of the query performing filtering by partitioning key:
536-
```
536+
```plpgsql
537537
SELECT * FROM journal WHERE dt >= '2015-06-01' AND dt < '2015-06-03';
538538
id | dt | level | msg
539539
--------+---------------------+-------+----------------------------------

range.sql

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -582,7 +582,7 @@ BEGIN
582582

583583
/* Check if this is a RANGE partition */
584584
IF v_part_type != 2 THEN
585-
RAISE EXCEPTION 'specified partition isn''t RANGE partition';
585+
RAISE EXCEPTION '"%" is not a RANGE partition', p_partition::TEXT;
586586
END IF;
587587

588588
v_atttype = @extschema@.get_attribute_type(v_parent, v_attname);
@@ -1036,11 +1036,22 @@ DECLARE
10361036
part_name TEXT;
10371037
v_relkind CHAR;
10381038
v_rows BIGINT;
1039+
v_part_type INTEGER;
10391040

10401041
BEGIN
10411042
parent_relid := @extschema@.get_parent_of_partition(p_partition);
10421043
part_name := p_partition::TEXT; /* save the name to be returned */
10431044

1045+
SELECT parttype
1046+
FROM @extschema@.pathman_config
1047+
WHERE partrel = parent_relid
1048+
INTO v_part_type;
1049+
1050+
/* Check if this is a RANGE partition */
1051+
IF v_part_type != 2 THEN
1052+
RAISE EXCEPTION '"%" is not a RANGE partition', p_partition::TEXT;
1053+
END IF;
1054+
10441055
/* Acquire lock on parent */
10451056
PERFORM @extschema@.lock_partitioned_relation(parent_relid);
10461057

src/partition_filter.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ init_partition_filter_static_data(void)
9292
NULL,
9393
&pg_pathman_enable_partition_filter,
9494
true,
95-
PGC_SUSET,
95+
PGC_USERSET,
9696
0,
9797
NULL,
9898
NULL,

src/pl_funcs.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ get_parent_of_partition_pl(PG_FUNCTION_ARGS)
173173
PG_RETURN_OID(parent);
174174
else
175175
{
176-
elog(ERROR, "\%s\" is not pg_pathman's partition",
176+
elog(ERROR, "\"%s\" is not a partition",
177177
get_rel_name_or_relid(partition));
178178

179179
PG_RETURN_NULL();

0 commit comments

Comments
 (0)