mirror of
https://github.com/vrana/adminer.git
synced 2025-08-08 07:36:44 +02:00
PostgreSQL: Use function for exporting constraints
This commit is contained in:
@@ -770,6 +770,7 @@ AND typelem = 0"
|
||||
}
|
||||
|
||||
function create_sql($table, $auto_increment, $style) {
|
||||
global $driver;
|
||||
$return_parts = array();
|
||||
$sequences = array();
|
||||
|
||||
@@ -823,17 +824,7 @@ AND typelem = 0"
|
||||
}
|
||||
}
|
||||
|
||||
$constraints = get_key_vals("SELECT conname, " . (min_version(8) ? "pg_get_constraintdef(pg_constraint.oid)" : "CONCAT('CHECK ', consrc)") . "
|
||||
FROM pg_catalog.pg_constraint
|
||||
INNER JOIN pg_catalog.pg_namespace ON pg_constraint.connamespace = pg_namespace.oid
|
||||
INNER JOIN pg_catalog.pg_class ON pg_constraint.conrelid = pg_class.oid AND pg_constraint.connamespace = pg_class.relnamespace
|
||||
WHERE pg_constraint.contype = 'c'
|
||||
AND conrelid != 0 -- handle only CONSTRAINTs here, not TYPES
|
||||
AND nspname = current_schema()
|
||||
AND relname = " . q($table) . "
|
||||
ORDER BY connamespace, conname"
|
||||
);
|
||||
foreach ($constraints as $conname => $consrc) {
|
||||
foreach ($driver->checkConstraints($table) as $conname => $consrc) {
|
||||
$return_parts[] = "CONSTRAINT " . idf_escape($conname) . " $consrc";
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user