Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitfce742d

Browse files
committed
improved function drop_partitions()
1 parent5567629 commitfce742d

File tree

1 file changed

+14
-11
lines changed

1 file changed

+14
-11
lines changed

‎init.sql‎

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -581,23 +581,22 @@ DECLARE
581581
v_recRECORD;
582582
v_rowsBIGINT;
583583
v_part_countINTEGER :=0;
584-
conf_num_delINTEGER;
584+
conf_numINTEGER;
585585
v_relkindCHAR;
586586

587587
BEGIN
588588
PERFORM @extschema@.validate_relname(parent_relid);
589589

590-
/*Drop trigger first*/
591-
PERFORM @extschema@.drop_triggers(parent_relid);
590+
/*Acquire data modification lock*/
591+
PERFORM @extschema@.prevent_relation_modification(parent_relid);
592592

593-
WITH config_num_deletedAS (DELETEFROM @extschema@.pathman_config
594-
WHERE partrel= parent_relid
595-
RETURNING*)
596-
SELECTcount(*)from config_num_deleted INTO conf_num_del;
593+
/* First, drop all triggers*/
594+
PERFORM @extschema@.drop_triggers(parent_relid);
597595

598-
DELETEFROM @extschema@.pathman_config_paramsWHERE partrel= parent_relid;
596+
SELECTcount(*)FROM @extschema@.pathman_config
597+
WHERE partrel= parent_relid INTO conf_num;
599598

600-
IFconf_num_del=0 THEN
599+
IFconf_num=0 THEN
601600
RAISE EXCEPTION'relation "%" has no partitions', parent_relid::TEXT;
602601
END IF;
603602

@@ -621,8 +620,8 @@ BEGIN
621620
INTO v_relkind;
622621

623622
/*
624-
* Determine the kind of child relation. It can be either regular
625-
* table (r) or foreign table (f). Depending on relkind we use
623+
* Determine the kind of child relation. It can be eitheraregular
624+
* table (r) oraforeign table (f). Depending on relkind we use
626625
* DROP TABLE or DROP FOREIGN TABLE.
627626
*/
628627
IF v_relkind='f' THEN
@@ -634,6 +633,10 @@ BEGIN
634633
v_part_count := v_part_count+1;
635634
END LOOP;
636635

636+
/* Finally delete both config entries*/
637+
DELETEFROM @extschema@.pathman_configWHERE partrel= parent_relid;
638+
DELETEFROM @extschema@.pathman_config_paramsWHERE partrel= parent_relid;
639+
637640
RETURN v_part_count;
638641
END
639642
$$ LANGUAGE plpgsql

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp