From 2ed8d19a49ec13ad940c4103af27d84c3c6e513e Mon Sep 17 00:00:00 2001 From: ioguix Date: Sun, 9 Sep 2007 20:20:31 +0000 Subject: [PATCH] Add "INCLUDING INDEXES" to CREATE TABLE (like ...) for PostgreSQL 8.3 --- classes/database/Postgres.php | 3 ++- classes/database/Postgres74.php | 5 +++-- classes/database/Postgres83.php | 4 +++- lang/english.php | 3 ++- tables.php | 10 ++++++++-- 5 files changed, 18 insertions(+), 7 deletions(-) diff --git a/classes/database/Postgres.php b/classes/database/Postgres.php index ba53efcd..5801134c 100755 --- a/classes/database/Postgres.php +++ b/classes/database/Postgres.php @@ -4,7 +4,7 @@ * A class that implements the DB interface for Postgres * Note: This class uses ADODB and returns RecordSets. * - * $Id: Postgres.php,v 1.300 2007/08/31 19:46:23 ioguix Exp $ + * $Id: Postgres.php,v 1.301 2007/09/09 20:20:31 ioguix Exp $ */ // @@@ THOUGHT: What about inherits? ie. use of ONLY??? @@ -4663,6 +4663,7 @@ class Postgres extends ADODB_base { function hasAnalyze() {return false;} function hasCreateTableLike() {return false;} function hasCreateTableLikeWithConstraints() {return false;} + function hasCreateTableLikeWithIndexes() {return false;} } ?> diff --git a/classes/database/Postgres74.php b/classes/database/Postgres74.php index 9f45952b..c338063d 100644 --- a/classes/database/Postgres74.php +++ b/classes/database/Postgres74.php @@ -4,7 +4,7 @@ * A class that implements the DB interface for Postgres * Note: This class uses ADODB and returns RecordSets. * - * $Id: Postgres74.php,v 1.59 2007/08/31 19:46:24 ioguix Exp $ + * $Id: Postgres74.php,v 1.60 2007/09/09 20:20:31 ioguix Exp $ */ include_once('./classes/database/Postgres73.php'); @@ -155,7 +155,7 @@ class Postgres74 extends Postgres73 { * @param $constraints if true, copy the constraints as well (CHECK on table & attr) * @param $tablespace The tablespace name ('' means none/default) */ - function createTableLike($name, $like, $defaults = false, $constraints = false, $tablespace = '') { + function createTableLike($name, $like, $defaults = false, $constraints = false, $idx = false, $tablespace = '') { $this->fieldClean($name); $this->fieldClean($like); @@ -166,6 +166,7 @@ class Postgres74 extends Postgres73 { if ($defaults) $sql .= " INCLUDING DEFAULTS"; if ($this->hasCreateTableLikeWithConstraints() && $constraints) $sql .= " INCLUDING CONSTRAINTS"; + if ($this->hasCreateTableLikeWithIndexes() && $idx) $sql .= " INCLUDING INDEXES"; $sql .= ")"; diff --git a/classes/database/Postgres83.php b/classes/database/Postgres83.php index dc2861af..a704203f 100644 --- a/classes/database/Postgres83.php +++ b/classes/database/Postgres83.php @@ -3,7 +3,7 @@ /** * PostgreSQL 8.3 support * - * $Id: Postgres83.php,v 1.1 2007/06/07 02:20:20 xzilla Exp $ + * $Id: Postgres83.php,v 1.2 2007/09/09 20:20:31 ioguix Exp $ */ include_once('./classes/database/Postgres82.php'); @@ -30,4 +30,6 @@ class Postgres83 extends Postgres82 { return $this->help_page; } + function hasCreateTableLikeWithIndexes() {return true;} +} ?> diff --git a/lang/english.php b/lang/english.php index 5fe8ef87..d51af4a0 100755 --- a/lang/english.php +++ b/lang/english.php @@ -4,7 +4,7 @@ * English language file for phpPgAdmin. Use this as a basis * for new translations. * - * $Id: english.php,v 1.214 2007/08/31 19:46:24 ioguix Exp $ + * $Id: english.php,v 1.215 2007/09/09 20:20:31 ioguix Exp $ */ // Language and character set @@ -183,6 +183,7 @@ $lang['strcreatetablelikeparent'] = 'Source table'; $lang['strcreatelikewithdefaults'] = 'INCLUDE DEFAULTS'; $lang['strcreatelikewithconstraints'] = 'INCLUDE CONSTRAINTS'; + $lang['strcreatelikewithindexes'] = 'INCLUDE INDEXES'; $lang['strtablename'] = 'Table name'; $lang['strtableneedsname'] = 'You must give a name for your table.'; $lang['strtablelikeneedslike'] = 'You must give a table to copy properties from.'; diff --git a/tables.php b/tables.php index bd9479e3..1f9d07de 100644 --- a/tables.php +++ b/tables.php @@ -3,7 +3,7 @@ /** * List tables in a database * - * $Id: tables.php,v 1.102 2007/08/31 19:46:23 ioguix Exp $ + * $Id: tables.php,v 1.103 2007/09/09 20:20:31 ioguix Exp $ */ // Include application functions @@ -294,6 +294,11 @@ isset($_REQUEST['withconstraints']) ? ' checked="checked"' : '', "/>{$lang['strcreatelikewithconstraints']}"; } + if ($data->hasCreateTableLikeWithIndexes()) { + echo ""; + } echo "\n\t\n"; echo ""; @@ -315,7 +320,8 @@ return; } - $status = $data->createTableLike($_REQUEST['name'], $_REQUEST['like'], isset($_REQUEST['withdefaults']), isset($_REQUEST['withconstraints']), $_REQUEST['tablespace']); + $status = $data->createTableLike($_REQUEST['name'], $_REQUEST['like'], isset($_REQUEST['withdefaults']), + isset($_REQUEST['withconstraints']), isset($_REQUEST['withindexes']), $_REQUEST['tablespace']); if ($status == 0) { $_reload_browser = true; doDefault($lang['strtablecreated']); -- 2.39.5