PostgreSQL: Allow creating trigger functions

This commit is contained in:
Jakub Vrana 2018-01-30 15:55:50 +01:00
parent 9f69160797
commit 1f21cd4329
2 changed files with 6 additions and 5 deletions

View file

@ -135,20 +135,21 @@ function textarea($name, $value, $rows = 10, $cols = 80) {
* @param array * @param array
* @param array * @param array
* @param array returned by referencable_primary() * @param array returned by referencable_primary()
* @param array extra types to prepend
* @return null * @return null
*/ */
function edit_type($key, $field, $collations, $foreign_keys = array()) { function edit_type($key, $field, $collations, $foreign_keys = array(), $extra_types = array()) {
global $structured_types, $types, $unsigned, $on_actions; global $structured_types, $types, $unsigned, $on_actions;
$type = $field["type"]; $type = $field["type"];
?> ?>
<td><select name="<?php echo h($key); ?>[type]" class="type" aria-labelledby="label-type"><?php <td><select name="<?php echo h($key); ?>[type]" class="type" aria-labelledby="label-type"><?php
if ($type && !isset($types[$type]) && !isset($foreign_keys[$type])) { if ($type && !isset($types[$type], $foreign_keys[$type]) && !in_array($type, $extra_types)) {
array_unshift($structured_types, $type); $extra_types[] = $type;
} }
if ($foreign_keys) { if ($foreign_keys) {
$structured_types[lang('Foreign keys')] = $foreign_keys; $structured_types[lang('Foreign keys')] = $foreign_keys;
} }
echo optionlist($structured_types, $type); echo optionlist(array_merge($extra_types, $structured_types), $type);
?></select> ?></select>
<?php echo on_help("getTarget(event).value", 1); ?> <?php echo on_help("getTarget(event).value", 1); ?>
<?php echo script("mixin(qsl('select'), {onfocus: function () { lastType = selectValue(this); }, onchange: editingTypeChange});", ""); ?> <?php echo script("mixin(qsl('select'), {onfocus: function () { lastType = selectValue(this); }, onchange: editingTypeChange});", ""); ?>

View file

@ -43,7 +43,7 @@ $routine_languages = routine_languages();
edit_fields($row["fields"], $collations, $routine); edit_fields($row["fields"], $collations, $routine);
if (isset($_GET["function"])) { if (isset($_GET["function"])) {
echo "<tr><td>" . lang('Return type'); echo "<tr><td>" . lang('Return type');
edit_type("returns", $row["returns"], $collations); edit_type("returns", $row["returns"], $collations, array(), ($jush == "pgsql" ? array("void", "trigger") : array()));
} }
?> ?>
</table> </table>