@@ -29,7 +29,8 @@ CREATE TABLE IF NOT EXISTS @extschema@.pathman_config (
29
29
30
30
CREATE TABLE IF NOT EXISTS @extschema@.pathman_config_params (
31
31
partrelREGCLASSNOT NULL ,
32
- enable_parentBOOLEAN NOT NULL DEFAULT TRUE
32
+ enable_parentBOOLEAN NOT NULL DEFAULT TRUE,
33
+ autoBOOLEAN NOT NULL DEFAULT TRUE
33
34
);
34
35
CREATE UNIQUE INDEX i_pathman_config_params
35
36
ON @extschema@.pathman_config_params(partrel);
81
82
$$
82
83
LANGUAGE plpgsql;
83
84
84
- /* Include parent relation into query plan's for specified relation*/
85
+ /*
86
+ * Set additional param
87
+ */
88
+ CREATEOR REPLACE FUNCTION @extschema@.pathman_set_param(
89
+ relationREGCLASS,
90
+ paramTEXT ,
91
+ valueBOOLEAN )
92
+ RETURNS VOIDAS
93
+ $$
94
+ BEGIN
95
+ EXECUTE format(
96
+ ' INSERT INTO @extschema@.pathman_config_params (partrel, %1$s)
97
+ VALUES ($1, $2)
98
+ ON CONFLICT (partrel) DO
99
+ UPDATE SET %1$s = $2' ,
100
+ param)
101
+ USING
102
+ relation,
103
+ value;
104
+ END
105
+ $$
106
+ LANGUAGE plpgsql;
107
+
108
+ /*
109
+ * Include parent relation into query plan's for specified relation
110
+ */
85
111
CREATEOR REPLACE FUNCTION @extschema@.enable_parent(relation REGCLASS)
86
112
RETURNS VOIDAS
87
113
$$
88
114
BEGIN
89
- INSERT INTO @extschema@.pathman_config_paramsvalues (relation, True)
90
- ON CONFLICT (partrel) DO
91
- UPDATE SET enable_parent= True;
115
+ PERFORM @extschema@.pathman_set_param(relation,' enable_parent' , True);
116
+ END
117
+ $$
118
+ LANGUAGE plpgsql;
92
119
93
- -- PERFORM @extschema@.invalidate_relcache(relation::oid);
94
- -- PERFORM @extschema@.on_enable_parent(relation::oid);
120
+ /*
121
+ * Do not include parent relation into query plan's for specified relation
122
+ */
123
+ CREATEOR REPLACE FUNCTION @extschema@.disable_parent(relation REGCLASS)
124
+ RETURNS VOIDAS
125
+ $$
126
+ BEGIN
127
+ PERFORM @extschema@.pathman_set_param(relation,' enable_parent' , False);
95
128
END
96
129
$$
97
130
LANGUAGE plpgsql;
98
131
99
- /* Do not include parent relation into query plan's for specified relation*/
100
- CREATEOR REPLACE FUNCTION @extschema@.disable_parent(relation REGCLASS)
132
+ /*
133
+ * Enable auto partition creation
134
+ */
135
+ CREATEOR REPLACE FUNCTION @extschema@.enable_auto(relation REGCLASS)
101
136
RETURNS VOIDAS
102
137
$$
103
138
BEGIN
104
- INSERT INTO @extschema@.pathman_config_paramsvalues (relation, False)
105
- ON CONFLICT (partrel) DO
106
- UPDATE SET enable_parent= False;
139
+ PERFORM @extschema@.pathman_set_param(relation,' auto' , True);
140
+ END
141
+ $$
142
+ LANGUAGE plpgsql;
107
143
108
- -- PERFORM @extschema@.invalidate_relcache(relation::oid);
109
- -- PERFORM @extschema@.on_disable_parent(relation::oid);
144
+ /*
145
+ * Disable auto partition creation
146
+ */
147
+ CREATEOR REPLACE FUNCTION @extschema@.disable_auto(relation REGCLASS)
148
+ RETURNS VOIDAS
149
+ $$
150
+ BEGIN
151
+ PERFORM @extschema@.pathman_set_param(relation,' auto' , False);
110
152
END
111
153
$$
112
154
LANGUAGE plpgsql;