| @@ 390-405 (lines=16) @@ | ||
| 387 | * |
|
| 388 | * @internal string $name new owner for the sequence |
|
| 389 | */ |
|
| 390 | public function alterSequenceOwner($seqrs, $owner) |
|
| 391 | { |
|
| 392 | // If owner has been changed, then do the alteration. We are |
|
| 393 | // careful to avoid this generally as changing owner is a |
|
| 394 | // superuser only function. |
|
| 395 | /* vars are cleaned in _alterSequence */ |
|
| 396 | if (!empty($owner) && ($seqrs->fields['seqowner'] != $owner)) { |
|
| 397 | $f_schema = $this->_schema; |
|
| 398 | $this->fieldClean($f_schema); |
|
| 399 | $sql = "ALTER SEQUENCE \"{$f_schema}\".\"{$seqrs->fields['seqname']}\" OWNER TO \"{$owner}\""; |
|
| 400 | ||
| 401 | return $this->execute($sql); |
|
| 402 | } |
|
| 403 | ||
| 404 | return 0; |
|
| 405 | } |
|
| 406 | ||
| 407 | /** |
|
| 408 | * Alter a sequence's properties. |
|
| @@ 509-521 (lines=13) @@ | ||
| 506 | * |
|
| 507 | * @internal param The $name new schema for the sequence |
|
| 508 | */ |
|
| 509 | public function alterSequenceSchema($seqrs, $schema) |
|
| 510 | { |
|
| 511 | /* vars are cleaned in _alterSequence */ |
|
| 512 | if (!empty($schema) && ($seqrs->fields['nspname'] != $schema)) { |
|
| 513 | $f_schema = $this->_schema; |
|
| 514 | $this->fieldClean($f_schema); |
|
| 515 | $sql = "ALTER SEQUENCE \"{$f_schema}\".\"{$seqrs->fields['seqname']}\" SET SCHEMA {$schema}"; |
|
| 516 | ||
| 517 | return $this->execute($sql); |
|
| 518 | } |
|
| 519 | ||
| 520 | return 0; |
|
| 521 | } |
|
| 522 | ||
| 523 | /** |
|
| 524 | * Drops a given sequence. |
|
| @@ 1133-1148 (lines=16) @@ | ||
| 1130 | * |
|
| 1131 | * @return int 0 if operation was successful |
|
| 1132 | */ |
|
| 1133 | public function alterTableOwner($tblrs, $owner = null) |
|
| 1134 | { |
|
| 1135 | /* vars cleaned in _alterTable */ |
|
| 1136 | if (!empty($owner) && ($tblrs->fields['relowner'] != $owner)) { |
|
| 1137 | $f_schema = $this->_schema; |
|
| 1138 | $this->fieldClean($f_schema); |
|
| 1139 | // If owner has been changed, then do the alteration. We are |
|
| 1140 | // careful to avoid this generally as changing owner is a |
|
| 1141 | // superuser only function. |
|
| 1142 | $sql = "ALTER TABLE \"{$f_schema}\".\"{$tblrs->fields['relname']}\" OWNER TO \"{$owner}\""; |
|
| 1143 | ||
| 1144 | return $this->execute($sql); |
|
| 1145 | } |
|
| 1146 | ||
| 1147 | return 0; |
|
| 1148 | } |
|
| 1149 | ||
| 1150 | /** |
|
| 1151 | * Alter a table's tablespace |
|
| @@ 1159-1174 (lines=16) @@ | ||
| 1156 | * |
|
| 1157 | * @return int 0 if operation was successful |
|
| 1158 | */ |
|
| 1159 | public function alterTableTablespace($tblrs, $tablespace = null) |
|
| 1160 | { |
|
| 1161 | /* vars cleaned in _alterTable */ |
|
| 1162 | if (!empty($tablespace) && ($tblrs->fields['tablespace'] != $tablespace)) { |
|
| 1163 | $f_schema = $this->_schema; |
|
| 1164 | $this->fieldClean($f_schema); |
|
| 1165 | ||
| 1166 | // If tablespace has been changed, then do the alteration. We |
|
| 1167 | // don't want to do this unnecessarily. |
|
| 1168 | $sql = "ALTER TABLE \"{$f_schema}\".\"{$tblrs->fields['relname']}\" SET TABLESPACE \"{$tablespace}\""; |
|
| 1169 | ||
| 1170 | return $this->execute($sql); |
|
| 1171 | } |
|
| 1172 | ||
| 1173 | return 0; |
|
| 1174 | } |
|
| 1175 | ||
| 1176 | /** |
|
| 1177 | * Alter a table's name |
|
| @@ 1216-1230 (lines=15) @@ | ||
| 1213 | * |
|
| 1214 | * @return int 0 if operation was successful |
|
| 1215 | */ |
|
| 1216 | public function alterTableSchema($tblrs, $schema = null) |
|
| 1217 | { |
|
| 1218 | /* vars cleaned in _alterTable */ |
|
| 1219 | if (!empty($schema) && ($tblrs->fields['nspname'] != $schema)) { |
|
| 1220 | $f_schema = $this->_schema; |
|
| 1221 | $this->fieldClean($f_schema); |
|
| 1222 | // If tablespace has been changed, then do the alteration. We |
|
| 1223 | // don't want to do this unnecessarily. |
|
| 1224 | $sql = "ALTER TABLE \"{$f_schema}\".\"{$tblrs->fields['relname']}\" SET SCHEMA \"{$schema}\""; |
|
| 1225 | ||
| 1226 | return $this->execute($sql); |
|
| 1227 | } |
|
| 1228 | ||
| 1229 | return 0; |
|
| 1230 | } |
|
| 1231 | ||
| 1232 | /** |
|
| 1233 | * Empties a table in the database. |
|
| @@ 358-373 (lines=16) @@ | ||
| 355 | * |
|
| 356 | * @internal param string The $name new owner for the sequence |
|
| 357 | */ |
|
| 358 | public function alterSequenceOwner($seqrs, $owner) |
|
| 359 | { |
|
| 360 | // If owner has been changed, then do the alteration. We are |
|
| 361 | // careful to avoid this generally as changing owner is a |
|
| 362 | // superuser only function. |
|
| 363 | /* vars are cleaned in _alterSequence */ |
|
| 364 | if (!empty($owner) && ($seqrs->fields['seqowner'] != $owner)) { |
|
| 365 | $f_schema = $this->_schema; |
|
| 366 | $this->fieldClean($f_schema); |
|
| 367 | $sql = "ALTER TABLE \"{$f_schema}\".\"{$seqrs->fields['seqname']}\" OWNER TO \"{$owner}\""; |
|
| 368 | ||
| 369 | return $this->execute($sql); |
|
| 370 | } |
|
| 371 | ||
| 372 | return 0; |
|
| 373 | } |
|
| 374 | ||
| 375 | // Function functions |
|
| 376 | ||