Handle hostnames with upper-case letters
[webmin.git] / postgresql / edit_index.cgi
1 #!/usr/local/bin/perl
2 # Show a form for creating or editing index on a table
3
4 require './postgresql-lib.pl';
5 &ReadParse();
6 &can_edit_db($in{'db'}) || &error($text{'dbase_ecannot'});
7 $access{'edonly'} && &error($text{'dbase_ecannot'});
8 $access{'indexes'} || &error($text{'index_ecannot'});
9
10 if ($in{'index'}) {
11         # Editing an index
12         $str = &index_structure($in{'db'}, $in{'index'});
13         $table = $str->{'table'};
14         }
15 else {
16         # Creating an index
17         $table = $in{'table'};
18         }
19 $desc = &text('table_header', "<tt>$table</tt>", "<tt>$in{'db'}</tt>");
20 &ui_print_header($desc, $in{'index'} ? $text{'index_title2'}
21                                      : $text{'index_title1'}, "");
22
23 print &ui_form_start("save_index.cgi", "post");
24 print &ui_hidden("db", $in{'db'}),"\n";
25 print &ui_hidden("table", $table),"\n";
26 print &ui_hidden("old", $in{'index'}),"\n";
27 print &ui_table_start($text{'index_header1'}, undef, 2);
28
29 # Index name
30 print &ui_table_row($text{'index_name'},
31                     &ui_textbox("name", $str->{'name'}, 20));
32
33 # Fields in index
34 @str = &table_structure($in{'db'}, $table);
35 @cols = map { $_->{'field'} } @str;
36 print &ui_table_row($text{'index_fields'},
37                    &ui_select("cols", $str->{'cols'},
38                       [ map { [ $_->{'field'}, "$_->{'field'} - $_->{'type'}" ] } @str ], 5, 1));
39
40 # Index type
41 print &ui_table_row($text{'index_type'},
42                     &ui_select("type", $str->{'type'},
43                         [ [ "unique", $text{'index_unique'} ],
44                           [ "", $text{'index_nonunique'} ] ]));
45
46 # Access method
47 print &ui_table_row($text{'index_using'},
48                     &ui_select("using", $str->{'using'} || "btree",
49                         [ [ "btree", $text{'index_btree'} ],
50                           [ "rtree", $text{'index_rtree'} ],
51                           [ "hash", $text{'index_hash'} ],
52                           [ "gist", $text{'index_gist'} ] ],
53                         undef, undef, 1));
54
55 print &ui_table_end();
56 if ($in{'index'}) {
57         print &ui_form_end([ [ "save", $text{'save'} ],
58                              [ "delete", $text{'delete'} ] ]);
59         }
60 else {
61         print &ui_form_end([ [ "create", $text{'create'} ] ]);
62         }
63
64 &ui_print_footer("edit_dbase.cgi?db=$in{'db'}", $text{'dbase_return'},
65         "", $text{'index_return'});