|
@@ 2819-2831 (lines=13) @@
|
| 2816 |
|
* @param $cascade True to cascade drop, false to restrict |
| 2817 |
|
* @return \PHPPgAdmin\Database\A 0 success |
| 2818 |
|
*/ |
| 2819 |
|
public function dropTable($table, $cascade) |
| 2820 |
|
{ |
| 2821 |
|
$f_schema = $this->_schema; |
| 2822 |
|
$this->fieldClean($f_schema); |
| 2823 |
|
$this->fieldClean($table); |
| 2824 |
|
|
| 2825 |
|
$sql = "DROP TABLE \"{$f_schema}\".\"{$table}\""; |
| 2826 |
|
if ($cascade) { |
| 2827 |
|
$sql .= ' CASCADE'; |
| 2828 |
|
} |
| 2829 |
|
|
| 2830 |
|
return $this->execute($sql); |
| 2831 |
|
} |
| 2832 |
|
|
| 2833 |
|
/** |
| 2834 |
|
* Add a new column to a table |
|
@@ 3079-3089 (lines=11) @@
|
| 3076 |
|
* @param $default The new default value |
| 3077 |
|
* @return \PHPPgAdmin\Database\A 0 success |
| 3078 |
|
*/ |
| 3079 |
|
public function setColumnDefault($table, $column, $default) |
| 3080 |
|
{ |
| 3081 |
|
$f_schema = $this->_schema; |
| 3082 |
|
$this->fieldClean($f_schema); |
| 3083 |
|
$this->fieldClean($table); |
| 3084 |
|
$this->fieldClean($column); |
| 3085 |
|
|
| 3086 |
|
$sql = "ALTER TABLE \"{$f_schema}\".\"{$table}\" ALTER COLUMN \"{$column}\" SET DEFAULT {$default}"; |
| 3087 |
|
|
| 3088 |
|
return $this->execute($sql); |
| 3089 |
|
} |
| 3090 |
|
|
| 3091 |
|
/** |
| 3092 |
|
* Sets whether or not a column can contain NULLs |
|
@@ 3119-3132 (lines=14) @@
|
| 3116 |
|
* @param $cascade True to cascade drop, false to restrict |
| 3117 |
|
* @return \PHPPgAdmin\Database\A 0 success |
| 3118 |
|
*/ |
| 3119 |
|
public function dropColumn($table, $column, $cascade) |
| 3120 |
|
{ |
| 3121 |
|
$f_schema = $this->_schema; |
| 3122 |
|
$this->fieldClean($f_schema); |
| 3123 |
|
$this->fieldClean($table); |
| 3124 |
|
$this->fieldClean($column); |
| 3125 |
|
|
| 3126 |
|
$sql = "ALTER TABLE \"{$f_schema}\".\"{$table}\" DROP COLUMN \"{$column}\""; |
| 3127 |
|
if ($cascade) { |
| 3128 |
|
$sql .= ' CASCADE'; |
| 3129 |
|
} |
| 3130 |
|
|
| 3131 |
|
return $this->execute($sql); |
| 3132 |
|
} |
| 3133 |
|
|
| 3134 |
|
/** |
| 3135 |
|
* Drops default value of a column |
|
@@ 3141-3151 (lines=11) @@
|
| 3138 |
|
* @param $column The column name to drop default |
| 3139 |
|
* @return \PHPPgAdmin\Database\A 0 success |
| 3140 |
|
*/ |
| 3141 |
|
public function dropColumnDefault($table, $column) |
| 3142 |
|
{ |
| 3143 |
|
$f_schema = $this->_schema; |
| 3144 |
|
$this->fieldClean($f_schema); |
| 3145 |
|
$this->fieldClean($table); |
| 3146 |
|
$this->fieldClean($column); |
| 3147 |
|
|
| 3148 |
|
$sql = "ALTER TABLE \"{$f_schema}\".\"{$table}\" ALTER COLUMN \"{$column}\" DROP DEFAULT"; |
| 3149 |
|
|
| 3150 |
|
return $this->execute($sql); |
| 3151 |
|
} |
| 3152 |
|
|
| 3153 |
|
/** |
| 3154 |
|
* Sets up the data object for a dump. eg. Starts the appropriate |
|
@@ 3650-3660 (lines=11) @@
|
| 3647 |
|
* @param $sequence Sequence name |
| 3648 |
|
* @return \PHPPgAdmin\Database\A 0 success |
| 3649 |
|
*/ |
| 3650 |
|
public function restartSequence($sequence) |
| 3651 |
|
{ |
| 3652 |
|
$f_schema = $this->_schema; |
| 3653 |
|
$this->fieldClean($f_schema); |
| 3654 |
|
$this->fieldClean($sequence); |
| 3655 |
|
|
| 3656 |
|
$sql = "ALTER SEQUENCE \"{$f_schema}\".\"{$sequence}\" RESTART;"; |
| 3657 |
|
|
| 3658 |
|
return $this->execute($sql); |
| 3659 |
|
} |
| 3660 |
|
|
| 3661 |
|
/** |
| 3662 |
|
* Resets a given sequence to min value of sequence |
| 3663 |
|
* |
|
@@ 4054-4066 (lines=13) @@
|
| 4051 |
|
* @param $cascade True to cascade drop, false to restrict |
| 4052 |
|
* @return \PHPPgAdmin\Database\A 0 success |
| 4053 |
|
*/ |
| 4054 |
|
public function dropSequence($sequence, $cascade) |
| 4055 |
|
{ |
| 4056 |
|
$f_schema = $this->_schema; |
| 4057 |
|
$this->fieldClean($f_schema); |
| 4058 |
|
$this->fieldClean($sequence); |
| 4059 |
|
|
| 4060 |
|
$sql = "DROP SEQUENCE \"{$f_schema}\".\"{$sequence}\""; |
| 4061 |
|
if ($cascade) { |
| 4062 |
|
$sql .= ' CASCADE'; |
| 4063 |
|
} |
| 4064 |
|
|
| 4065 |
|
return $this->execute($sql); |
| 4066 |
|
} |
| 4067 |
|
|
| 4068 |
|
/** |
| 4069 |
|
* Returns a list of all views in the database |
|
@@ 4355-4367 (lines=13) @@
|
| 4352 |
|
* @param $cascade True to cascade drop, false to restrict |
| 4353 |
|
* @return \PHPPgAdmin\Database\A 0 success |
| 4354 |
|
*/ |
| 4355 |
|
public function dropView($viewname, $cascade) |
| 4356 |
|
{ |
| 4357 |
|
$f_schema = $this->_schema; |
| 4358 |
|
$this->fieldClean($f_schema); |
| 4359 |
|
$this->fieldClean($viewname); |
| 4360 |
|
|
| 4361 |
|
$sql = "DROP VIEW \"{$f_schema}\".\"{$viewname}\""; |
| 4362 |
|
if ($cascade) { |
| 4363 |
|
$sql .= ' CASCADE'; |
| 4364 |
|
} |
| 4365 |
|
|
| 4366 |
|
return $this->execute($sql); |
| 4367 |
|
} |
| 4368 |
|
|
| 4369 |
|
// Domain functions |
| 4370 |
|
|
|
@@ 4458-4470 (lines=13) @@
|
| 4455 |
|
* @param $cascade True to cascade drop, false to restrict |
| 4456 |
|
* @return \PHPPgAdmin\Database\A 0 success |
| 4457 |
|
*/ |
| 4458 |
|
public function dropIndex($index, $cascade) |
| 4459 |
|
{ |
| 4460 |
|
$f_schema = $this->_schema; |
| 4461 |
|
$this->fieldClean($f_schema); |
| 4462 |
|
$this->fieldClean($index); |
| 4463 |
|
|
| 4464 |
|
$sql = "DROP INDEX \"{$f_schema}\".\"{$index}\""; |
| 4465 |
|
if ($cascade) { |
| 4466 |
|
$sql .= ' CASCADE'; |
| 4467 |
|
} |
| 4468 |
|
|
| 4469 |
|
return $this->execute($sql); |
| 4470 |
|
} |
| 4471 |
|
|
| 4472 |
|
/** |
| 4473 |
|
* Rebuild indexes |
|
@@ 4848-4861 (lines=14) @@
|
| 4845 |
|
* @param $cascade True to cascade drop, false to restrict |
| 4846 |
|
* @return \PHPPgAdmin\Database\A 0 success |
| 4847 |
|
*/ |
| 4848 |
|
public function dropConstraint($constraint, $relation, $type, $cascade) |
| 4849 |
|
{ |
| 4850 |
|
$f_schema = $this->_schema; |
| 4851 |
|
$this->fieldClean($f_schema); |
| 4852 |
|
$this->fieldClean($constraint); |
| 4853 |
|
$this->fieldClean($relation); |
| 4854 |
|
|
| 4855 |
|
$sql = "ALTER TABLE \"{$f_schema}\".\"{$relation}\" DROP CONSTRAINT \"{$constraint}\""; |
| 4856 |
|
if ($cascade) { |
| 4857 |
|
$sql .= ' CASCADE'; |
| 4858 |
|
} |
| 4859 |
|
|
| 4860 |
|
return $this->execute($sql); |
| 4861 |
|
} |
| 4862 |
|
|
| 4863 |
|
/** |
| 4864 |
|
* A function for getting all columns linked by foreign keys given a group of tables |
|
@@ 5225-5237 (lines=13) @@
|
| 5222 |
|
* @param $cascade True to cascade drop, false to restrict |
| 5223 |
|
* @return \PHPPgAdmin\Database\A 0 success |
| 5224 |
|
*/ |
| 5225 |
|
public function dropDomain($domain, $cascade) |
| 5226 |
|
{ |
| 5227 |
|
$f_schema = $this->_schema; |
| 5228 |
|
$this->fieldClean($f_schema); |
| 5229 |
|
$this->fieldClean($domain); |
| 5230 |
|
|
| 5231 |
|
$sql = "DROP DOMAIN \"{$f_schema}\".\"{$domain}\""; |
| 5232 |
|
if ($cascade) { |
| 5233 |
|
$sql .= ' CASCADE'; |
| 5234 |
|
} |
| 5235 |
|
|
| 5236 |
|
return $this->execute($sql); |
| 5237 |
|
} |
| 5238 |
|
|
| 5239 |
|
/** |
| 5240 |
|
* Adds a check constraint to a domain |
|
@@ 5272-5285 (lines=14) @@
|
| 5269 |
|
* @param $cascade True to cascade, false otherwise |
| 5270 |
|
* @return \PHPPgAdmin\Database\A 0 success |
| 5271 |
|
*/ |
| 5272 |
|
public function dropDomainConstraint($domain, $constraint, $cascade) |
| 5273 |
|
{ |
| 5274 |
|
$f_schema = $this->_schema; |
| 5275 |
|
$this->fieldClean($f_schema); |
| 5276 |
|
$this->fieldClean($domain); |
| 5277 |
|
$this->fieldClean($constraint); |
| 5278 |
|
|
| 5279 |
|
$sql = "ALTER DOMAIN \"{$f_schema}\".\"{$domain}\" DROP CONSTRAINT \"{$constraint}\""; |
| 5280 |
|
if ($cascade) { |
| 5281 |
|
$sql .= ' CASCADE'; |
| 5282 |
|
} |
| 5283 |
|
|
| 5284 |
|
return $this->execute($sql); |
| 5285 |
|
} |
| 5286 |
|
|
| 5287 |
|
// Rule functions |
| 5288 |
|
|
|
@@ 5751-5763 (lines=13) @@
|
| 5748 |
|
* @param $cascade True to cascade drop, false to restrict |
| 5749 |
|
* @return \PHPPgAdmin\Database\A 0 success |
| 5750 |
|
*/ |
| 5751 |
|
public function dropType($typname, $cascade) |
| 5752 |
|
{ |
| 5753 |
|
$f_schema = $this->_schema; |
| 5754 |
|
$this->fieldClean($f_schema); |
| 5755 |
|
$this->fieldClean($typname); |
| 5756 |
|
|
| 5757 |
|
$sql = "DROP TYPE \"{$f_schema}\".\"{$typname}\""; |
| 5758 |
|
if ($cascade) { |
| 5759 |
|
$sql .= ' CASCADE'; |
| 5760 |
|
} |
| 5761 |
|
|
| 5762 |
|
return $this->execute($sql); |
| 5763 |
|
} |
| 5764 |
|
|
| 5765 |
|
/** |
| 5766 |
|
* Creates a new enum type in the database |
|
@@ 6106-6119 (lines=14) @@
|
| 6103 |
|
* @param $cascade True to cascade drop, false to restrict |
| 6104 |
|
* @return \PHPPgAdmin\Database\A 0 success |
| 6105 |
|
*/ |
| 6106 |
|
public function dropRule($rule, $relation, $cascade) |
| 6107 |
|
{ |
| 6108 |
|
$f_schema = $this->_schema; |
| 6109 |
|
$this->fieldClean($f_schema); |
| 6110 |
|
$this->fieldClean($rule); |
| 6111 |
|
$this->fieldClean($relation); |
| 6112 |
|
|
| 6113 |
|
$sql = "DROP RULE \"{$rule}\" ON \"{$f_schema}\".\"{$relation}\""; |
| 6114 |
|
if ($cascade) { |
| 6115 |
|
$sql .= ' CASCADE'; |
| 6116 |
|
} |
| 6117 |
|
|
| 6118 |
|
return $this->execute($sql); |
| 6119 |
|
} |
| 6120 |
|
|
| 6121 |
|
/** |
| 6122 |
|
* Grabs a single trigger |
|
@@ 6383-6396 (lines=14) @@
|
| 6380 |
|
* @param $cascade True to cascade drop, false to restrict |
| 6381 |
|
* @return \PHPPgAdmin\Database\A 0 success |
| 6382 |
|
*/ |
| 6383 |
|
public function dropTrigger($tgname, $table, $cascade) |
| 6384 |
|
{ |
| 6385 |
|
$f_schema = $this->_schema; |
| 6386 |
|
$this->fieldClean($f_schema); |
| 6387 |
|
$this->fieldClean($tgname); |
| 6388 |
|
$this->fieldClean($table); |
| 6389 |
|
|
| 6390 |
|
$sql = "DROP TRIGGER \"{$tgname}\" ON \"{$f_schema}\".\"{$table}\""; |
| 6391 |
|
if ($cascade) { |
| 6392 |
|
$sql .= ' CASCADE'; |
| 6393 |
|
} |
| 6394 |
|
|
| 6395 |
|
return $this->execute($sql); |
| 6396 |
|
} |
| 6397 |
|
|
| 6398 |
|
/** |
| 6399 |
|
* Enables a trigger |
|
@@ 6405-6415 (lines=11) @@
|
| 6402 |
|
* @param $table The table in which to enable the trigger |
| 6403 |
|
* @return \PHPPgAdmin\Database\A 0 success |
| 6404 |
|
*/ |
| 6405 |
|
public function enableTrigger($tgname, $table) |
| 6406 |
|
{ |
| 6407 |
|
$f_schema = $this->_schema; |
| 6408 |
|
$this->fieldClean($f_schema); |
| 6409 |
|
$this->fieldClean($tgname); |
| 6410 |
|
$this->fieldClean($table); |
| 6411 |
|
|
| 6412 |
|
$sql = "ALTER TABLE \"{$f_schema}\".\"{$table}\" ENABLE TRIGGER \"{$tgname}\""; |
| 6413 |
|
|
| 6414 |
|
return $this->execute($sql); |
| 6415 |
|
} |
| 6416 |
|
|
| 6417 |
|
/** |
| 6418 |
|
* Disables a trigger |
|
@@ 6424-6434 (lines=11) @@
|
| 6421 |
|
* @param $table The table in which to disable the trigger |
| 6422 |
|
* @return \PHPPgAdmin\Database\A 0 success |
| 6423 |
|
*/ |
| 6424 |
|
public function disableTrigger($tgname, $table) |
| 6425 |
|
{ |
| 6426 |
|
$f_schema = $this->_schema; |
| 6427 |
|
$this->fieldClean($f_schema); |
| 6428 |
|
$this->fieldClean($tgname); |
| 6429 |
|
$this->fieldClean($table); |
| 6430 |
|
|
| 6431 |
|
$sql = "ALTER TABLE \"{$f_schema}\".\"{$table}\" DISABLE TRIGGER \"{$tgname}\""; |
| 6432 |
|
|
| 6433 |
|
return $this->execute($sql); |
| 6434 |
|
} |
| 6435 |
|
|
| 6436 |
|
/** |
| 6437 |
|
* Returns a list of all operators in the database |
|
@@ 6785-6797 (lines=13) @@
|
| 6782 |
|
* @param $cascade Cascade to dependenced objects |
| 6783 |
|
* @return \PHPPgAdmin\Database\A 0 on success |
| 6784 |
|
*/ |
| 6785 |
|
public function dropFtsConfiguration($ftscfg, $cascade) |
| 6786 |
|
{ |
| 6787 |
|
$f_schema = $this->_schema; |
| 6788 |
|
$this->fieldClean($f_schema); |
| 6789 |
|
$this->fieldClean($ftscfg); |
| 6790 |
|
|
| 6791 |
|
$sql = "DROP TEXT SEARCH CONFIGURATION \"{$f_schema}\".\"{$ftscfg}\""; |
| 6792 |
|
if ($cascade) { |
| 6793 |
|
$sql .= ' CASCADE'; |
| 6794 |
|
} |
| 6795 |
|
|
| 6796 |
|
return $this->execute($sql); |
| 6797 |
|
} |
| 6798 |
|
|
| 6799 |
|
/** |
| 6800 |
|
* Drops FTS dictionary |
|
@@ 6807-6820 (lines=14) @@
|
| 6804 |
|
* @return \PHPPgAdmin\Database\A 0 on success |
| 6805 |
|
* @todo Support of dictionary templates dropping |
| 6806 |
|
*/ |
| 6807 |
|
public function dropFtsDictionary($ftsdict, $cascade) |
| 6808 |
|
{ |
| 6809 |
|
$f_schema = $this->_schema; |
| 6810 |
|
$this->fieldClean($f_schema); |
| 6811 |
|
$this->fieldClean($ftsdict); |
| 6812 |
|
|
| 6813 |
|
$sql = 'DROP TEXT SEARCH DICTIONARY'; |
| 6814 |
|
$sql .= " \"{$f_schema}\".\"{$ftsdict}\""; |
| 6815 |
|
if ($cascade) { |
| 6816 |
|
$sql .= ' CASCADE'; |
| 6817 |
|
} |
| 6818 |
|
|
| 6819 |
|
return $this->execute($sql); |
| 6820 |
|
} |
| 6821 |
|
|
| 6822 |
|
/** |
| 6823 |
|
* Alters FTS configuration |
|
@@ 7260-7273 (lines=14) @@
|
| 7257 |
|
* @param $cascade True to cascade drop, false to restrict |
| 7258 |
|
* @return \PHPPgAdmin\Database\A 0 success |
| 7259 |
|
*/ |
| 7260 |
|
public function dropAggregate($aggrname, $aggrtype, $cascade) |
| 7261 |
|
{ |
| 7262 |
|
$f_schema = $this->_schema; |
| 7263 |
|
$this->fieldClean($f_schema); |
| 7264 |
|
$this->fieldClean($aggrname); |
| 7265 |
|
$this->fieldClean($aggrtype); |
| 7266 |
|
|
| 7267 |
|
$sql = "DROP AGGREGATE \"{$f_schema}\".\"{$aggrname}\" (\"{$aggrtype}\")"; |
| 7268 |
|
if ($cascade) { |
| 7269 |
|
$sql .= ' CASCADE'; |
| 7270 |
|
} |
| 7271 |
|
|
| 7272 |
|
return $this->execute($sql); |
| 7273 |
|
} |
| 7274 |
|
|
| 7275 |
|
/** |
| 7276 |
|
* Gets all information for an aggregate |
|
@@ 7413-7422 (lines=10) @@
|
| 7410 |
|
* @param $newaggrowner The new owner of the aggregate |
| 7411 |
|
* @return \PHPPgAdmin\Database\A 0 success |
| 7412 |
|
*/ |
| 7413 |
|
public function changeAggregateOwner($aggrname, $aggrtype, $newaggrowner) |
| 7414 |
|
{ |
| 7415 |
|
$f_schema = $this->_schema; |
| 7416 |
|
$this->fieldClean($f_schema); |
| 7417 |
|
$this->fieldClean($aggrname); |
| 7418 |
|
$this->fieldClean($newaggrowner); |
| 7419 |
|
$sql = "ALTER AGGREGATE \"{$f_schema}\".\"{$aggrname}\" (\"{$aggrtype}\") OWNER TO \"{$newaggrowner}\""; |
| 7420 |
|
|
| 7421 |
|
return $this->execute($sql); |
| 7422 |
|
} |
| 7423 |
|
|
| 7424 |
|
/** |
| 7425 |
|
* Changes the schema of an aggregate function |
|
@@ 7432-7441 (lines=10) @@
|
| 7429 |
|
* @param $newaggrschema The new schema for the aggregate |
| 7430 |
|
* @return \PHPPgAdmin\Database\A 0 success |
| 7431 |
|
*/ |
| 7432 |
|
public function changeAggregateSchema($aggrname, $aggrtype, $newaggrschema) |
| 7433 |
|
{ |
| 7434 |
|
$f_schema = $this->_schema; |
| 7435 |
|
$this->fieldClean($f_schema); |
| 7436 |
|
$this->fieldClean($aggrname); |
| 7437 |
|
$this->fieldClean($newaggrschema); |
| 7438 |
|
$sql = "ALTER AGGREGATE \"{$f_schema}\".\"{$aggrname}\" (\"{$aggrtype}\") SET SCHEMA \"{$newaggrschema}\""; |
| 7439 |
|
|
| 7440 |
|
return $this->execute($sql); |
| 7441 |
|
} |
| 7442 |
|
|
| 7443 |
|
/** |
| 7444 |
|
* Renames an aggregate function |
|
@@ 8503-8516 (lines=14) @@
|
| 8500 |
|
* @param $table (optional) The table to analyze |
| 8501 |
|
* @return \PHPPgAdmin\Database\A |
| 8502 |
|
*/ |
| 8503 |
|
public function analyzeDB($table = '') |
| 8504 |
|
{ |
| 8505 |
|
if ($table != '') { |
| 8506 |
|
$f_schema = $this->_schema; |
| 8507 |
|
$this->fieldClean($f_schema); |
| 8508 |
|
$this->fieldClean($table); |
| 8509 |
|
|
| 8510 |
|
$sql = "ANALYZE \"{$f_schema}\".\"{$table}\""; |
| 8511 |
|
} else { |
| 8512 |
|
$sql = 'ANALYZE'; |
| 8513 |
|
} |
| 8514 |
|
|
| 8515 |
|
return $this->execute($sql); |
| 8516 |
|
} |
| 8517 |
|
|
| 8518 |
|
/** |
| 8519 |
|
* Vacuums a database |