1
|
|
|
<?php |
2
|
|
|
|
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* PHPPgAdmin v6.0.0-beta.30 |
5
|
|
|
*/ |
6
|
|
|
|
7
|
|
|
namespace PHPPgAdmin\Controller; |
8
|
|
|
|
9
|
|
|
use \PHPPgAdmin\Decorators\Decorator; |
10
|
|
|
|
11
|
|
|
trait AdminTrait |
|
|
|
|
12
|
|
|
{ |
13
|
|
|
/** |
14
|
|
|
* Show confirmation of cluster and perform cluster |
15
|
|
|
* @param mixed $type |
|
|
|
|
16
|
|
|
* @param mixed $confirm |
|
|
|
|
17
|
|
|
*/ |
18
|
|
|
public function doCluster($type, $confirm = false) |
19
|
|
|
{ |
20
|
|
|
$this->script = ('database' == $type) ? 'database.php' : 'tables.php'; |
21
|
|
|
|
22
|
|
|
$script = $this->script; |
23
|
|
|
|
24
|
|
|
$lang = $this->lang; |
|
|
|
|
25
|
|
|
$data = $this->misc->getDatabaseAccessor(); |
26
|
|
|
|
27
|
|
|
if (('table' == $type) && empty($_REQUEST['table']) && empty($_REQUEST['ma'])) { |
28
|
|
|
$this->doDefault($lang['strspecifytabletocluster']); |
29
|
|
|
|
30
|
|
|
return; |
31
|
|
|
} |
32
|
|
|
|
33
|
|
|
if ($confirm) { |
34
|
|
|
if (isset($_REQUEST['ma'])) { |
35
|
|
|
$this->printTrail('schema'); |
36
|
|
|
$this->printTitle($lang['strclusterindex'], 'pg.index.cluster'); |
37
|
|
|
|
38
|
|
|
echo '<form action="' . SUBFOLDER . "/src/views/{$script}\" method=\"post\">\n"; |
39
|
|
|
foreach ($_REQUEST['ma'] as $v) { |
40
|
|
|
$a = unserialize(htmlspecialchars_decode($v, ENT_QUOTES)); |
41
|
|
|
echo '<p>', sprintf($lang['strconfclustertable'], $this->misc->printVal($a['table'])), "</p>\n"; |
42
|
|
|
echo '<input type="hidden" name="table[]" value="', htmlspecialchars($a['table']), "\" />\n"; |
43
|
|
|
} |
44
|
|
|
} // END if multi cluster |
45
|
|
|
else { |
|
|
|
|
46
|
|
|
$this->printTrail($type); |
47
|
|
|
$this->printTitle($lang['strclusterindex'], 'pg.index.cluster'); |
48
|
|
|
|
49
|
|
|
echo '<form action="' . SUBFOLDER . "/src/views/{$script}\" method=\"post\">\n"; |
50
|
|
|
|
51
|
|
|
if ('table' == $type) { |
52
|
|
|
echo '<p>', sprintf($lang['strconfclustertable'], $this->misc->printVal($_REQUEST['object'])), "</p>\n"; |
53
|
|
|
echo '<input type="hidden" name="table" value="', htmlspecialchars($_REQUEST['object']), "\" />\n"; |
54
|
|
|
} else { |
55
|
|
|
echo '<p>', sprintf($lang['strconfclusterdatabase'], $this->misc->printVal($_REQUEST['object'])), "</p>\n"; |
56
|
|
|
echo "<input type=\"hidden\" name=\"table\" value=\"\" />\n"; |
57
|
|
|
} |
58
|
|
|
} |
59
|
|
|
echo "<input type=\"hidden\" name=\"action\" value=\"cluster\" />\n"; |
60
|
|
|
|
61
|
|
|
echo $this->misc->form; |
62
|
|
|
|
63
|
|
|
echo "<input type=\"submit\" name=\"cluster\" value=\"{$lang['strcluster']}\" />\n"; //TODO |
64
|
|
|
echo "<input type=\"submit\" name=\"cancel\" value=\"{$lang['strcancel']}\" />\n"; |
65
|
|
|
echo "</form>\n"; |
66
|
|
|
} // END single cluster |
67
|
|
|
else { |
|
|
|
|
68
|
|
|
//If multi table cluster |
69
|
|
|
if ('table' == $type) { |
70
|
|
|
// cluster one or more table |
71
|
|
|
if (is_array($_REQUEST['table'])) { |
72
|
|
|
$msg = ''; |
73
|
|
|
foreach ($_REQUEST['table'] as $o) { |
74
|
|
|
$status = $data->clusterIndex($o); |
75
|
|
|
if (0 == $status) { |
76
|
|
|
$msg .= sprintf('%s: %s<br />', htmlentities($o, ENT_QUOTES, 'UTF-8'), $lang['strclusteredgood']); |
77
|
|
|
} else { |
78
|
|
|
$this->doDefault($type, sprintf('%s%s: %s<br />', $msg, htmlentities($o, ENT_QUOTES, 'UTF-8'), $lang['strclusteredbad'])); |
|
|
|
|
79
|
|
|
|
80
|
|
|
return; |
81
|
|
|
} |
82
|
|
|
} |
83
|
|
|
// Everything went fine, back to the Default page.... |
84
|
|
|
$this->doDefault($msg); |
85
|
|
|
} else { |
86
|
|
|
$status = $data->clusterIndex($_REQUEST['object']); |
87
|
|
|
if (0 == $status) { |
88
|
|
|
$this->doAdmin($type, $lang['strclusteredgood']); |
89
|
|
|
} else { |
90
|
|
|
$this->doAdmin($type, $lang['strclusteredbad']); |
91
|
|
|
} |
92
|
|
|
} |
93
|
|
|
} else { |
94
|
|
|
// Cluster all tables in database |
95
|
|
|
$status = $data->clusterIndex(); |
96
|
|
|
if (0 == $status) { |
97
|
|
|
$this->doAdmin($type, $lang['strclusteredgood']); |
98
|
|
|
} else { |
99
|
|
|
$this->doAdmin($type, $lang['strclusteredbad']); |
100
|
|
|
} |
101
|
|
|
} |
102
|
|
|
} |
103
|
|
|
} |
104
|
|
|
|
105
|
|
|
/** |
106
|
|
|
* Show confirmation of reindex and perform reindex |
107
|
|
|
* @param mixed $type |
|
|
|
|
108
|
|
|
* @param mixed $confirm |
|
|
|
|
109
|
|
|
*/ |
110
|
|
|
public function doReindex($type, $confirm = false) |
111
|
|
|
{ |
112
|
|
|
$this->script = ('database' == $type) ? 'database.php' : 'tables.php'; |
113
|
|
|
$script = $this->script; |
114
|
|
|
$this->misc = $this->misc; |
115
|
|
|
$lang = $this->lang; |
|
|
|
|
116
|
|
|
$data = $this->misc->getDatabaseAccessor(); |
117
|
|
|
|
118
|
|
|
if (('table' == $type) && empty($_REQUEST['table']) && empty($_REQUEST['ma'])) { |
119
|
|
|
$this->doDefault($lang['strspecifytabletoreindex']); |
120
|
|
|
|
121
|
|
|
return; |
122
|
|
|
} |
123
|
|
|
|
124
|
|
|
if ($confirm) { |
125
|
|
|
if (isset($_REQUEST['ma'])) { |
126
|
|
|
$this->printTrail('schema'); |
127
|
|
|
$this->printTitle($lang['strreindex'], 'pg.reindex'); |
128
|
|
|
|
129
|
|
|
echo '<form action="' . SUBFOLDER . "/src/views/{$script}\" method=\"post\">\n"; |
130
|
|
|
foreach ($_REQUEST['ma'] as $v) { |
131
|
|
|
$a = unserialize(htmlspecialchars_decode($v, ENT_QUOTES)); |
132
|
|
|
echo '<p>', sprintf($lang['strconfreindextable'], $this->misc->printVal($a['table'])), "</p>\n"; |
133
|
|
|
echo '<input type="hidden" name="table[]" value="', htmlspecialchars($a['table']), "\" />\n"; |
134
|
|
|
} |
135
|
|
|
} // END if multi reindex |
136
|
|
|
else { |
|
|
|
|
137
|
|
|
$this->printTrail($type); |
138
|
|
|
$this->printTitle($lang['strreindex'], 'pg.reindex'); |
139
|
|
|
|
140
|
|
|
echo '<form action="' . SUBFOLDER . "/src/views/{$script}\" method=\"post\">\n"; |
141
|
|
|
|
142
|
|
|
if ('table' == $type) { |
143
|
|
|
echo '<p>', sprintf($lang['strconfreindextable'], $this->misc->printVal($_REQUEST['object'])), "</p>\n"; |
144
|
|
|
echo '<input type="hidden" name="table" value="', htmlspecialchars($_REQUEST['object']), "\" />\n"; |
145
|
|
|
} else { |
146
|
|
|
echo '<p>', sprintf($lang['strconfreindexdatabase'], $this->misc->printVal($_REQUEST['object'])), "</p>\n"; |
147
|
|
|
echo "<input type=\"hidden\" name=\"table\" value=\"\" />\n"; |
148
|
|
|
} |
149
|
|
|
} |
150
|
|
|
echo "<input type=\"hidden\" name=\"action\" value=\"reindex\" />\n"; |
151
|
|
|
|
152
|
|
|
if ($data->hasForceReindex()) { |
153
|
|
|
echo "<p><input type=\"checkbox\" id=\"reindex_force\" name=\"reindex_force\" /><label for=\"reindex_force\">{$lang['strforce']}</label></p>\n"; |
154
|
|
|
} |
155
|
|
|
|
156
|
|
|
echo $this->misc->form; |
157
|
|
|
|
158
|
|
|
echo "<input type=\"submit\" name=\"reindex\" value=\"{$lang['strreindex']}\" />\n"; //TODO |
159
|
|
|
echo "<input type=\"submit\" name=\"cancel\" value=\"{$lang['strcancel']}\" />\n"; |
160
|
|
|
echo "</form>\n"; |
161
|
|
|
} // END single reindex |
162
|
|
|
else { |
|
|
|
|
163
|
|
|
//If multi table reindex |
164
|
|
|
if (('table' == $type) && is_array($_REQUEST['table'])) { |
165
|
|
|
$msg = ''; |
166
|
|
|
foreach ($_REQUEST['table'] as $o) { |
167
|
|
|
$status = $data->reindex(strtoupper($type), $o, isset($_REQUEST['reindex_force'])); |
168
|
|
|
if (0 == $status) { |
169
|
|
|
$msg .= sprintf('%s: %s<br />', htmlentities($o, ENT_QUOTES, 'UTF-8'), $lang['strreindexgood']); |
170
|
|
|
} else { |
171
|
|
|
$this->doDefault($type, sprintf('%s%s: %s<br />', $msg, htmlentities($o, ENT_QUOTES, 'UTF-8'), $lang['strreindexbad'])); |
|
|
|
|
172
|
|
|
|
173
|
|
|
return; |
174
|
|
|
} |
175
|
|
|
} |
176
|
|
|
// Everything went fine, back to the Default page.... |
177
|
|
|
$this->misc->setReloadBrowser(true); |
178
|
|
|
$this->doDefault($msg); |
179
|
|
|
} else { |
180
|
|
|
$status = $data->reindex(strtoupper($type), $_REQUEST['object'], isset($_REQUEST['reindex_force'])); |
181
|
|
|
if (0 == $status) { |
182
|
|
|
$this->misc->setReloadBrowser(true); |
183
|
|
|
$this->doAdmin($type, $lang['strreindexgood']); |
184
|
|
|
} else { |
185
|
|
|
$this->doAdmin($type, $lang['strreindexbad']); |
186
|
|
|
} |
187
|
|
|
} |
188
|
|
|
} |
189
|
|
|
} |
190
|
|
|
|
191
|
|
|
/** |
192
|
|
|
* Show confirmation of analyze and perform analyze |
193
|
|
|
* @param mixed $type |
|
|
|
|
194
|
|
|
* @param mixed $confirm |
|
|
|
|
195
|
|
|
*/ |
196
|
|
|
public function doAnalyze($type, $confirm = false) |
197
|
|
|
{ |
198
|
|
|
$this->script = ('database' == $type) ? 'database.php' : 'tables.php'; |
199
|
|
|
|
200
|
|
|
$script = $this->script; |
201
|
|
|
|
202
|
|
|
$lang = $this->lang; |
|
|
|
|
203
|
|
|
$data = $this->misc->getDatabaseAccessor(); |
204
|
|
|
|
205
|
|
|
if (('table' == $type) && empty($_REQUEST['table']) && empty($_REQUEST['ma'])) { |
206
|
|
|
$this->doDefault($lang['strspecifytabletoanalyze']); |
207
|
|
|
|
208
|
|
|
return; |
209
|
|
|
} |
210
|
|
|
|
211
|
|
|
if ($confirm) { |
212
|
|
|
if (isset($_REQUEST['ma'])) { |
213
|
|
|
$this->printTrail('schema'); |
214
|
|
|
$this->printTitle($lang['stranalyze'], 'pg.analyze'); |
215
|
|
|
|
216
|
|
|
echo '<form action="' . SUBFOLDER . "/src/views/{$script}\" method=\"post\">\n"; |
217
|
|
|
foreach ($_REQUEST['ma'] as $v) { |
218
|
|
|
$a = unserialize(htmlspecialchars_decode($v, ENT_QUOTES)); |
219
|
|
|
\Kint::dump($a); |
220
|
|
|
echo '<p>', sprintf($lang['strconfanalyzetable'], $this->misc->printVal($a['table'])), "</p>\n"; |
221
|
|
|
echo '<input type="hidden" name="table[]" value="', htmlspecialchars($a['table']), "\" />\n"; |
222
|
|
|
} |
223
|
|
|
} // END if multi analyze |
224
|
|
|
else { |
|
|
|
|
225
|
|
|
$this->printTrail($type); |
226
|
|
|
$this->printTitle($lang['stranalyze'], 'pg.analyze'); |
227
|
|
|
|
228
|
|
|
echo '<form action="' . SUBFOLDER . "/src/views/{$script}\" method=\"post\">\n"; |
229
|
|
|
|
230
|
|
|
if ('table' == $type) { |
231
|
|
|
echo '<p>', sprintf($lang['strconfanalyzetable'], $this->misc->printVal($_REQUEST['object'])), "</p>\n"; |
232
|
|
|
echo '<input type="hidden" name="table" value="', htmlspecialchars($_REQUEST['object']), "\" />\n"; |
233
|
|
|
} else { |
234
|
|
|
echo '<p>', sprintf($lang['strconfanalyzedatabase'], $this->misc->printVal($_REQUEST['object'])), "</p>\n"; |
235
|
|
|
echo "<input type=\"hidden\" name=\"table\" value=\"\" />\n"; |
236
|
|
|
} |
237
|
|
|
} |
238
|
|
|
echo "<input type=\"hidden\" name=\"action\" value=\"analyze\" />\n"; |
239
|
|
|
echo $this->misc->form; |
240
|
|
|
|
241
|
|
|
echo "<input type=\"submit\" name=\"analyze\" value=\"{$lang['stranalyze']}\" />\n"; //TODO |
242
|
|
|
echo "<input type=\"submit\" name=\"cancel\" value=\"{$lang['strcancel']}\" />\n"; |
243
|
|
|
echo "</form>\n"; |
244
|
|
|
} // END single analyze |
245
|
|
|
else { |
|
|
|
|
246
|
|
|
//If multi table analyze |
247
|
|
|
if (('table' == $type) && is_array($_REQUEST['table'])) { |
248
|
|
|
$msg = ''; |
249
|
|
|
foreach ($_REQUEST['table'] as $o) { |
250
|
|
|
$status = $data->analyzeDB($o); |
251
|
|
|
if (0 == $status) { |
252
|
|
|
$msg .= sprintf('%s: %s<br />', htmlentities($o, ENT_QUOTES, 'UTF-8'), $lang['stranalyzegood']); |
253
|
|
|
} else { |
254
|
|
|
$this->doDefault($type, sprintf('%s%s: %s<br />', $msg, htmlentities($o, ENT_QUOTES, 'UTF-8'), $lang['stranalyzebad'])); |
|
|
|
|
255
|
|
|
|
256
|
|
|
return; |
257
|
|
|
} |
258
|
|
|
} |
259
|
|
|
// Everything went fine, back to the Default page.... |
260
|
|
|
$this->misc->setReloadBrowser(true); |
261
|
|
|
$this->doDefault($msg); |
262
|
|
|
} else { |
263
|
|
|
//we must pass table here. When empty, analyze the whole db |
264
|
|
|
$status = $data->analyzeDB($_REQUEST['table']); |
265
|
|
|
if (0 == $status) { |
266
|
|
|
$this->misc->setReloadBrowser(true); |
267
|
|
|
$this->doAdmin($type, $lang['stranalyzegood']); |
268
|
|
|
} else { |
269
|
|
|
$this->doAdmin($type, $lang['stranalyzebad']); |
270
|
|
|
} |
271
|
|
|
} |
272
|
|
|
} |
273
|
|
|
} |
274
|
|
|
|
275
|
|
|
/** |
276
|
|
|
* Show confirmation of vacuum and perform actual vacuum |
277
|
|
|
* @param mixed $type |
|
|
|
|
278
|
|
|
* @param mixed $confirm |
|
|
|
|
279
|
|
|
*/ |
280
|
|
|
public function doVacuum($type, $confirm = false) |
281
|
|
|
{ |
282
|
|
|
$script = ('database' == $type) ? 'database.php' : 'tables.php'; |
283
|
|
|
|
284
|
|
|
$lang = $this->lang; |
|
|
|
|
285
|
|
|
$data = $this->misc->getDatabaseAccessor(); |
286
|
|
|
|
287
|
|
|
if (('table' == $type) && empty($_REQUEST['table']) && empty($_REQUEST['ma'])) { |
288
|
|
|
$this->doDefault($lang['strspecifytabletovacuum']); |
289
|
|
|
|
290
|
|
|
return; |
291
|
|
|
} |
292
|
|
|
|
293
|
|
|
if ($confirm) { |
294
|
|
|
if (isset($_REQUEST['ma'])) { |
295
|
|
|
$this->printTrail('schema'); |
296
|
|
|
$this->printTitle($lang['strvacuum'], 'pg.vacuum'); |
297
|
|
|
|
298
|
|
|
echo '<form action="' . SUBFOLDER . "/src/views/{$script}\" method=\"post\">\n"; |
299
|
|
|
foreach ($_REQUEST['ma'] as $v) { |
300
|
|
|
$a = unserialize(htmlspecialchars_decode($v, ENT_QUOTES)); |
301
|
|
|
echo '<p>', sprintf($lang['strconfvacuumtable'], $this->misc->printVal($a['table'])), "</p>\n"; |
302
|
|
|
echo '<input type="hidden" name="table[]" value="', htmlspecialchars($a['table']), "\" />\n"; |
303
|
|
|
} |
304
|
|
|
} else { |
305
|
|
|
// END if multi vacuum |
306
|
|
|
$this->printTrail($type); |
307
|
|
|
$this->printTitle($lang['strvacuum'], 'pg.vacuum'); |
308
|
|
|
|
309
|
|
|
echo '<form action="' . SUBFOLDER . "/src/views/{$script}\" method=\"post\">\n"; |
310
|
|
|
|
311
|
|
|
if ('table' == $type) { |
312
|
|
|
echo '<p>', sprintf($lang['strconfvacuumtable'], $this->misc->printVal($_REQUEST['object'])), "</p>\n"; |
313
|
|
|
echo '<input type="hidden" name="table" value="', htmlspecialchars($_REQUEST['object']), "\" />\n"; |
314
|
|
|
} else { |
315
|
|
|
echo '<p>', sprintf($lang['strconfvacuumdatabase'], $this->misc->printVal($_REQUEST['object'])), "</p>\n"; |
316
|
|
|
echo "<input type=\"hidden\" name=\"table\" value=\"\" />\n"; |
317
|
|
|
} |
318
|
|
|
} |
319
|
|
|
echo "<input type=\"hidden\" name=\"action\" value=\"vacuum\" />\n"; |
320
|
|
|
echo $this->misc->form; |
321
|
|
|
echo "<p><input type=\"checkbox\" id=\"vacuum_full\" name=\"vacuum_full\" /> <label for=\"vacuum_full\">{$lang['strfull']}</label></p>\n"; |
322
|
|
|
echo "<p><input type=\"checkbox\" id=\"vacuum_analyze\" name=\"vacuum_analyze\" /> <label for=\"vacuum_analyze\">{$lang['stranalyze']}</label></p>\n"; |
323
|
|
|
echo "<p><input type=\"checkbox\" id=\"vacuum_freeze\" name=\"vacuum_freeze\" /> <label for=\"vacuum_freeze\">{$lang['strfreeze']}</label></p>\n"; |
324
|
|
|
echo "<input type=\"submit\" name=\"vacuum\" value=\"{$lang['strvacuum']}\" />\n"; |
325
|
|
|
echo "<input type=\"submit\" name=\"cancel\" value=\"{$lang['strcancel']}\" />\n"; |
326
|
|
|
echo "</form>\n"; |
327
|
|
|
} // END single vacuum |
328
|
|
|
else { |
|
|
|
|
329
|
|
|
//If multi drop |
330
|
|
|
if (is_array($_REQUEST['table'])) { |
331
|
|
|
$msg = ''; |
332
|
|
|
foreach ($_REQUEST['table'] as $t) { |
333
|
|
|
$status = $data->vacuumDB($t, isset($_REQUEST['vacuum_analyze']), isset($_REQUEST['vacuum_full']), isset($_REQUEST['vacuum_freeze'])); |
334
|
|
|
if (0 == $status) { |
335
|
|
|
$msg .= sprintf('%s: %s<br />', htmlentities($t, ENT_QUOTES, 'UTF-8'), $lang['strvacuumgood']); |
336
|
|
|
} else { |
337
|
|
|
$this->doDefault($type, sprintf('%s%s: %s<br />', $msg, htmlentities($t, ENT_QUOTES, 'UTF-8'), $lang['strvacuumbad'])); |
338
|
|
|
|
339
|
|
|
return; |
340
|
|
|
} |
341
|
|
|
} |
342
|
|
|
// Everything went fine, back to the Default page.... |
343
|
|
|
$this->misc->setReloadBrowser(true); |
344
|
|
|
$this->doDefault($msg); |
345
|
|
|
} else { |
346
|
|
|
//we must pass table here. When empty, vacuum the whole db |
347
|
|
|
$status = $data->vacuumDB($_REQUEST['table'], isset($_REQUEST['vacuum_analyze']), isset($_REQUEST['vacuum_full']), isset($_REQUEST['vacuum_freeze'])); |
348
|
|
|
if (0 == $status) { |
349
|
|
|
$this->misc->setReloadBrowser(true); |
350
|
|
|
$this->doAdmin($type, $lang['strvacuumgood']); |
351
|
|
|
} else { |
352
|
|
|
$this->doAdmin($type, $lang['strvacuumbad']); |
353
|
|
|
} |
354
|
|
|
} |
355
|
|
|
} |
356
|
|
|
} |
357
|
|
|
|
358
|
|
|
/** |
359
|
|
|
* Add or Edit autovacuum params and save them |
360
|
|
|
* @param mixed $type |
|
|
|
|
361
|
|
|
* @param mixed $confirm |
|
|
|
|
362
|
|
|
* @param mixed $msg |
|
|
|
|
363
|
|
|
*/ |
364
|
|
|
public function doEditAutovacuum($type, $confirm, $msg = '') |
365
|
|
|
{ |
366
|
|
|
$this->script = ('database' == $type) ? 'database.php' : 'tables.php'; |
367
|
|
|
$script = $this->script; |
|
|
|
|
368
|
|
|
|
369
|
|
|
$lang = $this->lang; |
|
|
|
|
370
|
|
|
$data = $this->misc->getDatabaseAccessor(); |
371
|
|
|
|
372
|
|
|
if (empty($_REQUEST['table'])) { |
373
|
|
|
$this->doAdmin($type, '', $lang['strspecifyeditvacuumtable']); |
|
|
|
|
374
|
|
|
|
375
|
|
|
return; |
376
|
|
|
} |
377
|
|
|
|
378
|
|
|
$script = ('database' == $type) ? 'database.php' : 'tables.php'; |
379
|
|
|
|
380
|
|
|
if ($confirm) { |
381
|
|
|
$this->printTrail($type); |
382
|
|
|
$this->printTitle(sprintf($lang['streditvacuumtable'], $this->misc->printVal($_REQUEST['table']))); |
383
|
|
|
$this->printMsg(sprintf($msg, $this->misc->printVal($_REQUEST['table']))); |
384
|
|
|
|
385
|
|
|
if (empty($_REQUEST['table'])) { |
386
|
|
|
$this->doAdmin($type, '', $lang['strspecifyeditvacuumtable']); |
387
|
|
|
|
388
|
|
|
return; |
389
|
|
|
} |
390
|
|
|
|
391
|
|
|
$old_val = $data->getTableAutovacuum($_REQUEST['table']); |
392
|
|
|
$defaults = $data->getAutovacuum(); |
393
|
|
|
$old_val = $old_val->fields; |
394
|
|
|
|
395
|
|
|
if (isset($old_val['autovacuum_enabled']) and ('off' == $old_val['autovacuum_enabled'])) { |
396
|
|
|
$enabled = ''; |
397
|
|
|
$disabled = 'checked="checked"'; |
398
|
|
|
} else { |
399
|
|
|
$enabled = 'checked="checked"'; |
400
|
|
|
$disabled = ''; |
401
|
|
|
} |
402
|
|
|
|
403
|
|
|
if (!isset($old_val['autovacuum_vacuum_threshold'])) { |
404
|
|
|
$old_val['autovacuum_vacuum_threshold'] = ''; |
405
|
|
|
} |
406
|
|
|
|
407
|
|
|
if (!isset($old_val['autovacuum_vacuum_scale_factor'])) { |
408
|
|
|
$old_val['autovacuum_vacuum_scale_factor'] = ''; |
409
|
|
|
} |
410
|
|
|
|
411
|
|
|
if (!isset($old_val['autovacuum_analyze_threshold'])) { |
412
|
|
|
$old_val['autovacuum_analyze_threshold'] = ''; |
413
|
|
|
} |
414
|
|
|
|
415
|
|
|
if (!isset($old_val['autovacuum_analyze_scale_factor'])) { |
416
|
|
|
$old_val['autovacuum_analyze_scale_factor'] = ''; |
417
|
|
|
} |
418
|
|
|
|
419
|
|
|
if (!isset($old_val['autovacuum_vacuum_cost_delay'])) { |
420
|
|
|
$old_val['autovacuum_vacuum_cost_delay'] = ''; |
421
|
|
|
} |
422
|
|
|
|
423
|
|
|
if (!isset($old_val['autovacuum_vacuum_cost_limit'])) { |
424
|
|
|
$old_val['autovacuum_vacuum_cost_limit'] = ''; |
425
|
|
|
} |
426
|
|
|
|
427
|
|
|
echo '<form action="' . SUBFOLDER . "/src/views/{$script}\" method=\"post\">\n"; |
428
|
|
|
echo $this->misc->form; |
429
|
|
|
echo "<input type=\"hidden\" name=\"action\" value=\"editautovac\" />\n"; |
430
|
|
|
echo '<input type="hidden" name="table" value="', htmlspecialchars($_REQUEST['table']), "\" />\n"; |
431
|
|
|
|
432
|
|
|
echo "<br />\n<br />\n<table>\n"; |
433
|
|
|
echo "\t<tr><td> </td>\n"; |
434
|
|
|
echo "<th class=\"data\">{$lang['strnewvalues']}</th><th class=\"data\">{$lang['strdefaultvalues']}</th></tr>\n"; |
435
|
|
|
echo "\t<tr><th class=\"data left\">{$lang['strenable']}</th>\n"; |
436
|
|
|
echo "<td class=\"data1\">\n"; |
437
|
|
|
echo "<label for=\"on\">on</label><input type=\"radio\" name=\"autovacuum_enabled\" id=\"on\" value=\"on\" {$enabled} />\n"; |
438
|
|
|
echo "<label for=\"off\">off</label><input type=\"radio\" name=\"autovacuum_enabled\" id=\"off\" value=\"off\" {$disabled} /></td>\n"; |
439
|
|
|
echo "<th class=\"data left\">{$defaults['autovacuum']}</th></tr>\n"; |
440
|
|
|
echo "\t<tr><th class=\"data left\">{$lang['strvacuumbasethreshold']}</th>\n"; |
441
|
|
|
echo "<td class=\"data1\"><input type=\"text\" name=\"autovacuum_vacuum_threshold\" value=\"{$old_val['autovacuum_vacuum_threshold']}\" /></td>\n"; |
442
|
|
|
echo "<th class=\"data left\">{$defaults['autovacuum_vacuum_threshold']}</th></tr>\n"; |
443
|
|
|
echo "\t<tr><th class=\"data left\">{$lang['strvacuumscalefactor']}</th>\n"; |
444
|
|
|
echo "<td class=\"data1\"><input type=\"text\" name=\"autovacuum_vacuum_scale_factor\" value=\"{$old_val['autovacuum_vacuum_scale_factor']}\" /></td>\n"; |
445
|
|
|
echo "<th class=\"data left\">{$defaults['autovacuum_vacuum_scale_factor']}</th></tr>\n"; |
446
|
|
|
echo "\t<tr><th class=\"data left\">{$lang['stranalybasethreshold']}</th>\n"; |
447
|
|
|
echo "<td class=\"data1\"><input type=\"text\" name=\"autovacuum_analyze_threshold\" value=\"{$old_val['autovacuum_analyze_threshold']}\" /></td>\n"; |
448
|
|
|
echo "<th class=\"data left\">{$defaults['autovacuum_analyze_threshold']}</th></tr>\n"; |
449
|
|
|
echo "\t<tr><th class=\"data left\">{$lang['stranalyzescalefactor']}</th>\n"; |
450
|
|
|
echo "<td class=\"data1\"><input type=\"text\" name=\"autovacuum_analyze_scale_factor\" value=\"{$old_val['autovacuum_analyze_scale_factor']}\" /></td>\n"; |
451
|
|
|
echo "<th class=\"data left\">{$defaults['autovacuum_analyze_scale_factor']}</th></tr>\n"; |
452
|
|
|
echo "\t<tr><th class=\"data left\">{$lang['strvacuumcostdelay']}</th>\n"; |
453
|
|
|
echo "<td class=\"data1\"><input type=\"text\" name=\"autovacuum_vacuum_cost_delay\" value=\"{$old_val['autovacuum_vacuum_cost_delay']}\" /></td>\n"; |
454
|
|
|
echo "<th class=\"data left\">{$defaults['autovacuum_vacuum_cost_delay']}</th></tr>\n"; |
455
|
|
|
echo "\t<tr><th class=\"data left\">{$lang['strvacuumcostlimit']}</th>\n"; |
456
|
|
|
echo "<td class=\"datat1\"><input type=\"text\" name=\"autovacuum_vacuum_cost_limit\" value=\"{$old_val['autovacuum_vacuum_cost_limit']}\" /></td>\n"; |
457
|
|
|
echo "<th class=\"data left\">{$defaults['autovacuum_vacuum_cost_limit']}</th></tr>\n"; |
458
|
|
|
echo "</table>\n"; |
459
|
|
|
echo '<br />'; |
460
|
|
|
echo '<br />'; |
461
|
|
|
echo "<input type=\"submit\" name=\"save\" value=\"{$lang['strsave']}\" />\n"; |
462
|
|
|
echo "<input type=\"submit\" name=\"cancel\" value=\"{$lang['strcancel']}\" /></p>\n"; |
463
|
|
|
|
464
|
|
|
echo "</form>\n"; |
465
|
|
|
} else { |
466
|
|
|
$status = $data->saveAutovacuum( |
467
|
|
|
$_REQUEST['table'], |
468
|
|
|
$_POST['autovacuum_enabled'], |
469
|
|
|
$_POST['autovacuum_vacuum_threshold'], |
470
|
|
|
$_POST['autovacuum_vacuum_scale_factor'], |
471
|
|
|
$_POST['autovacuum_analyze_threshold'], |
472
|
|
|
$_POST['autovacuum_analyze_scale_factor'], |
473
|
|
|
$_POST['autovacuum_vacuum_cost_delay'], |
474
|
|
|
$_POST['autovacuum_vacuum_cost_limit'] |
475
|
|
|
); |
476
|
|
|
|
477
|
|
|
if (0 == $status) { |
478
|
|
|
$this->doAdmin($type, '', sprintf($lang['strsetvacuumtablesaved'], $_REQUEST['table'])); |
479
|
|
|
} else { |
480
|
|
|
$this->doEditAutovacuum($type, true, $lang['strsetvacuumtablefail']); |
481
|
|
|
} |
482
|
|
|
} |
483
|
|
|
} |
484
|
|
|
|
485
|
|
|
/** |
486
|
|
|
* confirm drop autovacuum params for a table and drop it |
|
|
|
|
487
|
|
|
* @param mixed $type |
|
|
|
|
488
|
|
|
* @param mixed $confirm |
|
|
|
|
489
|
|
|
*/ |
490
|
|
|
public function doDropAutovacuum($type, $confirm) |
491
|
|
|
{ |
492
|
|
|
$this->script = ('database' == $type) ? 'database.php' : 'tables.php'; |
493
|
|
|
$script = $this->script; |
|
|
|
|
494
|
|
|
|
495
|
|
|
$lang = $this->lang; |
|
|
|
|
496
|
|
|
$data = $this->misc->getDatabaseAccessor(); |
497
|
|
|
|
498
|
|
|
if (empty($_REQUEST['table'])) { |
499
|
|
|
$this->doAdmin($type, '', $lang['strspecifydelvacuumtable']); |
|
|
|
|
500
|
|
|
|
501
|
|
|
return; |
502
|
|
|
} |
503
|
|
|
|
504
|
|
|
if ($confirm) { |
505
|
|
|
$this->printTrail($type); |
506
|
|
|
$this->printTabs($type, 'admin'); |
507
|
|
|
|
508
|
|
|
$script = ('database' == $type) ? 'database.php' : 'tables.php'; |
509
|
|
|
|
510
|
|
|
printf( |
511
|
|
|
"<p>{$lang['strdelvacuumtable']}</p>\n", |
512
|
|
|
$this->misc->printVal("\"{$_GET['schema']}\".\"{$_GET['table']}\"") |
513
|
|
|
); |
514
|
|
|
|
515
|
|
|
echo "<form style=\"float: left\" action=\"{$script}\" method=\"post\">\n"; |
516
|
|
|
echo "<input type=\"hidden\" name=\"action\" value=\"delautovac\" />\n"; |
517
|
|
|
echo $this->misc->form; |
518
|
|
|
echo '<input type="hidden" name="table" value="', htmlspecialchars($_REQUEST['table']), "\" />\n"; |
519
|
|
|
echo '<input type="hidden" name="rel" value="', htmlspecialchars(serialize([$_REQUEST['schema'], $_REQUEST['table']])), "\" />\n"; |
520
|
|
|
echo "<input type=\"submit\" name=\"yes\" value=\"{$lang['stryes']}\" />\n"; |
521
|
|
|
echo "</form>\n"; |
522
|
|
|
|
523
|
|
|
echo '<form action="' . SUBFOLDER . "/src/views/{$script}\" method=\"post\">\n"; |
524
|
|
|
echo "<input type=\"hidden\" name=\"action\" value=\"admin\" />\n"; |
525
|
|
|
echo '<input type="hidden" name="table" value="', htmlspecialchars($_REQUEST['table']), "\" />\n"; |
526
|
|
|
echo $this->misc->form; |
527
|
|
|
echo "<input type=\"submit\" name=\"no\" value=\"{$lang['strno']}\" />\n"; |
528
|
|
|
echo "</form>\n"; |
529
|
|
|
} else { |
530
|
|
|
$status = $data->dropAutovacuum($_POST['table']); |
531
|
|
|
|
532
|
|
|
if (0 == $status) { |
533
|
|
|
$this->doAdmin($type, '', sprintf($lang['strvacuumtablereset'], $this->misc->printVal($_POST['table']))); |
534
|
|
|
} else { |
535
|
|
|
$this->doAdmin($type, '', sprintf($lang['strdelvacuumtablefail'], $this->misc->printVal($_POST['table']))); |
536
|
|
|
} |
537
|
|
|
} |
538
|
|
|
} |
539
|
|
|
|
540
|
|
|
/** |
541
|
|
|
* database/table administration and tuning tasks |
|
|
|
|
542
|
|
|
* |
543
|
|
|
* $Id: admin.php |
544
|
|
|
* @param mixed $type |
|
|
|
|
545
|
|
|
* @param mixed $msg |
|
|
|
|
546
|
|
|
*/ |
|
|
|
|
547
|
|
|
|
548
|
|
|
public function doAdmin($type, $msg = '') |
549
|
|
|
{ |
550
|
|
|
$this->script = ('database' == $type) ? 'database.php' : 'tables.php'; |
551
|
|
|
|
552
|
|
|
$script = $this->script; |
553
|
|
|
|
554
|
|
|
$lang = $this->lang; |
|
|
|
|
555
|
|
|
|
556
|
|
|
$data = $this->misc->getDatabaseAccessor(); |
557
|
|
|
|
558
|
|
|
$this->printTrail($type); |
559
|
|
|
$this->printTabs($type, 'admin'); |
560
|
|
|
$this->printMsg($msg); |
561
|
|
|
|
562
|
|
|
if ('database' == $type) { |
563
|
|
|
printf("<p>{$lang['stradminondatabase']}</p>\n", $this->misc->printVal($_REQUEST['object'])); |
564
|
|
|
} else { |
565
|
|
|
printf("<p>{$lang['stradminontable']}</p>\n", $this->misc->printVal($_REQUEST['object'])); |
566
|
|
|
} |
567
|
|
|
|
568
|
|
|
echo "<table style=\"width: 50%\">\n"; |
569
|
|
|
echo "<tr>\n"; |
570
|
|
|
echo '<th class="data">'; |
571
|
|
|
$this->misc->printHelp($lang['strvacuum'], 'pg.admin.vacuum') . "</th>\n"; |
572
|
|
|
echo '</th>'; |
573
|
|
|
echo '<th class="data">'; |
574
|
|
|
$this->misc->printHelp($lang['stranalyze'], 'pg.admin.analyze'); |
575
|
|
|
echo '</th>'; |
576
|
|
|
if ($data->hasRecluster()) { |
577
|
|
|
echo '<th class="data">'; |
578
|
|
|
$this->misc->printHelp($lang['strclusterindex'], 'pg.index.cluster'); |
579
|
|
|
echo '</th>'; |
580
|
|
|
} |
581
|
|
|
echo '<th class="data">'; |
582
|
|
|
$this->misc->printHelp($lang['strreindex'], 'pg.index.reindex'); |
583
|
|
|
echo '</th>'; |
584
|
|
|
echo '</tr>'; |
585
|
|
|
|
586
|
|
|
// Vacuum |
587
|
|
|
echo "<tr class=\"row1\">\n"; |
588
|
|
|
echo "<td style=\"text-align: center; vertical-align: bottom\">\n"; |
589
|
|
|
echo '<form action="' . SUBFOLDER . "/src/views/{$script}\" method=\"post\">\n"; |
590
|
|
|
|
591
|
|
|
echo "<p><input type=\"hidden\" name=\"action\" value=\"confirm_vacuum\" />\n"; |
592
|
|
|
echo $this->misc->form; |
593
|
|
|
if ('table' == $type) { |
594
|
|
|
echo '<input type="hidden" name="table" value="', htmlspecialchars($_REQUEST['object']), "\" />\n"; |
595
|
|
|
echo "<input type=\"hidden\" name=\"subject\" value=\"table\" />\n"; |
596
|
|
|
} |
597
|
|
|
echo "<input type=\"submit\" value=\"{$lang['strvacuum']}\" /></p>\n"; |
598
|
|
|
echo "</form>\n"; |
599
|
|
|
echo "</td>\n"; |
600
|
|
|
|
601
|
|
|
// Analyze |
602
|
|
|
echo "<td style=\"text-align: center; vertical-align: bottom\">\n"; |
603
|
|
|
echo '<form action="' . SUBFOLDER . "/src/views/{$script}\" method=\"post\">\n"; |
604
|
|
|
echo "<p><input type=\"hidden\" name=\"action\" value=\"confirm_analyze\" />\n"; |
605
|
|
|
echo $this->misc->form; |
606
|
|
|
if ('table' == $type) { |
607
|
|
|
echo '<input type="hidden" name="table" value="', htmlspecialchars($_REQUEST['object']), "\" />\n"; |
608
|
|
|
echo "<input type=\"hidden\" name=\"subject\" value=\"table\" />\n"; |
609
|
|
|
} |
610
|
|
|
echo "<input type=\"submit\" value=\"{$lang['stranalyze']}\" /></p>\n"; |
611
|
|
|
echo "</form>\n"; |
612
|
|
|
echo "</td>\n"; |
613
|
|
|
|
614
|
|
|
// Cluster |
615
|
|
|
if ($data->hasRecluster()) { |
616
|
|
|
$disabled = ''; |
617
|
|
|
echo "<td style=\"text-align: center; vertical-align: bottom\">\n"; |
618
|
|
|
echo '<form action="' . SUBFOLDER . "/src/views/{$script}\" method=\"post\">\n"; |
619
|
|
|
echo $this->misc->form; |
620
|
|
|
if ('table' == $type) { |
621
|
|
|
echo '<input type="hidden" name="table" value="', htmlspecialchars($_REQUEST['object']), "\" />\n"; |
622
|
|
|
echo "<input type=\"hidden\" name=\"subject\" value=\"table\" />\n"; |
623
|
|
|
if (!$data->alreadyClustered($_REQUEST['object'])) { |
624
|
|
|
$disabled = 'disabled="disabled" '; |
625
|
|
|
echo "{$lang['strnoclusteravailable']}<br />"; |
626
|
|
|
} |
627
|
|
|
} |
628
|
|
|
echo "<p><input type=\"hidden\" name=\"action\" value=\"confirm_cluster\" />\n"; |
629
|
|
|
echo "<input type=\"submit\" value=\"{$lang['strclusterindex']}\" ${disabled}/></p>\n"; |
630
|
|
|
echo "</form>\n"; |
631
|
|
|
echo "</td>\n"; |
632
|
|
|
} |
633
|
|
|
|
634
|
|
|
// Reindex |
635
|
|
|
echo "<td style=\"text-align: center; vertical-align: bottom\">\n"; |
636
|
|
|
echo '<form action="' . SUBFOLDER . "/src/views/{$script}\" method=\"post\">\n"; |
637
|
|
|
echo "<p><input type=\"hidden\" name=\"action\" value=\"confirm_reindex\" />\n"; |
638
|
|
|
echo $this->misc->form; |
639
|
|
|
if ('table' == $type) { |
640
|
|
|
echo '<input type="hidden" name="table" value="', htmlspecialchars($_REQUEST['object']), "\" />\n"; |
641
|
|
|
echo "<input type=\"hidden\" name=\"subject\" value=\"table\" />\n"; |
642
|
|
|
} |
643
|
|
|
echo "<input type=\"submit\" value=\"{$lang['strreindex']}\" /></p>\n"; |
644
|
|
|
echo "</form>\n"; |
645
|
|
|
echo "</td>\n"; |
646
|
|
|
echo "</tr>\n"; |
647
|
|
|
echo "</table>\n"; |
648
|
|
|
|
649
|
|
|
// Autovacuum |
650
|
|
|
if ($data->hasAutovacuum()) { |
651
|
|
|
// get defaults values for autovacuum |
652
|
|
|
$defaults = $data->getAutovacuum(); |
653
|
|
|
// Fetch the autovacuum properties from the database or table if != '' |
654
|
|
|
if ('table' == $type) { |
655
|
|
|
$autovac = $data->getTableAutovacuum($_REQUEST['table']); |
656
|
|
|
} else { |
657
|
|
|
$autovac = $data->getTableAutovacuum(); |
658
|
|
|
} |
659
|
|
|
|
660
|
|
|
echo "<br /><br /><h2>{$lang['strvacuumpertable']}</h2>"; |
661
|
|
|
echo '<p>' . (('on' == $defaults['autovacuum']) ? $lang['strturnedon'] : $lang['strturnedoff']) . '</p>'; |
662
|
|
|
echo "<p class=\"message\">{$lang['strnotdefaultinred']}</p>"; |
663
|
|
|
|
664
|
|
|
$enlight = function ($f, $p) { |
665
|
|
|
if (isset($f[$p[0]]) and ($f[$p[0]] != $p[1])) { |
666
|
|
|
return '<span style="color:#F33;font-weight:bold">' . htmlspecialchars($f[$p[0]]) . '</span>'; |
667
|
|
|
} |
668
|
|
|
|
669
|
|
|
return htmlspecialchars($p[1]); |
670
|
|
|
}; |
671
|
|
|
|
672
|
|
|
$columns = [ |
673
|
|
|
'namespace' => [ |
674
|
|
|
'title' => $lang['strschema'], |
675
|
|
|
'field' => Decorator::field('nspname'), |
676
|
|
|
'url' => SUBFOLDER . "/redirect/schema?{$this->misc->href}&", |
677
|
|
|
'vars' => ['schema' => 'nspname'], |
678
|
|
|
], |
679
|
|
|
'relname' => [ |
680
|
|
|
'title' => $lang['strtable'], |
681
|
|
|
'field' => Decorator::field('relname'), |
682
|
|
|
'url' => SUBFOLDER . "/redirect/table?{$this->misc->href}&", |
683
|
|
|
'vars' => ['table' => 'relname', 'schema' => 'nspname'], |
684
|
|
|
], |
685
|
|
|
'autovacuum_enabled' => [ |
686
|
|
|
'title' => $lang['strenabled'], |
687
|
|
|
'field' => Decorator::callback($enlight, ['autovacuum_enabled', $defaults['autovacuum']]), |
688
|
|
|
'type' => 'verbatim', |
689
|
|
|
], |
690
|
|
|
'autovacuum_vacuum_threshold' => [ |
691
|
|
|
'title' => $lang['strvacuumbasethreshold'], |
692
|
|
|
'field' => Decorator::callback($enlight, ['autovacuum_vacuum_threshold', $defaults['autovacuum_vacuum_threshold']]), |
693
|
|
|
'type' => 'verbatim', |
694
|
|
|
], |
695
|
|
|
'autovacuum_vacuum_scale_factor' => [ |
696
|
|
|
'title' => $lang['strvacuumscalefactor'], |
697
|
|
|
'field' => Decorator::callback($enlight, ['autovacuum_vacuum_scale_factor', $defaults['autovacuum_vacuum_scale_factor']]), |
698
|
|
|
'type' => 'verbatim', |
699
|
|
|
], |
700
|
|
|
'autovacuum_analyze_threshold' => [ |
701
|
|
|
'title' => $lang['stranalybasethreshold'], |
702
|
|
|
'field' => Decorator::callback($enlight, ['autovacuum_analyze_threshold', $defaults['autovacuum_analyze_threshold']]), |
703
|
|
|
'type' => 'verbatim', |
704
|
|
|
], |
705
|
|
|
'autovacuum_analyze_scale_factor' => [ |
706
|
|
|
'title' => $lang['stranalyzescalefactor'], |
707
|
|
|
'field' => Decorator::callback($enlight, ['autovacuum_analyze_scale_factor', $defaults['autovacuum_analyze_scale_factor']]), |
708
|
|
|
'type' => 'verbatim', |
709
|
|
|
], |
710
|
|
|
'autovacuum_vacuum_cost_delay' => [ |
711
|
|
|
'title' => $lang['strvacuumcostdelay'], |
712
|
|
|
'field' => Decorator::concat(Decorator::callback($enlight, ['autovacuum_vacuum_cost_delay', $defaults['autovacuum_vacuum_cost_delay']]), 'ms'), |
713
|
|
|
'type' => 'verbatim', |
714
|
|
|
], |
715
|
|
|
'autovacuum_vacuum_cost_limit' => [ |
716
|
|
|
'title' => $lang['strvacuumcostlimit'], |
717
|
|
|
'field' => Decorator::callback($enlight, ['autovacuum_vacuum_cost_limit', $defaults['autovacuum_vacuum_cost_limit']]), |
718
|
|
|
'type' => 'verbatim', |
719
|
|
|
], |
720
|
|
|
]; |
721
|
|
|
|
722
|
|
|
// Maybe we need to check permissions here? |
723
|
|
|
$columns['actions'] = ['title' => $lang['stractions']]; |
724
|
|
|
|
725
|
|
|
$actions = [ |
726
|
|
|
'edit' => [ |
727
|
|
|
'content' => $lang['stredit'], |
728
|
|
|
'attr' => [ |
729
|
|
|
'href' => [ |
730
|
|
|
'url' => $script, |
731
|
|
|
'urlvars' => [ |
732
|
|
|
'subject' => $type, |
733
|
|
|
'action' => 'confeditautovac', |
734
|
|
|
'schema' => Decorator::field('nspname'), |
735
|
|
|
'table' => Decorator::field('relname'), |
736
|
|
|
], |
737
|
|
|
], |
738
|
|
|
], |
739
|
|
|
], |
740
|
|
|
'delete' => [ |
741
|
|
|
'content' => $lang['strdelete'], |
742
|
|
|
'attr' => [ |
743
|
|
|
'href' => [ |
744
|
|
|
'url' => $script, |
745
|
|
|
'urlvars' => [ |
746
|
|
|
'subject' => $type, |
747
|
|
|
'action' => 'confdelautovac', |
748
|
|
|
'schema' => Decorator::field('nspname'), |
749
|
|
|
'table' => Decorator::field('relname'), |
750
|
|
|
], |
751
|
|
|
], |
752
|
|
|
], |
753
|
|
|
], |
754
|
|
|
]; |
755
|
|
|
|
756
|
|
|
if ('table' == $type) { |
757
|
|
|
unset($actions['edit']['vars']['schema'], |
|
|
|
|
758
|
|
|
$actions['delete']['vars']['schema'], |
759
|
|
|
$columns['namespace'], |
760
|
|
|
$columns['relname'] |
761
|
|
|
); |
762
|
|
|
} |
763
|
|
|
|
764
|
|
|
echo $this->printTable($autovac, $columns, $actions, 'admin-admin', $lang['strnovacuumconf']); |
765
|
|
|
|
766
|
|
|
if (('table' == $type) and (0 == $autovac->recordCount())) { |
767
|
|
|
echo '<br />'; |
768
|
|
|
echo "<a href=\"tables.php?action=confeditautovac&{$this->misc->href}&table=", htmlspecialchars($_REQUEST['table']) |
769
|
|
|
, "\">{$lang['straddvacuumtable']}</a>"; |
770
|
|
|
} |
771
|
|
|
} |
772
|
|
|
} |
773
|
|
|
|
774
|
|
|
public function adminActions($action, $type) |
|
|
|
|
775
|
|
|
{ |
776
|
|
|
if ('database' == $type) { |
777
|
|
|
$_REQUEST['object'] = $_REQUEST['database']; |
778
|
|
|
$this->script = 'database.php'; |
779
|
|
|
} else { |
780
|
|
|
// $_REQUEST['table'] is no set if we are in the schema page |
781
|
|
|
$_REQUEST['object'] = (isset($_REQUEST['table']) ? $_REQUEST['table'] : ''); |
782
|
|
|
$this->script = 'tables.php'; |
783
|
|
|
} |
784
|
|
|
|
785
|
|
|
$script = $this->script; |
|
|
|
|
786
|
|
|
|
787
|
|
|
switch ($action) { |
788
|
|
|
case 'confirm_cluster': |
789
|
|
|
$this->doCluster($type, true); |
790
|
|
|
|
791
|
|
|
break; |
792
|
|
|
case 'confirm_reindex': |
793
|
|
|
$this->doReindex($type, true); |
794
|
|
|
|
795
|
|
|
break; |
796
|
|
|
case 'confirm_analyze': |
797
|
|
|
$this->doAnalyze($type, true); |
798
|
|
|
|
799
|
|
|
break; |
800
|
|
|
case 'confirm_vacuum': |
801
|
|
|
$this->doVacuum($type, true); |
802
|
|
|
|
803
|
|
|
break; |
804
|
|
|
case 'cluster': |
805
|
|
|
if (isset($_POST['cluster'])) { |
806
|
|
|
$this->doCluster($type); |
807
|
|
|
} |
808
|
|
|
|
809
|
|
|
// if multi-action from table canceled: back to the schema default page |
810
|
|
|
elseif (('table' == $type) && is_array($_REQUEST['object'])) { |
|
|
|
|
811
|
|
|
$this->doDefault(); |
812
|
|
|
} else { |
813
|
|
|
$this->doAdmin($type); |
814
|
|
|
} |
815
|
|
|
|
816
|
|
|
break; |
817
|
|
|
case 'reindex': |
818
|
|
|
if (isset($_POST['reindex'])) { |
819
|
|
|
$this->doReindex($type); |
820
|
|
|
} |
821
|
|
|
|
822
|
|
|
// if multi-action from table canceled: back to the schema default page |
823
|
|
|
elseif (('table' == $type) && is_array($_REQUEST['object'])) { |
|
|
|
|
824
|
|
|
$this->doDefault(); |
825
|
|
|
} else { |
826
|
|
|
$this->doAdmin($type); |
827
|
|
|
} |
828
|
|
|
|
829
|
|
|
break; |
830
|
|
|
case 'analyze': |
831
|
|
|
if (isset($_POST['analyze'])) { |
832
|
|
|
$this->doAnalyze($type); |
833
|
|
|
} |
834
|
|
|
|
835
|
|
|
// if multi-action from table canceled: back to the schema default page |
836
|
|
|
elseif (('table' == $type) && is_array($_REQUEST['object'])) { |
|
|
|
|
837
|
|
|
$this->doDefault(); |
838
|
|
|
} else { |
839
|
|
|
$this->doAdmin($type); |
840
|
|
|
} |
841
|
|
|
|
842
|
|
|
break; |
843
|
|
|
case 'vacuum': |
844
|
|
|
if (isset($_POST['vacuum'])) { |
845
|
|
|
$this->doVacuum($type); |
846
|
|
|
} |
847
|
|
|
|
848
|
|
|
// if multi-action from table canceled: back to the schema default page |
849
|
|
|
elseif (('table' == $type) && is_array($_REQUEST['object'])) { |
|
|
|
|
850
|
|
|
$this->doDefault(); |
851
|
|
|
} else { |
852
|
|
|
$this->doAdmin($type); |
853
|
|
|
} |
854
|
|
|
|
855
|
|
|
break; |
856
|
|
|
case 'admin': |
857
|
|
|
$this->doAdmin($type); |
858
|
|
|
|
859
|
|
|
break; |
860
|
|
|
case 'confeditautovac': |
861
|
|
|
$this->doEditAutovacuum($type, true); |
862
|
|
|
|
863
|
|
|
break; |
864
|
|
|
case 'confdelautovac': |
865
|
|
|
$this->doDropAutovacuum($type, true); |
866
|
|
|
|
867
|
|
|
break; |
868
|
|
|
case 'confaddautovac': |
869
|
|
|
$this->/** @scrutinizer ignore-call */ |
|
|
|
|
870
|
|
|
doAddAutovacuum(true); |
871
|
|
|
|
872
|
|
|
break; |
873
|
|
|
case 'editautovac': |
874
|
|
|
if (isset($_POST['save'])) { |
875
|
|
|
$this->doEditAutovacuum($type, false); |
876
|
|
|
} else { |
877
|
|
|
$this->doAdmin($type); |
878
|
|
|
} |
879
|
|
|
|
880
|
|
|
break; |
881
|
|
|
case 'delautovac': |
882
|
|
|
$this->doDropAutovacuum($type, false); |
883
|
|
|
|
884
|
|
|
break; |
885
|
|
|
default: |
886
|
|
|
return false; |
887
|
|
|
} |
888
|
|
|
|
889
|
|
|
return true; |
890
|
|
|
} |
891
|
|
|
|
892
|
|
|
abstract public function doDefault($msg = ''); |
|
|
|
|
893
|
|
|
|
894
|
|
|
abstract public function printTrail($trail = [], $do_print = true); |
|
|
|
|
895
|
|
|
|
896
|
|
|
abstract public function printTitle($title, $help = null, $do_print = true); |
|
|
|
|
897
|
|
|
|
898
|
|
|
abstract public function printMsg($msg, $do_print = true); |
|
|
|
|
899
|
|
|
|
900
|
|
|
abstract public function printTabs($tabs, $activetab, $do_print = true); |
|
|
|
|
901
|
|
|
|
902
|
|
|
abstract public function printTable(&$tabledata, &$columns, &$actions, $place, $nodata = null, $pre_fn = null); |
|
|
|
|
903
|
|
|
} |
904
|
|
|
|