|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* PHPPgAdmin v6.0.0-beta.33 |
|
5
|
|
|
*/ |
|
6
|
|
|
|
|
7
|
|
|
namespace PHPPgAdmin\Database; |
|
8
|
|
|
|
|
9
|
|
|
/** |
|
10
|
|
|
* @file |
|
11
|
|
|
* Parent class of all ADODB objects. |
|
12
|
|
|
* |
|
13
|
|
|
* Id: ADOdbBase.php,v 1.24 2008/02/20 20:43:10 ioguix Exp $ |
|
14
|
|
|
* @package PHPPgAdmin |
|
15
|
|
|
*/ |
|
16
|
|
|
class ADOdbBase |
|
17
|
|
|
{ |
|
18
|
|
|
use \PHPPgAdmin\HelperTrait; |
|
|
|
|
|
|
19
|
|
|
|
|
20
|
|
|
public $conn; |
|
21
|
|
|
|
|
22
|
|
|
// The backend platform. Set to UNKNOWN by default. |
|
23
|
|
|
public $platform = 'UNKNOWN'; |
|
24
|
|
|
|
|
25
|
|
|
public $major_version = 9.6; |
|
26
|
|
|
// Max object name length |
|
27
|
|
|
public $_maxNameLen = 63; |
|
|
|
|
|
|
28
|
|
|
// Store the current schema |
|
29
|
|
|
public $_schema; |
|
|
|
|
|
|
30
|
|
|
// Map of database encoding names to HTTP encoding names. If a |
|
31
|
|
|
// database encoding does not appear in this list, then its HTTP |
|
32
|
|
|
// encoding name is the same as its database encoding name. |
|
33
|
|
|
public $codemap = [ |
|
34
|
|
|
'BIG5' => 'BIG5', |
|
35
|
|
|
'EUC_CN' => 'GB2312', |
|
36
|
|
|
'EUC_JP' => 'EUC-JP', |
|
37
|
|
|
'EUC_KR' => 'EUC-KR', |
|
38
|
|
|
'EUC_TW' => 'EUC-TW', |
|
39
|
|
|
'GB18030' => 'GB18030', |
|
40
|
|
|
'GBK' => 'GB2312', |
|
41
|
|
|
'ISO_8859_5' => 'ISO-8859-5', |
|
42
|
|
|
'ISO_8859_6' => 'ISO-8859-6', |
|
43
|
|
|
'ISO_8859_7' => 'ISO-8859-7', |
|
44
|
|
|
'ISO_8859_8' => 'ISO-8859-8', |
|
45
|
|
|
'JOHAB' => 'CP1361', |
|
46
|
|
|
'KOI8' => 'KOI8-R', |
|
47
|
|
|
'LATIN1' => 'ISO-8859-1', |
|
48
|
|
|
'LATIN2' => 'ISO-8859-2', |
|
49
|
|
|
'LATIN3' => 'ISO-8859-3', |
|
50
|
|
|
'LATIN4' => 'ISO-8859-4', |
|
51
|
|
|
'LATIN5' => 'ISO-8859-9', |
|
52
|
|
|
'LATIN6' => 'ISO-8859-10', |
|
53
|
|
|
'LATIN7' => 'ISO-8859-13', |
|
54
|
|
|
'LATIN8' => 'ISO-8859-14', |
|
55
|
|
|
'LATIN9' => 'ISO-8859-15', |
|
56
|
|
|
'LATIN10' => 'ISO-8859-16', |
|
57
|
|
|
'SJIS' => 'SHIFT_JIS', |
|
58
|
|
|
'SQL_ASCII' => 'US-ASCII', |
|
59
|
|
|
'UHC' => 'WIN949', |
|
60
|
|
|
'UTF8' => 'UTF-8', |
|
61
|
|
|
'WIN866' => 'CP866', |
|
62
|
|
|
'WIN874' => 'CP874', |
|
63
|
|
|
'WIN1250' => 'CP1250', |
|
64
|
|
|
'WIN1251' => 'CP1251', |
|
65
|
|
|
'WIN1252' => 'CP1252', |
|
66
|
|
|
'WIN1256' => 'CP1256', |
|
67
|
|
|
'WIN1258' => 'CP1258', |
|
68
|
|
|
]; |
|
69
|
|
|
public $defaultprops = ['', '', '']; |
|
70
|
|
|
// Extra "magic" types. BIGSERIAL was added in PostgreSQL 7.2. |
|
71
|
|
|
public $extraTypes = ['SERIAL', 'BIGSERIAL']; |
|
72
|
|
|
// Foreign key stuff. First element MUST be the default. |
|
73
|
|
|
public $fkactions = ['NO ACTION', 'RESTRICT', 'CASCADE', 'SET NULL', 'SET DEFAULT']; |
|
74
|
|
|
public $fkdeferrable = ['NOT DEFERRABLE', 'DEFERRABLE']; |
|
75
|
|
|
public $fkinitial = ['INITIALLY IMMEDIATE', 'INITIALLY DEFERRED']; |
|
76
|
|
|
public $fkmatches = ['MATCH SIMPLE', 'MATCH FULL']; |
|
77
|
|
|
// Function properties |
|
78
|
|
|
public $funcprops = [ |
|
79
|
|
|
['', 'VOLATILE', 'IMMUTABLE', 'STABLE'], |
|
80
|
|
|
['', 'CALLED ON NULL INPUT', 'RETURNS NULL ON NULL INPUT'], |
|
81
|
|
|
['', 'SECURITY INVOKER', 'SECURITY DEFINER'], |
|
82
|
|
|
]; |
|
83
|
|
|
|
|
84
|
|
|
// Default help URL |
|
85
|
|
|
public $help_base; |
|
86
|
|
|
// Help sub pages |
|
87
|
|
|
public $help_page; |
|
88
|
|
|
// Name of id column |
|
89
|
|
|
public $id = 'oid'; |
|
90
|
|
|
|
|
91
|
|
|
// Supported join operations for use with view wizard |
|
92
|
|
|
public $joinOps = ['INNER JOIN' => 'INNER JOIN', 'LEFT JOIN' => 'LEFT JOIN', 'RIGHT JOIN' => 'RIGHT JOIN', 'FULL JOIN' => 'FULL JOIN']; |
|
93
|
|
|
// Map of internal language name to syntax highlighting name |
|
94
|
|
|
public $langmap = [ |
|
95
|
|
|
'sql' => 'SQL', |
|
96
|
|
|
'plpgsql' => 'SQL', |
|
97
|
|
|
'php' => 'PHP', |
|
98
|
|
|
'phpu' => 'PHP', |
|
99
|
|
|
'plphp' => 'PHP', |
|
100
|
|
|
'plphpu' => 'PHP', |
|
101
|
|
|
'perl' => 'Perl', |
|
102
|
|
|
'perlu' => 'Perl', |
|
103
|
|
|
'plperl' => 'Perl', |
|
104
|
|
|
'plperlu' => 'Perl', |
|
105
|
|
|
'java' => 'Java', |
|
106
|
|
|
'javau' => 'Java', |
|
107
|
|
|
'pljava' => 'Java', |
|
108
|
|
|
'pljavau' => 'Java', |
|
109
|
|
|
'plj' => 'Java', |
|
110
|
|
|
'plju' => 'Java', |
|
111
|
|
|
'python' => 'Python', |
|
112
|
|
|
'pythonu' => 'Python', |
|
113
|
|
|
'plpython' => 'Python', |
|
114
|
|
|
'plpythonu' => 'Python', |
|
115
|
|
|
'ruby' => 'Ruby', |
|
116
|
|
|
'rubyu' => 'Ruby', |
|
117
|
|
|
'plruby' => 'Ruby', |
|
118
|
|
|
'plrubyu' => 'Ruby', |
|
119
|
|
|
]; |
|
120
|
|
|
// Predefined size types |
|
121
|
|
|
public $predefined_size_types = [ |
|
122
|
|
|
'abstime', |
|
123
|
|
|
'aclitem', |
|
124
|
|
|
'bigserial', |
|
125
|
|
|
'boolean', |
|
126
|
|
|
'bytea', |
|
127
|
|
|
'cid', |
|
128
|
|
|
'cidr', |
|
129
|
|
|
'circle', |
|
130
|
|
|
'date', |
|
131
|
|
|
'float4', |
|
132
|
|
|
'float8', |
|
133
|
|
|
'gtsvector', |
|
134
|
|
|
'inet', |
|
135
|
|
|
'int2', |
|
136
|
|
|
'int4', |
|
137
|
|
|
'int8', |
|
138
|
|
|
'macaddr', |
|
139
|
|
|
'money', |
|
140
|
|
|
'oid', |
|
141
|
|
|
'path', |
|
142
|
|
|
'polygon', |
|
143
|
|
|
'refcursor', |
|
144
|
|
|
'regclass', |
|
145
|
|
|
'regoper', |
|
146
|
|
|
'regoperator', |
|
147
|
|
|
'regproc', |
|
148
|
|
|
'regprocedure', |
|
149
|
|
|
'regtype', |
|
150
|
|
|
'reltime', |
|
151
|
|
|
'serial', |
|
152
|
|
|
'smgr', |
|
153
|
|
|
'text', |
|
154
|
|
|
'tid', |
|
155
|
|
|
'tinterval', |
|
156
|
|
|
'tsquery', |
|
157
|
|
|
'tsvector', |
|
158
|
|
|
'varbit', |
|
159
|
|
|
'void', |
|
160
|
|
|
'xid', |
|
161
|
|
|
]; |
|
162
|
|
|
// List of all legal privileges that can be applied to different types |
|
163
|
|
|
// of objects. |
|
164
|
|
|
public $privlist = [ |
|
165
|
|
|
'table' => ['SELECT', 'INSERT', 'UPDATE', 'DELETE', 'REFERENCES', 'TRIGGER', 'ALL PRIVILEGES'], |
|
166
|
|
|
'view' => ['SELECT', 'INSERT', 'UPDATE', 'DELETE', 'REFERENCES', 'TRIGGER', 'ALL PRIVILEGES'], |
|
167
|
|
|
'sequence' => ['SELECT', 'UPDATE', 'ALL PRIVILEGES'], |
|
168
|
|
|
'database' => ['CREATE', 'TEMPORARY', 'CONNECT', 'ALL PRIVILEGES'], |
|
169
|
|
|
'function' => ['EXECUTE', 'ALL PRIVILEGES'], |
|
170
|
|
|
'language' => ['USAGE', 'ALL PRIVILEGES'], |
|
171
|
|
|
'schema' => ['CREATE', 'USAGE', 'ALL PRIVILEGES'], |
|
172
|
|
|
'tablespace' => ['CREATE', 'ALL PRIVILEGES'], |
|
173
|
|
|
'column' => ['SELECT', 'INSERT', 'UPDATE', 'REFERENCES', 'ALL PRIVILEGES'], |
|
174
|
|
|
]; |
|
175
|
|
|
// List of characters in acl lists and the privileges they |
|
176
|
|
|
// refer to. |
|
177
|
|
|
public $privmap = [ |
|
178
|
|
|
'r' => 'SELECT', |
|
179
|
|
|
'w' => 'UPDATE', |
|
180
|
|
|
'a' => 'INSERT', |
|
181
|
|
|
'd' => 'DELETE', |
|
182
|
|
|
'D' => 'TRUNCATE', |
|
183
|
|
|
'R' => 'RULE', |
|
184
|
|
|
'x' => 'REFERENCES', |
|
185
|
|
|
't' => 'TRIGGER', |
|
186
|
|
|
'X' => 'EXECUTE', |
|
187
|
|
|
'U' => 'USAGE', |
|
188
|
|
|
'C' => 'CREATE', |
|
189
|
|
|
'T' => 'TEMPORARY', |
|
190
|
|
|
'c' => 'CONNECT', |
|
191
|
|
|
]; |
|
192
|
|
|
// Rule action types |
|
193
|
|
|
public $rule_events = ['SELECT', 'INSERT', 'UPDATE', 'DELETE']; |
|
194
|
|
|
// Select operators |
|
195
|
|
|
public $selectOps = [ |
|
196
|
|
|
'=' => 'i', |
|
197
|
|
|
'!=' => 'i', |
|
198
|
|
|
'<' => 'i', |
|
199
|
|
|
'>' => 'i', |
|
200
|
|
|
'<=' => 'i', |
|
201
|
|
|
'>=' => 'i', |
|
202
|
|
|
'<<' => 'i', |
|
203
|
|
|
'>>' => 'i', |
|
204
|
|
|
'<<=' => 'i', |
|
205
|
|
|
'>>=' => 'i', |
|
206
|
|
|
'LIKE' => 'i', |
|
207
|
|
|
'NOT LIKE' => 'i', |
|
208
|
|
|
'ILIKE' => 'i', |
|
209
|
|
|
'NOT ILIKE' => 'i', |
|
210
|
|
|
'SIMILAR TO' => 'i', |
|
211
|
|
|
'NOT SIMILAR TO' => 'i', |
|
212
|
|
|
'~' => 'i', |
|
213
|
|
|
'!~' => 'i', |
|
214
|
|
|
'~*' => 'i', |
|
215
|
|
|
'!~*' => 'i', |
|
216
|
|
|
'IS NULL' => 'p', |
|
217
|
|
|
'IS NOT NULL' => 'p', |
|
218
|
|
|
'IN' => 'x', |
|
219
|
|
|
'NOT IN' => 'x', |
|
220
|
|
|
'@@' => 'i', |
|
221
|
|
|
'@@@' => 'i', |
|
222
|
|
|
'@>' => 'i', |
|
223
|
|
|
'<@' => 'i', |
|
224
|
|
|
'@@ to_tsquery' => 't', |
|
225
|
|
|
'@@@ to_tsquery' => 't', |
|
226
|
|
|
'@> to_tsquery' => 't', |
|
227
|
|
|
'<@ to_tsquery' => 't', |
|
228
|
|
|
'@@ plainto_tsquery' => 't', |
|
229
|
|
|
'@@@ plainto_tsquery' => 't', |
|
230
|
|
|
'@> plainto_tsquery' => 't', |
|
231
|
|
|
'<@ plainto_tsquery' => 't', |
|
232
|
|
|
]; |
|
233
|
|
|
// Array of allowed trigger events |
|
234
|
|
|
public $triggerEvents = [ |
|
235
|
|
|
'INSERT', |
|
236
|
|
|
'UPDATE', |
|
237
|
|
|
'DELETE', |
|
238
|
|
|
'INSERT OR UPDATE', |
|
239
|
|
|
'INSERT OR DELETE', |
|
240
|
|
|
'DELETE OR UPDATE', |
|
241
|
|
|
'INSERT OR DELETE OR UPDATE', |
|
242
|
|
|
]; |
|
243
|
|
|
// When to execute the trigger |
|
244
|
|
|
public $triggerExecTimes = ['BEFORE', 'AFTER']; |
|
245
|
|
|
// How often to execute the trigger |
|
246
|
|
|
public $triggerFrequency = ['ROW', 'STATEMENT']; |
|
247
|
|
|
// Array of allowed type alignments |
|
248
|
|
|
public $typAligns = ['char', 'int2', 'int4', 'double']; |
|
249
|
|
|
// The default type alignment |
|
250
|
|
|
public $typAlignDef = 'int4'; |
|
251
|
|
|
// Default index type |
|
252
|
|
|
public $typIndexDef = 'BTREE'; |
|
253
|
|
|
// Array of allowed index types |
|
254
|
|
|
public $typIndexes = ['BTREE', 'RTREE', 'GIST', 'GIN', 'HASH']; |
|
255
|
|
|
// Array of allowed type storage attributes |
|
256
|
|
|
public $typStorages = ['plain', 'external', 'extended', 'main']; |
|
257
|
|
|
// The default type storage |
|
258
|
|
|
public $typStorageDef = 'plain'; |
|
259
|
|
|
/** |
|
260
|
|
|
* Base constructor. |
|
261
|
|
|
* |
|
262
|
|
|
* @param \ADONewConnection &$conn The connection object |
|
|
|
|
|
|
263
|
|
|
*/ |
|
264
|
|
|
public function __construct(&$conn) |
|
265
|
|
|
{ |
|
266
|
|
|
$this->prtrace('instanced connection class'); |
|
267
|
|
|
$this->conn = $conn; |
|
268
|
|
|
} |
|
269
|
|
|
|
|
270
|
|
|
/** |
|
271
|
|
|
* Turns on or off query debugging. |
|
272
|
|
|
* |
|
273
|
|
|
* @param $debug True to turn on debugging, false otherwise |
|
274
|
|
|
*/ |
|
275
|
|
|
public function setDebug($debug) |
|
276
|
|
|
{ |
|
277
|
|
|
$this->conn->debug = $debug; |
|
278
|
|
|
} |
|
279
|
|
|
|
|
280
|
|
|
/** |
|
281
|
|
|
* Cleans (escapes) an array. |
|
282
|
|
|
* |
|
283
|
|
|
* @param $arr The array to clean, by reference |
|
|
|
|
|
|
284
|
|
|
* |
|
285
|
|
|
* @return The cleaned array |
|
286
|
|
|
*/ |
|
287
|
|
|
public function arrayClean(&$arr) |
|
288
|
|
|
{ |
|
289
|
|
|
reset($arr); |
|
290
|
|
|
//while (list($k, $v) = each($arr)) { |
|
291
|
|
|
foreach ($arr as $k => $v) { |
|
292
|
|
|
$arr[$k] = addslashes($v); |
|
293
|
|
|
} |
|
294
|
|
|
|
|
295
|
|
|
return $arr; |
|
296
|
|
|
} |
|
297
|
|
|
|
|
298
|
|
|
/** |
|
299
|
|
|
* Executes a query on the underlying connection. |
|
300
|
|
|
* |
|
301
|
|
|
* @param $sql The SQL query to execute |
|
302
|
|
|
* |
|
303
|
|
|
* @return \ADORecordSet A recordset |
|
304
|
|
|
*/ |
|
305
|
|
|
public function execute($sql) |
|
306
|
|
|
{ |
|
307
|
|
|
// Execute the statement |
|
308
|
|
|
$rs = $this->conn->Execute($sql); |
|
|
|
|
|
|
309
|
|
|
|
|
310
|
|
|
// If failure, return error value |
|
311
|
|
|
return $this->conn->ErrorNo(); |
|
312
|
|
|
} |
|
313
|
|
|
|
|
314
|
|
|
/** |
|
315
|
|
|
* Closes the connection the database class |
|
316
|
|
|
* relies on. |
|
317
|
|
|
*/ |
|
318
|
|
|
public function close() |
|
319
|
|
|
{ |
|
320
|
|
|
$this->conn->close(); |
|
321
|
|
|
} |
|
322
|
|
|
|
|
323
|
|
|
/** |
|
324
|
|
|
* Retrieves a ResultSet from a query. |
|
325
|
|
|
* |
|
326
|
|
|
* @param $sql The SQL statement to be executed |
|
327
|
|
|
* |
|
328
|
|
|
* @return \ADORecordSet A recordset |
|
329
|
|
|
*/ |
|
330
|
|
|
public function selectSet($sql) |
|
331
|
|
|
{ |
|
332
|
|
|
// Execute the statement |
|
333
|
|
|
$rs = $this->conn->Execute($sql); |
|
334
|
|
|
|
|
335
|
|
|
if (!$rs) { |
|
336
|
|
|
return $this->conn->ErrorNo(); |
|
337
|
|
|
} |
|
338
|
|
|
|
|
339
|
|
|
return $rs; |
|
340
|
|
|
} |
|
341
|
|
|
|
|
342
|
|
|
/** |
|
343
|
|
|
* Retrieves a single value from a query. |
|
344
|
|
|
* |
|
345
|
|
|
* @@ assumes that the query will return only one row - returns field value in the first row |
|
346
|
|
|
* |
|
347
|
|
|
* @param $sql The SQL statement to be executed |
|
|
|
|
|
|
348
|
|
|
* @param $field The field name to be returned |
|
349
|
|
|
* |
|
350
|
|
|
* @return A single field value |
|
351
|
|
|
* @return -1 No rows were found |
|
|
|
|
|
|
352
|
|
|
*/ |
|
353
|
|
|
public function selectField($sql, $field) |
|
354
|
|
|
{ |
|
355
|
|
|
// Execute the statement |
|
356
|
|
|
$rs = $this->conn->Execute($sql); |
|
357
|
|
|
|
|
358
|
|
|
// If failure, or no rows returned, return error value |
|
359
|
|
|
if (!$rs) { |
|
360
|
|
|
return $this->conn->ErrorNo(); |
|
361
|
|
|
} |
|
362
|
|
|
|
|
363
|
|
|
if ($rs->RecordCount() == 0) { |
|
364
|
|
|
return -1; |
|
|
|
|
|
|
365
|
|
|
} |
|
366
|
|
|
|
|
367
|
|
|
return $rs->fields[$field]; |
|
368
|
|
|
} |
|
369
|
|
|
|
|
370
|
|
|
/** |
|
371
|
|
|
* Delete from the database. |
|
372
|
|
|
* |
|
373
|
|
|
* @param $table The name of the table |
|
374
|
|
|
* @param $conditions (array) A map of field names to conditions |
|
375
|
|
|
* @param string $schema (optional) The table's schema |
|
376
|
|
|
* |
|
377
|
|
|
* @return int 0 success |
|
378
|
|
|
*/ |
|
379
|
|
|
public function delete($table, $conditions, $schema = '') |
|
380
|
|
|
{ |
|
381
|
|
|
$this->fieldClean($table); |
|
382
|
|
|
|
|
383
|
|
|
reset($conditions); |
|
384
|
|
|
|
|
385
|
|
|
if (!empty($schema)) { |
|
386
|
|
|
$this->fieldClean($schema); |
|
387
|
|
|
$schema = "\"{$schema}\"."; |
|
388
|
|
|
} |
|
389
|
|
|
|
|
390
|
|
|
// Build clause |
|
391
|
|
|
$sql = ''; |
|
392
|
|
|
//while (list($key, $value) = each($conditions)) { |
|
393
|
|
|
foreach ($conditions as $key => $value) { |
|
394
|
|
|
$this->clean($key); |
|
395
|
|
|
$this->clean($value); |
|
396
|
|
|
if ($sql) { |
|
397
|
|
|
$sql .= " AND \"{$key}\"='{$value}'"; |
|
398
|
|
|
} else { |
|
399
|
|
|
$sql = "DELETE FROM {$schema}\"{$table}\" WHERE \"{$key}\"='{$value}'"; |
|
400
|
|
|
} |
|
401
|
|
|
} |
|
402
|
|
|
|
|
403
|
|
|
// Check for failures |
|
404
|
|
|
if (!$this->conn->Execute($sql)) { |
|
405
|
|
|
// Check for referential integrity failure |
|
406
|
|
|
if (stristr($this->conn->ErrorMsg(), 'referential')) { |
|
407
|
|
|
return -1; |
|
408
|
|
|
} |
|
409
|
|
|
} |
|
410
|
|
|
|
|
411
|
|
|
// Check for no rows modified |
|
412
|
|
|
if ($this->conn->Affected_Rows() == 0) { |
|
413
|
|
|
return -2; |
|
414
|
|
|
} |
|
415
|
|
|
|
|
416
|
|
|
return $this->conn->ErrorNo(); |
|
417
|
|
|
} |
|
418
|
|
|
|
|
419
|
|
|
/** |
|
420
|
|
|
* Cleans (escapes) an object name (eg. table, field). |
|
421
|
|
|
* |
|
422
|
|
|
* @param $str The string to clean, by reference |
|
423
|
|
|
* |
|
424
|
|
|
* @return The cleaned string |
|
425
|
|
|
*/ |
|
426
|
|
|
public function fieldClean(&$str) |
|
427
|
|
|
{ |
|
428
|
|
|
$str = str_replace('"', '""', $str); |
|
429
|
|
|
|
|
430
|
|
|
return $str; |
|
431
|
|
|
} |
|
432
|
|
|
|
|
433
|
|
|
/** |
|
434
|
|
|
* Cleans (escapes) a string. |
|
435
|
|
|
* |
|
436
|
|
|
* @param string $str The string to clean, by reference |
|
437
|
|
|
* |
|
438
|
|
|
* @return string The cleaned string |
|
439
|
|
|
*/ |
|
440
|
|
|
public function clean(&$str) |
|
441
|
|
|
{ |
|
442
|
|
|
$str = addslashes($str); |
|
443
|
|
|
|
|
444
|
|
|
return $str; |
|
445
|
|
|
} |
|
446
|
|
|
|
|
447
|
|
|
/** |
|
448
|
|
|
* Insert a set of values into the database. |
|
449
|
|
|
* |
|
450
|
|
|
* @param $table The table to insert into |
|
451
|
|
|
* @param $vars (array) A mapping of the field names to the values to be inserted |
|
452
|
|
|
* |
|
453
|
|
|
* @return int 0 success |
|
454
|
|
|
*/ |
|
455
|
|
|
public function insert($table, $vars) |
|
456
|
|
|
{ |
|
457
|
|
|
$this->fieldClean($table); |
|
458
|
|
|
|
|
459
|
|
|
// Build clause |
|
460
|
|
|
if (sizeof($vars) > 0) { |
|
461
|
|
|
$fields = ''; |
|
462
|
|
|
$values = ''; |
|
463
|
|
|
foreach ($vars as $key => $value) { |
|
464
|
|
|
$this->clean($key); |
|
465
|
|
|
$this->clean($value); |
|
466
|
|
|
|
|
467
|
|
|
if ($fields) { |
|
468
|
|
|
$fields .= ", \"{$key}\""; |
|
469
|
|
|
} else { |
|
470
|
|
|
$fields = "INSERT INTO \"{$table}\" (\"{$key}\""; |
|
471
|
|
|
} |
|
472
|
|
|
|
|
473
|
|
|
if ($values) { |
|
474
|
|
|
$values .= ", '{$value}'"; |
|
475
|
|
|
} else { |
|
476
|
|
|
$values = ") VALUES ('{$value}'"; |
|
477
|
|
|
} |
|
478
|
|
|
} |
|
479
|
|
|
$sql = $fields . $values . ')'; |
|
480
|
|
|
} |
|
481
|
|
|
|
|
482
|
|
|
// Check for failures |
|
483
|
|
|
if (!$this->conn->Execute($sql)) { |
|
|
|
|
|
|
484
|
|
|
// Check for unique constraint failure |
|
485
|
|
|
if (stristr($this->conn->ErrorMsg(), 'unique')) { |
|
486
|
|
|
return -1; |
|
487
|
|
|
} |
|
488
|
|
|
|
|
489
|
|
|
if (stristr($this->conn->ErrorMsg(), 'referential')) { |
|
490
|
|
|
return -2; |
|
491
|
|
|
} // Check for referential integrity failure |
|
492
|
|
|
} |
|
493
|
|
|
|
|
494
|
|
|
return $this->conn->ErrorNo(); |
|
495
|
|
|
} |
|
496
|
|
|
|
|
497
|
|
|
/** |
|
498
|
|
|
* Update a row in the database. |
|
499
|
|
|
* |
|
500
|
|
|
* @param $table The table that is to be updated |
|
501
|
|
|
* @param $vars (array) A mapping of the field names to the values to be updated |
|
502
|
|
|
* @param $where (array) A mapping of field names to values for the where clause |
|
503
|
|
|
* @param array $nulls (array, optional) An array of fields to be set null |
|
504
|
|
|
* |
|
505
|
|
|
* @return int 0 success |
|
506
|
|
|
*/ |
|
507
|
|
|
public function update($table, $vars, $where, $nulls = []) |
|
508
|
|
|
{ |
|
509
|
|
|
$this->fieldClean($table); |
|
510
|
|
|
|
|
511
|
|
|
$setClause = ''; |
|
512
|
|
|
$whereClause = ''; |
|
513
|
|
|
|
|
514
|
|
|
// Populate the syntax arrays |
|
515
|
|
|
reset($vars); |
|
516
|
|
|
//while (list($key, $value) = each($vars)) { |
|
517
|
|
|
foreach ($vars as $key => $value) { |
|
518
|
|
|
$this->fieldClean($key); |
|
519
|
|
|
$this->clean($value); |
|
520
|
|
|
if ($setClause) { |
|
521
|
|
|
$setClause .= ", \"{$key}\"='{$value}'"; |
|
522
|
|
|
} else { |
|
523
|
|
|
$setClause = "UPDATE \"{$table}\" SET \"{$key}\"='{$value}'"; |
|
524
|
|
|
} |
|
525
|
|
|
} |
|
526
|
|
|
|
|
527
|
|
|
reset($nulls); |
|
528
|
|
|
//while (list(, $value) = each($nulls)) { |
|
529
|
|
|
foreach ($nulls as $key => $value) { |
|
530
|
|
|
$this->fieldClean($value); |
|
531
|
|
|
if ($setClause) { |
|
532
|
|
|
$setClause .= ", \"{$value}\"=NULL"; |
|
533
|
|
|
} else { |
|
534
|
|
|
$setClause = "UPDATE \"{$table}\" SET \"{$value}\"=NULL"; |
|
535
|
|
|
} |
|
536
|
|
|
} |
|
537
|
|
|
|
|
538
|
|
|
reset($where); |
|
539
|
|
|
//while (list($key, $value) = each($where)) { |
|
540
|
|
|
foreach ($where as $key => $value) { |
|
541
|
|
|
$this->fieldClean($key); |
|
542
|
|
|
$this->clean($value); |
|
543
|
|
|
if ($whereClause) { |
|
544
|
|
|
$whereClause .= " AND \"{$key}\"='{$value}'"; |
|
545
|
|
|
} else { |
|
546
|
|
|
$whereClause = " WHERE \"{$key}\"='{$value}'"; |
|
547
|
|
|
} |
|
548
|
|
|
} |
|
549
|
|
|
|
|
550
|
|
|
// Check for failures |
|
551
|
|
|
if (!$this->conn->Execute($setClause . $whereClause)) { |
|
552
|
|
|
// Check for unique constraint failure |
|
553
|
|
|
if (stristr($this->conn->ErrorMsg(), 'unique')) { |
|
554
|
|
|
return -1; |
|
555
|
|
|
} |
|
556
|
|
|
|
|
557
|
|
|
if (stristr($this->conn->ErrorMsg(), 'referential')) { |
|
558
|
|
|
return -2; |
|
559
|
|
|
} // Check for referential integrity failure |
|
560
|
|
|
} |
|
561
|
|
|
|
|
562
|
|
|
// Check for no rows modified |
|
563
|
|
|
if ($this->conn->Affected_Rows() == 0) { |
|
564
|
|
|
return -3; |
|
565
|
|
|
} |
|
566
|
|
|
|
|
567
|
|
|
return $this->conn->ErrorNo(); |
|
568
|
|
|
} |
|
569
|
|
|
|
|
570
|
|
|
/** |
|
571
|
|
|
* Begin a transaction. |
|
572
|
|
|
* |
|
573
|
|
|
* @return bool 0 success |
|
574
|
|
|
*/ |
|
575
|
|
|
public function beginTransaction() |
|
576
|
|
|
{ |
|
577
|
|
|
return !$this->conn->BeginTrans(); |
|
578
|
|
|
} |
|
579
|
|
|
|
|
580
|
|
|
/** |
|
581
|
|
|
* End a transaction. |
|
582
|
|
|
* |
|
583
|
|
|
* @return bool 0 success |
|
584
|
|
|
*/ |
|
585
|
|
|
public function endTransaction() |
|
586
|
|
|
{ |
|
587
|
|
|
return !$this->conn->CommitTrans(); |
|
588
|
|
|
} |
|
589
|
|
|
|
|
590
|
|
|
/** |
|
591
|
|
|
* Roll back a transaction. |
|
592
|
|
|
* |
|
593
|
|
|
* @return bool 0 success |
|
594
|
|
|
*/ |
|
595
|
|
|
public function rollbackTransaction() |
|
596
|
|
|
{ |
|
597
|
|
|
return !$this->conn->RollbackTrans(); |
|
598
|
|
|
} |
|
599
|
|
|
|
|
600
|
|
|
/** |
|
601
|
|
|
* Get the backend platform. |
|
602
|
|
|
* |
|
603
|
|
|
* @return The backend platform |
|
604
|
|
|
*/ |
|
605
|
|
|
public function getPlatform() |
|
606
|
|
|
{ |
|
607
|
|
|
//return $this->conn->platform; |
|
608
|
|
|
return 'UNKNOWN'; |
|
|
|
|
|
|
609
|
|
|
} |
|
610
|
|
|
|
|
611
|
|
|
// Type conversion routines |
|
612
|
|
|
|
|
613
|
|
|
/** |
|
614
|
|
|
* Change the value of a parameter to database representation depending on whether it evaluates to true or false. |
|
|
|
|
|
|
615
|
|
|
* |
|
616
|
|
|
* @param $parameter the parameter |
|
617
|
|
|
* |
|
618
|
|
|
* @return \PHPPgAdmin\Database\the |
|
619
|
|
|
*/ |
|
620
|
|
|
public function dbBool(&$parameter) |
|
621
|
|
|
{ |
|
622
|
|
|
return $parameter; |
|
623
|
|
|
} |
|
624
|
|
|
|
|
625
|
|
|
/** |
|
626
|
|
|
* Change a parameter from database representation to a boolean, (others evaluate to false). |
|
627
|
|
|
* |
|
628
|
|
|
* @param $parameter the parameter |
|
629
|
|
|
* |
|
630
|
|
|
* @return \PHPPgAdmin\Database\the |
|
631
|
|
|
*/ |
|
632
|
|
|
public function phpBool($parameter) |
|
633
|
|
|
{ |
|
634
|
|
|
return $parameter; |
|
635
|
|
|
} |
|
636
|
|
|
|
|
637
|
|
|
/** |
|
638
|
|
|
* Change a db array into a PHP array. |
|
639
|
|
|
* |
|
640
|
|
|
* @param $dbarr |
|
641
|
|
|
* |
|
642
|
|
|
* @return array A PHP array |
|
643
|
|
|
* |
|
644
|
|
|
* @internal param String $arr representing the DB array |
|
645
|
|
|
*/ |
|
646
|
|
|
public function phpArray($dbarr) |
|
647
|
|
|
{ |
|
648
|
|
|
// Take off the first and last characters (the braces) |
|
649
|
|
|
$arr = substr($dbarr, 1, strlen($dbarr) - 2); |
|
650
|
|
|
|
|
651
|
|
|
// Pick out array entries by carefully parsing. This is necessary in order |
|
652
|
|
|
// to cope with double quotes and commas, etc. |
|
653
|
|
|
$elements = []; |
|
654
|
|
|
$i = $j = 0; |
|
655
|
|
|
$in_quotes = false; |
|
656
|
|
|
while ($i < strlen($arr)) { |
|
657
|
|
|
// If current char is a double quote and it's not escaped, then |
|
658
|
|
|
// enter quoted bit |
|
659
|
|
|
$char = substr($arr, $i, 1); |
|
660
|
|
|
if ($char == '"' && ($i == 0 || substr($arr, $i - 1, 1) != '\\')) { |
|
661
|
|
|
$in_quotes = !$in_quotes; |
|
|
|
|
|
|
662
|
|
|
} elseif ($char == ',' && !$in_quotes) { |
|
663
|
|
|
// Add text so far to the array |
|
664
|
|
|
$elements[] = substr($arr, $j, $i - $j); |
|
665
|
|
|
$j = $i + 1; |
|
666
|
|
|
} |
|
667
|
|
|
++$i; |
|
668
|
|
|
} |
|
669
|
|
|
// Add final text to the array |
|
670
|
|
|
$elements[] = substr($arr, $j); |
|
671
|
|
|
|
|
672
|
|
|
// Do one further loop over the elements array to remote double quoting |
|
673
|
|
|
// and escaping of double quotes and backslashes |
|
674
|
|
|
for ($i = 0; $i < sizeof($elements); ++$i) { |
|
|
|
|
|
|
675
|
|
|
$v = $elements[$i]; |
|
676
|
|
|
if (strpos($v, '"') === 0) { |
|
677
|
|
|
$v = substr($v, 1, strlen($v) - 2); |
|
678
|
|
|
$v = str_replace('\\"', '"', $v); |
|
679
|
|
|
$v = str_replace('\\\\', '\\', $v); |
|
680
|
|
|
$elements[$i] = $v; |
|
681
|
|
|
} |
|
682
|
|
|
} |
|
683
|
|
|
|
|
684
|
|
|
return $elements; |
|
685
|
|
|
} |
|
686
|
|
|
|
|
687
|
|
|
/** |
|
688
|
|
|
* Determines if it has tablespaces. |
|
689
|
|
|
* |
|
690
|
|
|
* @return boolean True if has tablespaces, False otherwise. |
|
691
|
|
|
*/ |
|
692
|
|
|
public function hasTablespaces() |
|
693
|
|
|
{ |
|
694
|
|
|
return true; |
|
695
|
|
|
} |
|
696
|
|
|
|
|
697
|
|
|
/** |
|
698
|
|
|
* Determines if it has shared comments. |
|
699
|
|
|
* |
|
700
|
|
|
* @return boolean True if has shared comments, False otherwise. |
|
701
|
|
|
*/ |
|
702
|
|
|
public function hasSharedComments() |
|
703
|
|
|
{ |
|
704
|
|
|
return true; |
|
705
|
|
|
} |
|
706
|
|
|
|
|
707
|
|
|
/** |
|
708
|
|
|
* Determines if it has roles. |
|
709
|
|
|
* |
|
710
|
|
|
* @return boolean True if has roles, False otherwise. |
|
711
|
|
|
*/ |
|
712
|
|
|
public function hasRoles() |
|
713
|
|
|
{ |
|
714
|
|
|
return true; |
|
715
|
|
|
} |
|
716
|
|
|
|
|
717
|
|
|
/** |
|
718
|
|
|
* Determines if it has grant option. |
|
719
|
|
|
* |
|
720
|
|
|
* @return boolean True if has grant option, False otherwise. |
|
721
|
|
|
*/ |
|
722
|
|
|
public function hasGrantOption() |
|
723
|
|
|
{ |
|
724
|
|
|
return true; |
|
725
|
|
|
} |
|
726
|
|
|
|
|
727
|
|
|
/** |
|
728
|
|
|
* Determines if it has create table like with constraints. |
|
729
|
|
|
* |
|
730
|
|
|
* @return boolean True if has create table like with constraints, False otherwise. |
|
731
|
|
|
*/ |
|
732
|
|
|
public function hasCreateTableLikeWithConstraints() |
|
733
|
|
|
{ |
|
734
|
|
|
return true; |
|
735
|
|
|
} |
|
736
|
|
|
|
|
737
|
|
|
/** |
|
738
|
|
|
* Determines if it has create table like with indexes. |
|
739
|
|
|
* |
|
740
|
|
|
* @return boolean True if has create table like with indexes, False otherwise. |
|
741
|
|
|
*/ |
|
742
|
|
|
public function hasCreateTableLikeWithIndexes() |
|
743
|
|
|
{ |
|
744
|
|
|
return true; |
|
745
|
|
|
} |
|
746
|
|
|
|
|
747
|
|
|
/** |
|
748
|
|
|
* Determines if it has create field with constraints. |
|
749
|
|
|
* |
|
750
|
|
|
* @return boolean True if has create field with constraints, False otherwise. |
|
751
|
|
|
*/ |
|
752
|
|
|
public function hasCreateFieldWithConstraints() |
|
753
|
|
|
{ |
|
754
|
|
|
return true; |
|
755
|
|
|
} |
|
756
|
|
|
|
|
757
|
|
|
/** |
|
758
|
|
|
* Determines if it has domain constraints. |
|
759
|
|
|
* |
|
760
|
|
|
* @return boolean True if has domain constraints, False otherwise. |
|
761
|
|
|
*/ |
|
762
|
|
|
public function hasDomainConstraints() |
|
763
|
|
|
{ |
|
764
|
|
|
return true; |
|
765
|
|
|
} |
|
766
|
|
|
|
|
767
|
|
|
/** |
|
768
|
|
|
* Determines if it has function alter owner. |
|
769
|
|
|
* |
|
770
|
|
|
* @return boolean True if has function alter owner, False otherwise. |
|
771
|
|
|
*/ |
|
772
|
|
|
public function hasFunctionAlterOwner() |
|
773
|
|
|
{ |
|
774
|
|
|
return true; |
|
775
|
|
|
} |
|
776
|
|
|
|
|
777
|
|
|
/** |
|
778
|
|
|
* Determines if it has function alter schema. |
|
779
|
|
|
* |
|
780
|
|
|
* @return boolean True if has function alter schema, False otherwise. |
|
781
|
|
|
*/ |
|
782
|
|
|
public function hasFunctionAlterSchema() |
|
783
|
|
|
{ |
|
784
|
|
|
return true; |
|
785
|
|
|
} |
|
786
|
|
|
|
|
787
|
|
|
/** |
|
788
|
|
|
* Determines if it has read only queries. |
|
789
|
|
|
* |
|
790
|
|
|
* @return boolean True if has read only queries, False otherwise. |
|
791
|
|
|
*/ |
|
792
|
|
|
public function hasReadOnlyQueries() |
|
793
|
|
|
{ |
|
794
|
|
|
return true; |
|
795
|
|
|
} |
|
796
|
|
|
|
|
797
|
|
|
/** |
|
798
|
|
|
* Determines if it has aggregate sort operation. |
|
799
|
|
|
* |
|
800
|
|
|
* @return boolean True if has aggregate sort operation, False otherwise. |
|
801
|
|
|
*/ |
|
802
|
|
|
public function hasAggregateSortOp() |
|
803
|
|
|
{ |
|
804
|
|
|
return true; |
|
805
|
|
|
} |
|
806
|
|
|
|
|
807
|
|
|
/** |
|
808
|
|
|
* Determines if it has alter aggregate. |
|
809
|
|
|
* |
|
810
|
|
|
* @return boolean True if has alter aggregate, False otherwise. |
|
811
|
|
|
*/ |
|
812
|
|
|
public function hasAlterAggregate() |
|
813
|
|
|
{ |
|
814
|
|
|
return true; |
|
815
|
|
|
} |
|
816
|
|
|
|
|
817
|
|
|
/** |
|
818
|
|
|
* Determines if it has alter column type. |
|
819
|
|
|
* |
|
820
|
|
|
* @return boolean True if has alter column type, False otherwise. |
|
821
|
|
|
*/ |
|
822
|
|
|
public function hasAlterColumnType() |
|
823
|
|
|
{ |
|
824
|
|
|
return true; |
|
825
|
|
|
} |
|
826
|
|
|
|
|
827
|
|
|
/** |
|
828
|
|
|
* Determines if it has alter database owner. |
|
829
|
|
|
* |
|
830
|
|
|
* @return boolean True if has alter database owner, False otherwise. |
|
831
|
|
|
*/ |
|
832
|
|
|
public function hasAlterDatabaseOwner() |
|
833
|
|
|
{ |
|
834
|
|
|
return true; |
|
835
|
|
|
} |
|
836
|
|
|
|
|
837
|
|
|
/** |
|
838
|
|
|
* Determines if it has alter schema. |
|
839
|
|
|
* |
|
840
|
|
|
* @return boolean True if has alter schema, False otherwise. |
|
841
|
|
|
*/ |
|
842
|
|
|
public function hasAlterSchema() |
|
843
|
|
|
{ |
|
844
|
|
|
return true; |
|
845
|
|
|
} |
|
846
|
|
|
|
|
847
|
|
|
/** |
|
848
|
|
|
* Determines if it has alter schema owner. |
|
849
|
|
|
* |
|
850
|
|
|
* @return boolean True if has alter schema owner, False otherwise. |
|
851
|
|
|
*/ |
|
852
|
|
|
public function hasAlterSchemaOwner() |
|
853
|
|
|
{ |
|
854
|
|
|
return true; |
|
855
|
|
|
} |
|
856
|
|
|
|
|
857
|
|
|
/** |
|
858
|
|
|
* Determines if it has alter sequence schema. |
|
859
|
|
|
* |
|
860
|
|
|
* @return boolean True if has alter sequence schema, False otherwise. |
|
861
|
|
|
*/ |
|
862
|
|
|
public function hasAlterSequenceSchema() |
|
863
|
|
|
{ |
|
864
|
|
|
return true; |
|
865
|
|
|
} |
|
866
|
|
|
|
|
867
|
|
|
/** |
|
868
|
|
|
* Determines if it has alter sequence start. |
|
869
|
|
|
* |
|
870
|
|
|
* @return boolean True if has alter sequence start, False otherwise. |
|
871
|
|
|
*/ |
|
872
|
|
|
public function hasAlterSequenceStart() |
|
873
|
|
|
{ |
|
874
|
|
|
return true; |
|
875
|
|
|
} |
|
876
|
|
|
|
|
877
|
|
|
/** |
|
878
|
|
|
* Determines if it has alter table schema. |
|
879
|
|
|
* |
|
880
|
|
|
* @return boolean True if has alter table schema, False otherwise. |
|
881
|
|
|
*/ |
|
882
|
|
|
public function hasAlterTableSchema() |
|
883
|
|
|
{ |
|
884
|
|
|
return true; |
|
885
|
|
|
} |
|
886
|
|
|
|
|
887
|
|
|
/** |
|
888
|
|
|
* Determines if it has autovacuum. |
|
889
|
|
|
* |
|
890
|
|
|
* @return boolean True if has autovacuum, False otherwise. |
|
891
|
|
|
*/ |
|
892
|
|
|
public function hasAutovacuum() |
|
893
|
|
|
{ |
|
894
|
|
|
return true; |
|
895
|
|
|
} |
|
896
|
|
|
|
|
897
|
|
|
/** |
|
898
|
|
|
* Determines if it has create table like. |
|
899
|
|
|
* |
|
900
|
|
|
* @return boolean True if has create table like, False otherwise. |
|
901
|
|
|
*/ |
|
902
|
|
|
public function hasCreateTableLike() |
|
903
|
|
|
{ |
|
904
|
|
|
return true; |
|
905
|
|
|
} |
|
906
|
|
|
|
|
907
|
|
|
/** |
|
908
|
|
|
* Determines if it has disable triggers. |
|
909
|
|
|
* |
|
910
|
|
|
* @return boolean True if has disable triggers, False otherwise. |
|
911
|
|
|
*/ |
|
912
|
|
|
public function hasDisableTriggers() |
|
913
|
|
|
{ |
|
914
|
|
|
return true; |
|
915
|
|
|
} |
|
916
|
|
|
|
|
917
|
|
|
/** |
|
918
|
|
|
* Determines if it has alter domains. |
|
919
|
|
|
* |
|
920
|
|
|
* @return boolean True if has alter domains, False otherwise. |
|
921
|
|
|
*/ |
|
922
|
|
|
public function hasAlterDomains() |
|
923
|
|
|
{ |
|
924
|
|
|
return true; |
|
925
|
|
|
} |
|
926
|
|
|
|
|
927
|
|
|
/** |
|
928
|
|
|
* Determines if it has enum types. |
|
929
|
|
|
* |
|
930
|
|
|
* @return boolean True if has enum types, False otherwise. |
|
931
|
|
|
*/ |
|
932
|
|
|
public function hasEnumTypes() |
|
933
|
|
|
{ |
|
934
|
|
|
return true; |
|
935
|
|
|
} |
|
936
|
|
|
|
|
937
|
|
|
/** |
|
938
|
|
|
* Determines if it has fts. |
|
939
|
|
|
* |
|
940
|
|
|
* @return boolean True if has fts, False otherwise. |
|
941
|
|
|
*/ |
|
942
|
|
|
public function hasFTS() |
|
943
|
|
|
{ |
|
944
|
|
|
return true; |
|
945
|
|
|
} |
|
946
|
|
|
|
|
947
|
|
|
/** |
|
948
|
|
|
* Determines if it has function costing. |
|
949
|
|
|
* |
|
950
|
|
|
* @return boolean True if has function costing, False otherwise. |
|
951
|
|
|
*/ |
|
952
|
|
|
public function hasFunctionCosting() |
|
953
|
|
|
{ |
|
954
|
|
|
return true; |
|
955
|
|
|
} |
|
956
|
|
|
|
|
957
|
|
|
/** |
|
958
|
|
|
* Determines if it has function guc. |
|
959
|
|
|
* |
|
960
|
|
|
* @return boolean True if has function guc, False otherwise. |
|
961
|
|
|
*/ |
|
962
|
|
|
public function hasFunctionGUC() |
|
963
|
|
|
{ |
|
964
|
|
|
return true; |
|
965
|
|
|
} |
|
966
|
|
|
|
|
967
|
|
|
/** |
|
968
|
|
|
* Determines if it has named parameters. |
|
969
|
|
|
* |
|
970
|
|
|
* @return boolean True if has named parameters, False otherwise. |
|
971
|
|
|
*/ |
|
972
|
|
|
public function hasNamedParams() |
|
973
|
|
|
{ |
|
974
|
|
|
return true; |
|
975
|
|
|
} |
|
976
|
|
|
|
|
977
|
|
|
/** |
|
978
|
|
|
* Determines if it has prepare. |
|
979
|
|
|
* |
|
980
|
|
|
* @return boolean True if has prepare, False otherwise. |
|
981
|
|
|
*/ |
|
982
|
|
|
public function hasPrepare() |
|
983
|
|
|
{ |
|
984
|
|
|
return true; |
|
985
|
|
|
} |
|
986
|
|
|
|
|
987
|
|
|
/** |
|
988
|
|
|
* Determines if it has prepared xacts. |
|
989
|
|
|
* |
|
990
|
|
|
* @return boolean True if has prepared xacts, False otherwise. |
|
991
|
|
|
*/ |
|
992
|
|
|
public function hasPreparedXacts() |
|
993
|
|
|
{ |
|
994
|
|
|
return true; |
|
995
|
|
|
} |
|
996
|
|
|
|
|
997
|
|
|
/** |
|
998
|
|
|
* Determines if it has recluster. |
|
999
|
|
|
* |
|
1000
|
|
|
* @return boolean True if has recluster, False otherwise. |
|
1001
|
|
|
*/ |
|
1002
|
|
|
public function hasRecluster() |
|
1003
|
|
|
{ |
|
1004
|
|
|
return true; |
|
1005
|
|
|
} |
|
1006
|
|
|
|
|
1007
|
|
|
/** |
|
1008
|
|
|
* Determines if it has server admin funcs. |
|
1009
|
|
|
* |
|
1010
|
|
|
* @return boolean True if has server admin funcs, False otherwise. |
|
1011
|
|
|
*/ |
|
1012
|
|
|
public function hasServerAdminFuncs() |
|
1013
|
|
|
{ |
|
1014
|
|
|
return true; |
|
1015
|
|
|
} |
|
1016
|
|
|
|
|
1017
|
|
|
/** |
|
1018
|
|
|
* Determines if it has query cancel. |
|
1019
|
|
|
* |
|
1020
|
|
|
* @return boolean True if has query cancel, False otherwise. |
|
1021
|
|
|
*/ |
|
1022
|
|
|
public function hasQueryCancel() |
|
1023
|
|
|
{ |
|
1024
|
|
|
return true; |
|
1025
|
|
|
} |
|
1026
|
|
|
|
|
1027
|
|
|
/** |
|
1028
|
|
|
* Determines if it has user rename. |
|
1029
|
|
|
* |
|
1030
|
|
|
* @return boolean True if has user rename, False otherwise. |
|
1031
|
|
|
*/ |
|
1032
|
|
|
public function hasUserRename() |
|
1033
|
|
|
{ |
|
1034
|
|
|
return true; |
|
1035
|
|
|
} |
|
1036
|
|
|
|
|
1037
|
|
|
/** |
|
1038
|
|
|
* Determines if it has user signals. |
|
1039
|
|
|
* |
|
1040
|
|
|
* @return boolean True if has user signals, False otherwise. |
|
1041
|
|
|
*/ |
|
1042
|
|
|
public function hasUserSignals() |
|
1043
|
|
|
{ |
|
1044
|
|
|
return true; |
|
1045
|
|
|
} |
|
1046
|
|
|
|
|
1047
|
|
|
/** |
|
1048
|
|
|
* Determines if it has virtual transaction identifier. |
|
1049
|
|
|
* |
|
1050
|
|
|
* @return boolean True if has virtual transaction identifier, False otherwise. |
|
1051
|
|
|
*/ |
|
1052
|
|
|
public function hasVirtualTransactionId() |
|
1053
|
|
|
{ |
|
1054
|
|
|
return true; |
|
1055
|
|
|
} |
|
1056
|
|
|
|
|
1057
|
|
|
/** |
|
1058
|
|
|
* Determines if it has alter database. |
|
1059
|
|
|
* |
|
1060
|
|
|
* @return boolean True if has alter database, False otherwise. |
|
1061
|
|
|
*/ |
|
1062
|
|
|
public function hasAlterDatabase() |
|
1063
|
|
|
{ |
|
1064
|
|
|
return $this->hasAlterDatabaseRename(); |
|
1065
|
|
|
} |
|
1066
|
|
|
|
|
1067
|
|
|
/** |
|
1068
|
|
|
* Determines if it has alter database rename. |
|
1069
|
|
|
* |
|
1070
|
|
|
* @return boolean True if has alter database rename, False otherwise. |
|
1071
|
|
|
*/ |
|
1072
|
|
|
public function hasAlterDatabaseRename() |
|
1073
|
|
|
{ |
|
1074
|
|
|
return true; |
|
1075
|
|
|
} |
|
1076
|
|
|
|
|
1077
|
|
|
/** |
|
1078
|
|
|
* Determines if it has database collation. |
|
1079
|
|
|
* |
|
1080
|
|
|
* @return boolean True if has database collation, False otherwise. |
|
1081
|
|
|
*/ |
|
1082
|
|
|
public function hasDatabaseCollation() |
|
1083
|
|
|
{ |
|
1084
|
|
|
return true; |
|
1085
|
|
|
} |
|
1086
|
|
|
|
|
1087
|
|
|
/** |
|
1088
|
|
|
* Determines if it has magic types. |
|
1089
|
|
|
* |
|
1090
|
|
|
* @return boolean True if has magic types, False otherwise. |
|
1091
|
|
|
*/ |
|
1092
|
|
|
public function hasMagicTypes() |
|
1093
|
|
|
{ |
|
1094
|
|
|
return true; |
|
1095
|
|
|
} |
|
1096
|
|
|
|
|
1097
|
|
|
/** |
|
1098
|
|
|
* Determines if it has query kill. |
|
1099
|
|
|
* |
|
1100
|
|
|
* @return boolean True if has query kill, False otherwise. |
|
1101
|
|
|
*/ |
|
1102
|
|
|
public function hasQueryKill() |
|
1103
|
|
|
{ |
|
1104
|
|
|
return true; |
|
1105
|
|
|
} |
|
1106
|
|
|
|
|
1107
|
|
|
/** |
|
1108
|
|
|
* Determines if it has concurrent index build. |
|
1109
|
|
|
* |
|
1110
|
|
|
* @return boolean True if has concurrent index build, False otherwise. |
|
1111
|
|
|
*/ |
|
1112
|
|
|
public function hasConcurrentIndexBuild() |
|
1113
|
|
|
{ |
|
1114
|
|
|
return true; |
|
1115
|
|
|
} |
|
1116
|
|
|
|
|
1117
|
|
|
/** |
|
1118
|
|
|
* Determines if it has force reindex. |
|
1119
|
|
|
* |
|
1120
|
|
|
* @return boolean True if has force reindex, False otherwise. |
|
1121
|
|
|
*/ |
|
1122
|
|
|
public function hasForceReindex() |
|
1123
|
|
|
{ |
|
1124
|
|
|
return false; |
|
1125
|
|
|
} |
|
1126
|
|
|
|
|
1127
|
|
|
/** |
|
1128
|
|
|
* Determines if it has bytea hexadecimal default. |
|
1129
|
|
|
* |
|
1130
|
|
|
* @return boolean True if has bytea hexadecimal default, False otherwise. |
|
1131
|
|
|
*/ |
|
1132
|
|
|
public function hasByteaHexDefault() |
|
1133
|
|
|
{ |
|
1134
|
|
|
return true; |
|
1135
|
|
|
} |
|
1136
|
|
|
} |
|
1137
|
|
|
|