mirror of
https://github.com/vrana/adminer.git
synced 2026-03-03 02:51:22 +01:00
Allow creating generated columns (bug #857)
This commit is contained in:
@@ -229,6 +229,9 @@ if (isset($_GET["pgsql"])) {
|
||||
"char|text" => "||",
|
||||
)
|
||||
);
|
||||
if (min_version(12, 0, $connection)) {
|
||||
$this->generated = array("STORED");
|
||||
}
|
||||
}
|
||||
|
||||
function setUserTypes($types) {
|
||||
@@ -441,7 +444,7 @@ ORDER BY a.attnum") as $row
|
||||
if (in_array($row['attidentity'], array('a', 'd'))) {
|
||||
$row['default'] = 'GENERATED ' . ($row['attidentity'] == 'd' ? 'BY DEFAULT' : 'ALWAYS') . ' AS IDENTITY';
|
||||
}
|
||||
$row["generated"] = ($row["attgenerated"] == "s");
|
||||
$row["generated"] = ($row["attgenerated"] == "s" ? "STORED" : "");
|
||||
$row["null"] = !$row["attnotnull"];
|
||||
$row["auto_increment"] = $row['attidentity'] || preg_match('~^nextval\(~i', $row["default"]);
|
||||
$row["privileges"] = array("insert" => 1, "select" => 1, "update" => 1);
|
||||
@@ -576,9 +579,9 @@ ORDER BY conkey, conname") as $row
|
||||
}
|
||||
$alter[] = "ALTER $column TYPE$val[1]";
|
||||
$sequence_name = $table . "_" . idf_unescape($val[0]) . "_seq";
|
||||
$alter[] = "ALTER $column " . ($val[3] ? "SET$val[3]"
|
||||
$alter[] = "ALTER $column " . ($val[3] ? "SET" . preg_replace('~GENERATED ALWAYS(.*) STORED~', 'EXPRESSION\1', $val[3])
|
||||
: (isset($val[6]) ? "SET DEFAULT nextval(" . q($sequence_name) . ")"
|
||||
: "DROP DEFAULT"
|
||||
: "DROP DEFAULT" //! change to DROP EXPRESSION with generated columns
|
||||
));
|
||||
if (isset($val[6])) {
|
||||
$sequence = "CREATE SEQUENCE IF NOT EXISTS " . idf_escape($sequence_name) . " OWNED BY " . idf_escape($table) . ".$val[0]";
|
||||
|
||||
Reference in New Issue
Block a user