Changeset: 7bfab0e4f9e1 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=7bfab0e4f9e1
Modified Files:
gdk/gdk_analytic_bounds.c
sql/backends/monet5/sql_rank.c
sql/server/rel_schema.c
sql/server/sql_parser.y
sql/test/BugTracker-2013/Tests/All
sql/test/BugTracker-2013/Tests/check-constraint.Bug-3335.stable.err
sql/test/BugTracker-2013/Tests/check-constraint.Bug-3335.stable.out
sql/test/analytics/Tests/analytics06.sql
sql/test/analytics/Tests/analytics06.stable.err
sql/test/analytics/Tests/analytics06.stable.out
sql/test/wlcr/Tests/All
Branch: default
Log Message:
Merge with Nov2019
diffs (truncated from 417 to 300 lines):
diff --git a/gdk/gdk_analytic_bounds.c b/gdk/gdk_analytic_bounds.c
--- a/gdk/gdk_analytic_bounds.c
+++ b/gdk/gdk_analytic_bounds.c
@@ -16,7 +16,7 @@
lng calc1, calc2; \
j = k; \
for (; k < i; k++, rb++) { \
- lng rlimit = (lng) LIMIT; \
+ lng rlimit = LIMIT; \
SUB_WITH_CHECK(k, rlimit, lng, calc1, GDK_lng_max, goto
calc_overflow); \
ADD_WITH_CHECK(calc1, !first_half, lng, calc2,
GDK_lng_max, goto calc_overflow); \
*rb = MAX(calc2, j); \
@@ -27,7 +27,7 @@
do { \
lng calc1, calc2; \
for (; k < i; k++, rb++) { \
- lng rlimit = (lng) LIMIT; \
+ lng rlimit = LIMIT; \
ADD_WITH_CHECK(rlimit, k, lng, calc1, GDK_lng_max, goto
calc_overflow); \
ADD_WITH_CHECK(calc1, !first_half, lng, calc2,
GDK_lng_max, goto calc_overflow); \
*rb = MIN(calc2, i); \
@@ -489,39 +489,50 @@ GDKanalyticalrowbounds(BAT *r, BAT *b, B
case TYPE_bte:{
bte *restrict limit = (bte *) Tloc(l, 0);
if (preceding) {
-
ANALYTICAL_WINDOW_BOUNDS_BRANCHES_ROWS(_PRECEDING, limit[k]);
+
ANALYTICAL_WINDOW_BOUNDS_BRANCHES_ROWS(_PRECEDING, (lng) limit[k]);
} else {
-
ANALYTICAL_WINDOW_BOUNDS_BRANCHES_ROWS(_FOLLOWING, limit[k]);
+
ANALYTICAL_WINDOW_BOUNDS_BRANCHES_ROWS(_FOLLOWING, (lng) limit[k]);
}
break;
}
case TYPE_sht:{
sht *restrict limit = (sht *) Tloc(l, 0);
if (preceding) {
-
ANALYTICAL_WINDOW_BOUNDS_BRANCHES_ROWS(_PRECEDING, limit[k]);
+
ANALYTICAL_WINDOW_BOUNDS_BRANCHES_ROWS(_PRECEDING, (lng) limit[k]);
} else {
-
ANALYTICAL_WINDOW_BOUNDS_BRANCHES_ROWS(_FOLLOWING, limit[k]);
+
ANALYTICAL_WINDOW_BOUNDS_BRANCHES_ROWS(_FOLLOWING, (lng) limit[k]);
}
break;
}
case TYPE_int:{
int *restrict limit = (int *) Tloc(l, 0);
if (preceding) {
-
ANALYTICAL_WINDOW_BOUNDS_BRANCHES_ROWS(_PRECEDING, limit[k]);
+
ANALYTICAL_WINDOW_BOUNDS_BRANCHES_ROWS(_PRECEDING, (lng) limit[k]);
} else {
-
ANALYTICAL_WINDOW_BOUNDS_BRANCHES_ROWS(_FOLLOWING, limit[k]);
+
ANALYTICAL_WINDOW_BOUNDS_BRANCHES_ROWS(_FOLLOWING, (lng) limit[k]);
}
break;
}
case TYPE_lng:{
lng *restrict limit = (lng *) Tloc(l, 0);
if (preceding) {
-
ANALYTICAL_WINDOW_BOUNDS_BRANCHES_ROWS(_PRECEDING, limit[k]);
+
ANALYTICAL_WINDOW_BOUNDS_BRANCHES_ROWS(_PRECEDING, (lng) limit[k]);
} else {
-
ANALYTICAL_WINDOW_BOUNDS_BRANCHES_ROWS(_FOLLOWING, limit[k]);
+
ANALYTICAL_WINDOW_BOUNDS_BRANCHES_ROWS(_FOLLOWING, (lng) limit[k]);
}
break;
}
+#ifdef HAVE_HGE
+ case TYPE_hge:{
+ hge *restrict limit = (hge *) Tloc(l, 0);
+ if (preceding) {
+
ANALYTICAL_WINDOW_BOUNDS_BRANCHES_ROWS(_PRECEDING, (limit[k] > (hge)
GDK_lng_max) ? GDK_lng_max : (lng) limit[k]);
+ } else {
+
ANALYTICAL_WINDOW_BOUNDS_BRANCHES_ROWS(_FOLLOWING, (limit[k] > (hge)
GDK_lng_max) ? GDK_lng_max : (lng) limit[k]);
+ }
+ break;
+ }
+#endif
default:
goto bound_not_supported;
}
@@ -540,6 +551,13 @@ GDKanalyticalrowbounds(BAT *r, BAT *b, B
case TYPE_lng:
limit = (lng) (*(lng *) bound);
break;
+#ifdef HAVE_HGE
+ case TYPE_hge: {
+ hge nval = *(hge *) bound;
+ limit = is_hge_nil(nval) ? lng_nil : (nval > (hge)
GDK_lng_max) ? GDK_lng_max : (lng) nval;
+ break;
+ }
+#endif
default:
goto bound_not_supported;
}
@@ -797,6 +815,17 @@ GDKanalyticalgroupsbounds(BAT *r, BAT *b
}
break;
}
+#ifdef HAVE_HGE
+ case TYPE_hge:{
+ hge *restrict limit = (hge *) Tloc(l, 0);
+ if (preceding) {
+
ANALYTICAL_WINDOW_BOUNDS_BRANCHES_GROUPS(_PRECEDING, (limit[k] > (hge)
GDK_lng_max) ? GDK_lng_max : (lng) limit[k]);
+ } else {
+
ANALYTICAL_WINDOW_BOUNDS_BRANCHES_GROUPS(_FOLLOWING, (limit[k] > (hge)
GDK_lng_max) ? GDK_lng_max : (lng) limit[k]);
+ }
+ break;
+ }
+#endif
default:
goto bound_not_supported;
}
@@ -815,6 +844,13 @@ GDKanalyticalgroupsbounds(BAT *r, BAT *b
case TYPE_lng:
limit = (lng) (*(lng *) bound);
break;
+#ifdef HAVE_HGE
+ case TYPE_hge: {
+ hge nval = *(hge *) bound;
+ limit = is_hge_nil(nval) ? lng_nil : (nval > (hge)
GDK_lng_max) ? GDK_lng_max : (lng) nval;
+ break;
+ }
+#endif
default:
goto bound_not_supported;
}
diff --git a/sql/backends/monet5/sql_rank.c b/sql/backends/monet5/sql_rank.c
--- a/sql/backends/monet5/sql_rank.c
+++ b/sql/backends/monet5/sql_rank.c
@@ -63,7 +63,7 @@ SQLdiff(Client cntxt, MalBlkPtr mb, MalS
}
#define CHECK_NEGATIVES_COLUMN(TPE) \
- for(TPE *lp = (TPE*)Tloc(l, 0), *lend = lp + BATcount(l); lp < lend &&
!is_negative; lp++) { \
+ for (TPE *lp = (TPE*)Tloc(l, 0), *lend = lp + BATcount(l); lp < lend &&
!is_negative; lp++) { \
is_negative |= !is_##TPE##_nil(*lp) && (*lp < 0); \
} \
@@ -113,7 +113,7 @@ SQLwindow_bound(Client cntxt, MalBlkPtr
}
is_a_bat = isaBatType(tp2);
- if(is_a_bat)
+ if (is_a_bat)
tp2 = getBatType(tp2);
voidresultBAT(r, TYPE_lng, BATcount(b), b, "sql.window_bound");
@@ -123,6 +123,11 @@ SQLwindow_bound(Client cntxt, MalBlkPtr
BBPunfix(b->batCacheid);
throw(SQL, "sql.window_bound", SQLSTATE(HY005)
"Cannot access column descriptor");
}
+ if ((unit == 0 || unit == 2) && l->tnil) {
+ BBPunfix(b->batCacheid);
+ BBPunfix(l->batCacheid);
+ throw(SQL, "sql.window_bound", SQLSTATE(HY005)
"All values on %s boundary must be non-null for %s frame", preceding ?
"PRECEDING" : "FOLLOWING", (unit == 0) ? "ROWS" : "GROUPS");
+ }
switch (tp2) {
case TYPE_bte:
CHECK_NEGATIVES_COLUMN(bte)
@@ -153,7 +158,7 @@ SQLwindow_bound(Client cntxt, MalBlkPtr
throw(SQL, "sql.window_bound",
SQLSTATE(42000) "%s limit not available for %s", "sql.window_bound",
ATOMname(tp2));
}
}
- if(is_negative) {
+ if (is_negative) {
BBPunfix(b->batCacheid);
BBPunfix(l->batCacheid);
throw(SQL, "sql.window_bound", SQLSTATE(HY005)
"All values on %s boundary must be non-negative", preceding ? "PRECEDING" :
"FOLLOWING");
@@ -190,7 +195,7 @@ SQLwindow_bound(Client cntxt, MalBlkPtr
throw(SQL, "sql.window_bound",
SQLSTATE(42000) "%s limit is not available for %s", "sql.window_bound",
ATOMname(tp2));
}
}
- if(is_negative)
+ if (is_negative)
throw(SQL, "sql.window_bound", SQLSTATE(42000)
"The %s boundary must be non-negative", preceding ? "PRECEDING" : "FOLLOWING");
}
if (part_offset) {
diff --git a/sql/server/rel_schema.c b/sql/server/rel_schema.c
--- a/sql/server/rel_schema.c
+++ b/sql/server/rel_schema.c
@@ -226,6 +226,10 @@ table_constraint_name(symbol *s, sql_tab
suffix = "_fkey";
nms = s->data.lval->h->next->data.lval->h; /* list
of colums */
break;
+ case SQL_CHECK:
+ suffix = "_check";
+ nms = s->data.lval->h; /* list of check constraint
conditions */
+ break;
default:
suffix = "_?";
nms = NULL;
@@ -294,6 +298,9 @@ column_constraint_name(symbol *s, sql_co
case SQL_FOREIGN_KEY:
suffix = "fkey";
break;
+ case SQL_CHECK:
+ suffix = "check";
+ break;
default:
suffix = "?";
}
@@ -394,6 +401,10 @@ column_constraint_type(mvc *sql, char *n
mvc_null(sql, cs, null);
res = SQL_OK;
} break;
+ case SQL_CHECK: {
+ (void) sql_error(sql, 02, SQLSTATE(42000) "CONSTRAINT CHECK:
check constraints not supported\n");
+ return SQL_ERR;
+ } break;
default:{
res = SQL_ERR;
}
@@ -422,8 +433,6 @@ column_option(
char *opt_name = l->h->data.sval;
symbol *sym = l->h->next->data.sym;
- if (!sym) /* For now we only parse CHECK Constraints */
- return SQL_OK;
if (!opt_name)
opt_name = column_constraint_name(sym, cs, t);
res = column_constraint_type(sql, opt_name, sym, ss, t, cs);
@@ -625,6 +634,10 @@ table_constraint_type(mvc *sql, char *na
case SQL_FOREIGN_KEY:
res = table_foreign_key(sql, name, s, ss, t);
break;
+ case SQL_CHECK: {
+ (void) sql_error(sql, 02, SQLSTATE(42000) "CONSTRAINT CHECK:
check constraints not supported\n");
+ return SQL_ERR;
+ } break;
default:
res = SQL_ERR;
}
diff --git a/sql/server/sql_parser.y b/sql/server/sql_parser.y
--- a/sql/server/sql_parser.y
+++ b/sql/server/sql_parser.y
@@ -2003,8 +2003,7 @@ table_constraint_type:
;
domain_constraint_type:
-/* CHECK '(' search_condition ')' { $$ = _symbol_create_symbol(SQL_CHECK,
$3); }*/
- CHECK '(' search_condition ')' { $$ = NULL; }
+ CHECK '(' search_condition ')' { $$ = _symbol_create_symbol(SQL_CHECK,
$3); }
;
ident_commalist:
diff --git a/sql/test/BugTracker-2013/Tests/All
b/sql/test/BugTracker-2013/Tests/All
--- a/sql/test/BugTracker-2013/Tests/All
+++ b/sql/test/BugTracker-2013/Tests/All
@@ -48,7 +48,7 @@ copy-into-compressed.Bug-3351
HAVE_LIBZ?copy-into-compressed-gz.Bug-3351
HAVE_LIBBZ2?copy-into-compressed-bz2.Bug-3351
median.Bug-3352
-KNOWNFAIL?check-constraint.Bug-3335
+check-constraint.Bug-3335
crash_after_creation_of_unique_key.Bug-3363
alter_resets_readonly.Bug-3362
env_errors.Bug-3370
diff --git
a/sql/test/BugTracker-2013/Tests/check-constraint.Bug-3335.stable.err
b/sql/test/BugTracker-2013/Tests/check-constraint.Bug-3335.stable.err
--- a/sql/test/BugTracker-2013/Tests/check-constraint.Bug-3335.stable.err
+++ b/sql/test/BugTracker-2013/Tests/check-constraint.Bug-3335.stable.err
@@ -28,7 +28,30 @@ stderr of test 'check-constraint.Bug-333
# 15:34:30 > "mclient" "-lsql" "-ftest" "-Eutf-8" "-i" "-e"
"--host=/var/tmp/mtest-26220" "--port=35083"
# 15:34:30 >
-We expect an error here.
+MAPI = (monetdb) /var/tmp/mtest-20083/.s.monetdb.36487
+QUERY = create table t3335(x integer check(x > 0 and x < 2));
+ERROR = !CONSTRAINT CHECK: check constraints not supported
+CODE = 42000
+MAPI = (monetdb) /var/tmp/mtest-20083/.s.monetdb.36487
+QUERY = insert into t3335 values(1);
+ERROR = !Current transaction is aborted (please ROLLBACK)
+CODE = 25005
+MAPI = (monetdb) /var/tmp/mtest-20083/.s.monetdb.36487
+QUERY = insert into t3335 values(0);
+ERROR = !Current transaction is aborted (please ROLLBACK)
+CODE = 25005
+MAPI = (monetdb) /var/tmp/mtest-20083/.s.monetdb.36487
+QUERY = insert into t3335 values(2);
+ERROR = !Current transaction is aborted (please ROLLBACK)
+CODE = 25005
+MAPI = (monetdb) /var/tmp/mtest-20083/.s.monetdb.36487
+QUERY = insert into t3335 values(-1);
+ERROR = !Current transaction is aborted (please ROLLBACK)
+CODE = 25005
+MAPI = (monetdb) /var/tmp/mtest-20083/.s.monetdb.36487
+QUERY = insert into t3335 values(3);
+ERROR = !Current transaction is aborted (please ROLLBACK)
+CODE = 25005
# 15:34:31 >
# 15:34:31 > "Done."
diff --git
a/sql/test/BugTracker-2013/Tests/check-constraint.Bug-3335.stable.out
b/sql/test/BugTracker-2013/Tests/check-constraint.Bug-3335.stable.out
--- a/sql/test/BugTracker-2013/Tests/check-constraint.Bug-3335.stable.out
+++ b/sql/test/BugTracker-2013/Tests/check-constraint.Bug-3335.stable.out
@@ -48,11 +48,7 @@ stdout of test 'check-constraint.Bug-333
# 15:34:30 >
#start transaction;
-#create table t3335(x integer check(x > 0 and x < 2));
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list