Fix dumb message name; allow numbers and underscores in database names
authorAdam Chlipala <adamc@hcoop.net>
Tue, 13 Nov 2007 23:52:59 +0000 (23:52 +0000)
committerAdam Chlipala <adamc@hcoop.net>
Tue, 13 Nov 2007 23:52:59 +0000 (23:52 +0000)
src/dbms.sml
src/main.sml
src/msg.sml
src/msgTypes.sml

index 0b40b26..8c34f8b 100644 (file)
@@ -22,7 +22,7 @@ structure Dbms :> DBMS = struct
 
 open DataStructures
 
-val validDbname = CharVector.all Char.isAlpha
+val validDbname = CharVector.all (fn ch => Char.isAlphaNum ch orelse ch = #"_")
 
 type handler = {getpass : (unit -> Client.passwd_result) option,
                adduser : {user : string, passwd : string option} -> string option,
index 4539b65..660c892 100644 (file)
@@ -524,7 +524,7 @@ fun requestDbTable p =
     let
        val (user, bio) = requestBio (fn () => ())
     in
-       Msg.send (bio, MsgCreateDbTable p);
+       Msg.send (bio, MsgCreateDb p);
        case Msg.recv bio of
            NONE => print "Server closed connection unexpectedly.\n"
          | SOME m =>
@@ -1285,7 +1285,7 @@ fun service () =
                                                   SOME ("Error adding user: " ^ msg)))
                                      (fn () => ())
 
-                              | MsgCreateDbTable {dbtype, dbname} =>
+                              | MsgCreateDb {dbtype, dbname} =>
                                 doIt (fn () =>
                                          if Dbms.validDbname dbname then
                                              case Dbms.lookup dbtype of
index 64837b9..61fa4bc 100644 (file)
@@ -171,9 +171,9 @@ fun send (bio, m) =
       | MsgCreateDbUser {dbtype, passwd} => (OpenSSL.writeInt (bio, 16);
                                             OpenSSL.writeString (bio, dbtype);
                                             sendOption OpenSSL.writeString (bio, passwd))
-      | MsgCreateDbTable {dbtype, dbname} => (OpenSSL.writeInt (bio, 17);
-                                             OpenSSL.writeString (bio, dbtype);
-                                             OpenSSL.writeString (bio, dbname))
+      | MsgCreateDb {dbtype, dbname} => (OpenSSL.writeInt (bio, 17);
+                                        OpenSSL.writeString (bio, dbtype);
+                                        OpenSSL.writeString (bio, dbname))
       | MsgNewMailbox {domain, user, passwd, mailbox} =>
        (OpenSSL.writeInt (bio, 18);
         OpenSSL.writeString (bio, domain);
@@ -285,7 +285,7 @@ fun recv bio =
                              | _ => NONE)
                   | 17 => (case (OpenSSL.readString bio, OpenSSL.readString bio) of
                                (SOME dbtype, SOME dbname) =>
-                               SOME (MsgCreateDbTable {dbtype = dbtype, dbname = dbname})
+                               SOME (MsgCreateDb {dbtype = dbtype, dbname = dbname})
                              | _ => NONE)
                   | 18 => (case (OpenSSL.readString bio, OpenSSL.readString bio,
                                  OpenSSL.readString bio, OpenSSL.readString bio) of
index 0c367ec..25c3592 100644 (file)
@@ -76,7 +76,7 @@ datatype msg =
        * that user and no one else has rights. *)
        | MsgCreateDbUser of {dbtype : string, passwd : string option}
        (* Request creation of a user for the named DBMS type *)
-       | MsgCreateDbTable of {dbtype : string, dbname : string}
+       | MsgCreateDb of {dbtype : string, dbname : string}
        (* Request creation of a DBMS database *)
        | MsgDropDb of {dbtype : string, dbname : string}
        (* Request dropping of a DBMS database *)