Collation order field
authorJamie Cameron <jcameron@webmin.com>
Fri, 8 Jan 2010 22:04:46 +0000 (14:04 -0800)
committerJamie Cameron <jcameron@webmin.com>
Fri, 8 Jan 2010 22:04:46 +0000 (14:04 -0800)
mysql/CHANGELOG
mysql/lang/en
mysql/mysql-lib.pl
mysql/newdb.cgi
mysql/newdb_form.cgi

index 693f397..ed24ecc 100644 (file)
@@ -88,3 +88,5 @@ MySQL stored procedures are now included in backups, where supported.
 Restores and imports from local files are now run as the Unix user configured for backups, rather than root.
 ---- Changes since 1.490 ----
 The information_schema database is no longer included when backing up all databases, as it really just contains metadata.
+---- Changes since 1.500 ----
+Added a collation order field to the database creation form.
index 87ba070..605cc8a 100644 (file)
@@ -428,6 +428,7 @@ newdb_table=Initial table
 newdb_none=None
 newdb_tname=Named
 newdb_charset=Character set
+newdb_collation=Collation order
 newdb_str=with fields below
 newdb_err=Failed to create database
 newdb_edb=Missing or invalid database name
index b441fe2..f622636 100755 (executable)
@@ -1234,6 +1234,20 @@ else {
 return sort { lc($a) cmp lc($b) } @rv;
 }
 
+# list_collation_orders([db])
+# Returns a list of supported collation orders. Each row is an array ref of
+# a code and character set it can work with.
+sub list_collation_orders
+{
+local @rv;
+local $db = $_[0] || $master_db;
+if ($mysql_version >= 5) {
+       local $d = &execute_sql($db, "show collation");
+       @rv = map { [ $_->[0], $_->[1] ] } @{$d->{'data'}};
+       }
+return sort { lc($a) cmp lc($b) } @rv;
+}
+
 # list_system_variables()
 # Returns a list of all system variables, and their default values
 sub list_system_variables
index 8f1fb32..249a0e0 100755 (executable)
@@ -19,7 +19,8 @@ if (!$in{'table_def'}) {
        @sql = &parse_table_form([ ], $in{'table'});
        }
 &execute_sql_logged($master_db, "create database ".&quotestr($in{'db'}).
-                   ($in{'charset'} ? " character set $in{'charset'}" : ""));
+                   ($in{'charset'} ? " character set $in{'charset'}" : "").
+                   ($in{'collation'} ? " collate $in{'collation'}" : ""));
 &webmin_log("create", "db", $in{'db'});
 if (@sql) {
        foreach $sql (@sql) {
index da0b0c9..e7b39e3 100755 (executable)
@@ -15,10 +15,22 @@ print &ui_table_row($text{'newdb_db'},
 
 if ($mysql_version >= 4.1) {
        # Character set option
+       @charsets = &list_character_sets();
+       %csmap = map { $_->[0], $_->[1] } @charsets;
        print &ui_table_row($text{'newdb_charset'},
                     &ui_select("charset", undef,
                                [ [ undef, "&lt;$text{'default'}&gt;" ],
-                                 &list_character_sets() ]));
+                                 @charsets ]));
+       }
+
+@coll = &list_collation_orders();
+if (@coll) {
+       # Collation order option
+       print &ui_table_row($text{'newdb_collation'},
+                    &ui_select("collation", undef,
+                       [ [ undef, "&lt;$text{'default'}&gt;" ],
+                         map { [ $_->[0], $_->[0]." (".$csmap{$_->[1]}.")" ] }
+                             &list_collation_orders() ]));
        }
 
 # Initial table name