mirror of
https://github.com/vrana/adminer.git
synced 2025-08-09 08:06:59 +02:00
PostgreSQL: Support CHECK constraint
This commit is contained in:
@@ -4,7 +4,7 @@ $name = $_GET["name"];
|
|||||||
$row = $_POST;
|
$row = $_POST;
|
||||||
|
|
||||||
if ($row && !$error) {
|
if ($row && !$error) {
|
||||||
$result = ($name == "" || queries("ALTER TABLE " . table($TABLE) . " DROP CHECK " . idf_escape($name)));
|
$result = ($name == "" || queries("ALTER TABLE " . table($TABLE) . " DROP CONSTRAINT " . idf_escape($name)));
|
||||||
if (!$row["drop"] && $result) {
|
if (!$row["drop"] && $result) {
|
||||||
$result = queries("ALTER TABLE " . table($TABLE) . " ADD" . ($row["name"] != "" ? " CONSTRAINT " . idf_escape($row["name"]) . "" : "") . " CHECK ($row[clause])"); //! SQL injection
|
$result = queries("ALTER TABLE " . table($TABLE) . " ADD" . ($row["name"] != "" ? " CONSTRAINT " . idf_escape($row["name"]) . "" : "") . " CHECK ($row[clause])"); //! SQL injection
|
||||||
}
|
}
|
||||||
|
@@ -864,18 +864,6 @@ if (!defined("DRIVER")) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Get defined check constraints
|
|
||||||
* @param string
|
|
||||||
* @return array array($name => $statement)
|
|
||||||
*/
|
|
||||||
function check_constraints($table) {
|
|
||||||
// MariaDB contains CHECK_CONSTRAINTS.TABLE_NAME, MySQL not
|
|
||||||
return get_key_vals("SELECT c.CONSTRAINT_NAME, c.CHECK_CLAUSE
|
|
||||||
FROM information_schema.CHECK_CONSTRAINTS c
|
|
||||||
JOIN information_schema.TABLE_CONSTRAINTS t ON c.CONSTRAINT_SCHEMA = t.CONSTRAINT_SCHEMA AND c.CONSTRAINT_NAME = t.CONSTRAINT_NAME
|
|
||||||
WHERE c.CONSTRAINT_SCHEMA = " . q(DB) . " AND t.TABLE_NAME = " . q($table));
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Get information about trigger
|
/** Get information about trigger
|
||||||
* @param string trigger name
|
* @param string trigger name
|
||||||
* @return array array("Trigger" => , "Timing" => , "Event" => , "Of" => , "Type" => , "Statement" => )
|
* @return array array("Trigger" => , "Timing" => , "Event" => , "Of" => , "Type" => , "Statement" => )
|
||||||
|
@@ -911,7 +911,7 @@ AND typelem = 0"
|
|||||||
}
|
}
|
||||||
|
|
||||||
function support($feature) {
|
function support($feature) {
|
||||||
return preg_match('~^(database|table|columns|sql|indexes|descidx|comment|view|' . (min_version(9.3) ? 'materializedview|' : '') . 'scheme|routine|processlist|sequence|trigger|type|variables|drop_col|kill|dump)$~', $feature);
|
return preg_match('~^(check|database|table|columns|sql|indexes|descidx|comment|view|' . (min_version(9.3) ? 'materializedview|' : '') . 'scheme|routine|processlist|sequence|trigger|type|variables|drop_col|kill|dump)$~', $feature);
|
||||||
}
|
}
|
||||||
|
|
||||||
function kill_process($val) {
|
function kill_process($val) {
|
||||||
|
@@ -532,6 +532,20 @@ function create_routine($routine, $row) {
|
|||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Get defined check constraints
|
||||||
|
* @param string
|
||||||
|
* @return array array($name => $clause)
|
||||||
|
*/
|
||||||
|
function check_constraints($table) {
|
||||||
|
// MariaDB contains CHECK_CONSTRAINTS.TABLE_NAME, MySQL and PostrgreSQL not
|
||||||
|
return get_key_vals("SELECT c.CONSTRAINT_NAME, CHECK_CLAUSE
|
||||||
|
FROM information_schema.CHECK_CONSTRAINTS c
|
||||||
|
JOIN information_schema.TABLE_CONSTRAINTS t ON c.CONSTRAINT_SCHEMA = t.CONSTRAINT_SCHEMA AND c.CONSTRAINT_NAME = t.CONSTRAINT_NAME
|
||||||
|
WHERE c.CONSTRAINT_SCHEMA = " . q($_GET["ns"] != "" ? $_GET["ns"] : DB) . "
|
||||||
|
AND t.TABLE_NAME = " . q($table) . "
|
||||||
|
AND CHECK_CLAUSE NOT LIKE '% IS NOT NULL'"); // ignore default IS NOT NULL checks in PostrgreSQL
|
||||||
|
}
|
||||||
|
|
||||||
/** Remove current user definer from SQL command
|
/** Remove current user definer from SQL command
|
||||||
* @param string
|
* @param string
|
||||||
* @return string
|
* @return string
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
Adminer 4.17.0-dev:
|
Adminer 4.17.0-dev:
|
||||||
Hide index column options by default
|
Hide index column options by default
|
||||||
MySQL: Support CHECK constraint
|
MySQL, PostgreSQL: Support CHECK constraint
|
||||||
PostgreSQL: Link user defined types
|
PostgreSQL: Link user defined types
|
||||||
PostgreSQL: Constraint enum values in editing (bug #270)
|
PostgreSQL: Constraint enum values in editing (bug #270)
|
||||||
SQLite: Show all supported pragmas in Variables
|
SQLite: Show all supported pragmas in Variables
|
||||||
|
Reference in New Issue
Block a user