Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Bugfix: Quering more columns than exist.

  • Loading branch information...
commit ef3426be7e650ab3a56df1dcd110502bdeb88314 1 parent 5053bc0
@ckroxigor ckroxigor authored
Showing with 30 additions and 2 deletions.
  1. +9 −0 eval.ml
  2. +21 −2 examples.lang
View
9 eval.ml
@@ -250,6 +250,8 @@ let str_list_to_str l =
(* Subquery generator *)
let rec get_subquery e name col_names =
+ let num_queried_columns = ( List.length(Str.split (Str.regexp ",") col_names)) in
+ (*Printf.printf "Number of parameters: %i\n" (List.length(Str.split (Str.regexp ",") col_names));*)
(*Printf.printf "Call %s\n" name; flush stdout;*)
let head_cols = get_head_attibutes e name in
(*Printf.printf "Head columns(%i): %s\n" (List.length head_cols) (String.concat ", " head_cols);*)
@@ -259,6 +261,10 @@ let rec get_subquery e name col_names =
flush stdout;
if ((List.length l) = 0) then
(*It's an edb*)
+ let edb_cols = get_column name in
+ if num_queried_columns > (List.length edb_cols) then
+ raise (QueryError ("Relation '"^name^"' has "^(string_of_int (List.length edb_cols))^" but you queried "^(string_of_int num_queried_columns)^"."))
+ else
(String.concat " " [
"(SELECT";
(merge_names (get_column name) (Str.split (Str.regexp ",") col_names) 0);
@@ -268,6 +274,9 @@ let rec get_subquery e name col_names =
"AS foo";
])
else
+ if num_queried_columns > (List.length head_cols) then
+ raise (QueryError ("Relation '"^name^"' has "^(string_of_int (List.length head_cols))^" but you queried "^(string_of_int num_queried_columns)^"."))
+ else
let sel = (merge_names head_cols (Str.split (Str.regexp ",") col_names) 0) in
(String.concat " " [
"(SELECT";
View
23 examples.lang
@@ -108,6 +108,15 @@ R(x):-Enroll(a,x,b) and not Q(x).
?-R(x).
/
+Q(id,descr) :- Test(id,descr).
+R(id,descr) :- Q(id,descr).
+?-R(x,y,x).
+/
+
+Q(id,descr) :- Test(id,descr).
+R(id,descr) :- Q(id,descr,id).
+?-R(x,y).
+/
Q(y):-Student(x,z,a) and not Enroll(x,y,b) and Enroll(c,y,d) and not b=100.
R(x):-Enroll(a,x,b) and not Q(x).
?-R(x).
@@ -125,6 +134,16 @@ Q(y):-Enroll(a,y,b) and not y = 100.
?-Q(y).
/
-Q(y):-Enroll(a,y,b) and y = 100 and y = 200.
-?-Q(y).
+Q(id,descr) :- Test(id,descr).
+R(id,descr) :- Q(id,descr).
+?-R(x,y,x).
+/
+
+Q(id,descr) :- Test(id,descr).
+R(id,descr) :- Q(id,descr,id).
+?-R(x,y).
+/
+
+Q(a,b,c) :- Test(a,b,c).
+?-Q(id,descr,c).
/
Please sign in to comment.
Something went wrong with that request. Please try again.