mirror of
https://github.com/vrana/adminer.git
synced 2025-08-23 06:32:55 +02:00
Print ALTER command instead of running it in export
git-svn-id: https://adminer.svn.sourceforge.net/svnroot/adminer/trunk@1042 7c3ca157-0c34-0410-bff1-cbf682f78f5c
This commit is contained in:
@@ -19,7 +19,7 @@ function dump_table($table, $style, $is_view = false) {
|
||||
// create procedure which iterates over original columns and adds new and removes old
|
||||
$query = "SELECT COLUMN_NAME, COLUMN_DEFAULT, IS_NULLABLE, COLLATION_NAME, COLUMN_TYPE, EXTRA, COLUMN_COMMENT FROM information_schema.COLUMNS WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = " . $dbh->quote($table) . " ORDER BY ORDINAL_POSITION";
|
||||
dump("DELIMITER ;;
|
||||
CREATE PROCEDURE adminer_alter () BEGIN
|
||||
CREATE PROCEDURE adminer_alter (INOUT alter_command text) BEGIN
|
||||
DECLARE _column_name, _collation_name, _column_type, after varchar(64) DEFAULT '';
|
||||
DECLARE _column_default longtext;
|
||||
DECLARE _is_nullable char(3);
|
||||
@@ -76,14 +76,11 @@ CREATE PROCEDURE adminer_alter () BEGIN
|
||||
UNTIL done END REPEAT;
|
||||
CLOSE columns;
|
||||
IF @alter_table != '' OR add_columns != '' THEN
|
||||
SET @alter_table = CONCAT('ALTER TABLE " . idf_escape($table) . "', SUBSTR(CONCAT(add_columns, @alter_table), 2));
|
||||
PREPARE alter_command FROM @alter_table;
|
||||
EXECUTE alter_command;
|
||||
DROP PREPARE alter_command;
|
||||
SET alter_command = CONCAT(alter_command, 'ALTER TABLE " . idf_escape($table) . "', SUBSTR(CONCAT(add_columns, @alter_table), 2), ';\\n');
|
||||
END IF;
|
||||
END;;
|
||||
DELIMITER ;
|
||||
CALL adminer_alter;
|
||||
CALL adminer_alter(@adminer_alter);
|
||||
DROP PROCEDURE adminer_alter;
|
||||
|
||||
");
|
||||
|
Reference in New Issue
Block a user