mirror of
https://github.com/vrana/adminer.git
synced 2025-08-26 15:54:34 +02:00
PostgreSQL: Export DROP SEQUENCE if dropping table
This commit is contained in:
@@ -915,9 +915,10 @@ if (!defined("DRIVER")) {
|
||||
/** Get SQL command to create table
|
||||
* @param string
|
||||
* @param bool
|
||||
* @param string
|
||||
* @return string
|
||||
*/
|
||||
function create_sql($table, $auto_increment) {
|
||||
function create_sql($table, $auto_increment, $style) {
|
||||
global $connection;
|
||||
$return = $connection->result("SHOW CREATE TABLE " . table($table), 1);
|
||||
if (!$auto_increment) {
|
||||
|
@@ -617,7 +617,7 @@ AND typelem = 0"
|
||||
return $return;
|
||||
}
|
||||
|
||||
function create_sql($table, $auto_increment) {
|
||||
function create_sql($table, $auto_increment, $style) {
|
||||
global $connection;
|
||||
$return = '';
|
||||
$return_parts = array();
|
||||
@@ -647,7 +647,8 @@ AND typelem = 0"
|
||||
if (preg_match('~nextval\(\'([^\']+)\'\)~', $field['default'], $matches)) {
|
||||
$sequence_name = $matches[1];
|
||||
$sq = reset(get_rows("SELECT * FROM $sequence_name"));
|
||||
$sequences[] = "CREATE SEQUENCE $sequence_name INCREMENT $sq[increment_by] MINVALUE $sq[min_value] MAXVALUE $sq[max_value] START " . ($auto_increment ? $sq['last_value'] : 1) . " CACHE $sq[cache_value];";
|
||||
$sequences[] = ($style == "DROP+CREATE" ? "DROP SEQUENCE $sequence_name;\n" : "")
|
||||
. "CREATE SEQUENCE $sequence_name INCREMENT $sq[increment_by] MINVALUE $sq[min_value] MAXVALUE $sq[max_value] START " . ($auto_increment ? $sq['last_value'] : 1) . " CACHE $sq[cache_value];";
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -715,7 +715,7 @@ if (isset($_GET["sqlite"]) || isset($_GET["sqlite2"])) {
|
||||
return true;
|
||||
}
|
||||
|
||||
function create_sql($table, $auto_increment) {
|
||||
function create_sql($table, $auto_increment, $style) {
|
||||
global $connection;
|
||||
$return = $connection->result("SELECT sql FROM sqlite_master WHERE type IN ('table', 'view') AND name = " . q($table));
|
||||
foreach (indexes($table) as $name => $index) {
|
||||
|
Reference in New Issue
Block a user