# HG changeset patch # User Adam Chlipala # Date 1296785052 18000 # Node ID 3dab4696d1166440254219093650d1074160bbfe # Parent 146b69c53304a2f95ae182c24a9f91f01fdb4955 Subqueries may always return NULL diff -r 146b69c53304 -r 3dab4696d116 doc/manual.tex --- a/doc/manual.tex Thu Feb 03 11:12:48 2011 -0500 +++ b/doc/manual.tex Thu Feb 03 21:04:12 2011 -0500 @@ -1726,8 +1726,8 @@ Any SQL query that returns single columns may be turned into a subquery expression. $$\begin{array}{l} -\mt{val} \; \mt{sql\_subquery} : \mt{tables} ::: \{\{\mt{Type}\}\} \to \mt{agg} ::: \{\{\mt{Type}\}\} \to \mt{exps} ::: \{\mt{Type}\} \to \mt{nm} ::: \mt{Name} \to \mt{t} ::: \mt{Type} \\ -\hspace{.1in} \to \mt{sql\_query} \; \mt{tables} \; \mt{agg} \; [\mt{nm} = \mt{t}] \to \mt{sql\_exp} \; \mt{tables} \; \mt{agg} \; \mt{exps} \; \mt{t} +\mt{val} \; \mt{sql\_subquery} : \mt{tables} ::: \{\{\mt{Type}\}\} \to \mt{agg} ::: \{\{\mt{Type}\}\} \to \mt{exps} ::: \{\mt{Type}\} \to \mt{nm} ::: \mt{Name} \to \mt{t} ::: \mt{Type} \to \mt{nt} ::: \mt{Type} \\ +\hspace{.1in} \to \mt{nullify} \; \mt{t} \; \mt{nt} \to \mt{sql\_query} \; \mt{tables} \; \mt{agg} \; [\mt{nm} = \mt{t}] \to \mt{sql\_exp} \; \mt{tables} \; \mt{agg} \; \mt{exps} \; \mt{nt} \end{array}$$ \texttt{FROM} clauses are specified using a type family, whose arguments are the free table variables and the table variables bound by this clause. diff -r 146b69c53304 -r 3dab4696d116 lib/ur/basis.urs --- a/lib/ur/basis.urs Thu Feb 03 11:12:48 2011 -0500 +++ b/lib/ur/basis.urs Thu Feb 03 21:04:12 2011 -0500 @@ -529,9 +529,10 @@ -> sql_exp tables agg exps t -> sql_exp tables agg exps (option t) -val sql_subquery : tables ::: {{Type}} -> agg ::: {{Type}} -> exps ::: {Type} -> nm ::: Name -> t ::: Type +val sql_subquery : tables ::: {{Type}} -> agg ::: {{Type}} -> exps ::: {Type} -> nm ::: Name -> t ::: Type -> nt ::: Type + -> nullify t nt -> sql_query tables agg [] [nm = t] - -> sql_exp tables agg exps t + -> sql_exp tables agg exps nt (*** Executing queries *) diff -r 146b69c53304 -r 3dab4696d116 src/monoize.sml --- a/src/monoize.sml Thu Feb 03 11:12:48 2011 -0500 +++ b/src/monoize.sml Thu Feb 03 21:04:12 2011 -0500 @@ -2796,7 +2796,9 @@ (L.ECApp ( (L.ECApp ( (L.ECApp ( - (L.EFfi ("Basis", "sql_subquery"), _), + (L.ECApp ( + (L.EFfi ("Basis", "sql_subquery"), _), + _), _), _), _), _), _), _), _), @@ -2806,10 +2808,11 @@ val s = (L'.TFfi ("Basis", "string"), loc) fun sc s = (L'.EPrim (Prim.String s), loc) in - ((L'.EAbs ("x", s, s, - strcat [sc "(", - (L'.ERel 0, loc), - sc ")"]), loc), + ((L'.EAbs ("_", (L'.TRecord [], loc), (L'.TFun (s, s), loc), + (L'.EAbs ("x", s, s, + strcat [sc "(", + (L'.ERel 0, loc), + sc ")"]), loc)), loc), fm) end