diff src/pathcheck.sml @ 707:d8217b4cb617

PRIMARY KEY
author Adam Chlipala <adamc@hcoop.net>
date Tue, 07 Apr 2009 16:14:31 -0400
parents 70cbdcf5989b
children 4c5796512edc
line wrap: on
line diff
--- a/src/pathcheck.sml	Tue Apr 07 15:04:07 2009 -0400
+++ b/src/pathcheck.sml	Tue Apr 07 16:14:31 2009 -0400
@@ -55,7 +55,7 @@
         case d of
             DExport (_, s, _, _, _) => doFunc s
             
-          | DTable (s, _, e) =>
+          | DTable (s, _, pe, ce) =>
             let
                 fun constraints (e, rels) =
                     case #1 e of
@@ -71,8 +71,22 @@
                         end
                       | EStrcat (e1, e2) => constraints (e2, constraints (e1, rels))
                       | _ => rels
+
+                val rels = #2 (doRel s)
+                val rels = case #1 pe of
+                               EPrim (Prim.String "") => rels
+                             | _ =>
+                               let
+                                   val s' = s ^ "_Pkey"
+                               in
+                                   if SS.member (rels, s') then
+                                       E.errorAt loc ("Duplicate primary key constraint path " ^ s')
+                                   else
+                                       ();
+                                   SS.add (rels, s')
+                               end
             in
-                (funcs, constraints (e, #2 (doRel s)))
+                (funcs, constraints (ce, rels))
             end
           | DSequence s => doRel s