Skip to content

Commit 2775b5a

Browse files
committed
prohibit usage of temporary tables as partitions
1 parent 8b14f73 commit 2775b5a

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

range.sql

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ END
328328
$$ LANGUAGE plpgsql;
329329

330330
/*
331-
*
331+
*
332332
*/
333333
CREATE OR REPLACE FUNCTION @extschema@.check_boundaries(
334334
p_relation REGCLASS
@@ -706,7 +706,7 @@ BEGIN
706706
FROM @extschema@.pathman_config WHERE relname::regclass = p_relation;
707707

708708
v_atttype := @extschema@.get_attribute_type_name(p_relation, v_attname);
709-
709+
710710
EXECUTE format('SELECT @extschema@.append_partition_internal($1, $2, $3, ARRAY[]::%s[])', v_atttype)
711711
INTO v_part_name
712712
USING p_relation, v_atttype, v_interval;
@@ -918,7 +918,15 @@ DECLARE
918918
v_cond TEXT;
919919
v_plain_partname TEXT;
920920
v_plain_schema TEXT;
921+
rel_persistence CHAR;
921922
BEGIN
923+
/* Ignore temporary tables */
924+
SELECT relpersistence FROM pg_catalog.pg_class WHERE oid = p_partition INTO rel_persistence;
925+
IF rel_persistence = 't'::CHAR THEN
926+
RAISE EXCEPTION 'Temporary table % cannot be used as a partition',
927+
quote_ident(p_partition::TEXT);
928+
END IF;
929+
922930
/* Prevent concurrent partition management */
923931
PERFORM @extschema@.acquire_partitions_lock();
924932

@@ -1086,7 +1094,7 @@ DECLARE
10861094
EXECUTE q USING %7$s;
10871095
RETURN NULL;
10881096
END $body$ LANGUAGE plpgsql';
1089-
trigger TEXT := 'CREATE TRIGGER %s_update_trigger ' ||
1097+
trigger TEXT := 'CREATE TRIGGER %s_update_trigger ' ||
10901098
'BEFORE UPDATE ON %s ' ||
10911099
'FOR EACH ROW EXECUTE PROCEDURE %s_update_trigger_func()';
10921100
att_names TEXT;

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy