Changeset: 84590b98c503 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/84590b98c503
Modified Files:
sql/server/rel_psm.c
sql/storage/bat/bat_table.c
Branch: Jul2021
Log Message:
Return early on error
diffs (100 lines):
diff --git a/sql/server/rel_psm.c b/sql/server/rel_psm.c
--- a/sql/server/rel_psm.c
+++ b/sql/server/rel_psm.c
@@ -231,12 +231,11 @@ rel_psm_while_do( sql_query *query, sql_
sql_rel *rel = NULL;
exp_kind ek = {type_value, card_value, FALSE};
- cond = rel_logical_value_exp(query, &rel, n->data.sym, sql_sel
| sql_psm, ek);
+ if (!(cond = rel_logical_value_exp(query, &rel, n->data.sym,
sql_sel | sql_psm, ek)))
+ return NULL;
psm_zero_or_one(cond);
n = n->next;
- whilestmts = sequential_block(query, res, restypelist,
n->data.lval, n->next->data.sval, is_func);
-
- if (sql->session->status || !cond || !whilestmts)
+ if (!(whilestmts = sequential_block(query, res, restypelist,
n->data.lval, n->next->data.sval, is_func)))
return NULL;
return exp_while( sql->sa, cond, whilestmts );
@@ -263,14 +262,15 @@ psm_if_then_else( sql_query *query, sql_
sql_rel *rel = NULL;
exp_kind ek = {type_value, card_value, FALSE};
- cond = rel_logical_value_exp(query, &rel, n->data.sym, sql_sel
| sql_psm, ek);
+ if (!(cond = rel_logical_value_exp(query, &rel, n->data.sym,
sql_sel | sql_psm, ek)))
+ return NULL;
psm_zero_or_one(cond);
n = n->next;
- ifstmts = sequential_block(query, res, restypelist,
n->data.lval, NULL, is_func);
+ if (!(ifstmts = sequential_block(query, res, restypelist,
n->data.lval, NULL, is_func)))
+ return NULL;
n = n->next;
elsestmts = psm_if_then_else( query, res, restypelist, n,
is_func);
-
- if (sql->session->status || !cond || !ifstmts)
+ if (sql->session->status)
return NULL;
return append(sa_list(sql->sa), exp_if( sql->sa, cond, ifstmts,
elsestmts));
@@ -296,13 +296,15 @@ rel_psm_if_then_else( sql_query *query,
sql_rel *rel = NULL;
exp_kind ek = {type_value, card_value, FALSE};
- cond = rel_logical_value_exp(query, &rel, n->data.sym, sql_sel
| sql_psm, ek);
+ if (!(cond = rel_logical_value_exp(query, &rel, n->data.sym,
sql_sel | sql_psm, ek)))
+ return NULL;
psm_zero_or_one(cond);
n = n->next;
- ifstmts = sequential_block(query, res, restypelist,
n->data.lval, NULL, is_func);
+ if (!(ifstmts = sequential_block(query, res, restypelist,
n->data.lval, NULL, is_func)))
+ return NULL;
n = n->next;
elsestmts = psm_if_then_else( query, res, restypelist, n,
is_func);
- if (sql->session->status || !cond || !ifstmts)
+ if (sql->session->status)
return NULL;
return exp_if( sql->sa, cond, ifstmts, elsestmts);
diff --git a/sql/storage/bat/bat_table.c b/sql/storage/bat/bat_table.c
--- a/sql/storage/bat/bat_table.c
+++ b/sql/storage/bat/bat_table.c
@@ -527,6 +527,8 @@ rids_orderby(sql_trans *tr, rids *r, sql
return NULL;
s = BATproject(r->data, b);
bat_destroy(b);
+ if (s == NULL)
+ return NULL;
if (BATsort(NULL, &o, NULL, s, NULL, NULL, false, false, false) !=
GDK_SUCCEED) {
bat_destroy(s);
return NULL;
@@ -750,25 +752,16 @@ rids_diff(sql_trans *tr, rids *l, sql_co
}
rcb = s;
- s = BATproject(l->data, lcb);
- if (s == NULL) {
+ diff = BATdiff(lcb, rcb, l->data, NULL, false, false, BUN_NONE);
+ bat_destroy(rcb);
+ if (diff == NULL) {
bat_destroy(lcb);
- bat_destroy(rcb);
return NULL;
}
- diff = BATdiff(s, rcb, NULL, NULL, false, false, BUN_NONE);
- bat_destroy(rcb);
- if (diff == NULL) {
- bat_destroy(lcb);
- bat_destroy(s);
- return NULL;
- }
-
- ret = BATjoin(&rids, NULL, lcb, s, NULL, diff, false, BATcount(s));
+ ret = BATjoin(&rids, NULL, lcb, lcb, NULL, diff, false, BATcount(lcb) -
BATcount(diff));
bat_destroy(diff);
bat_destroy(lcb);
- bat_destroy(s);
if (ret != GDK_SUCCEED)
return NULL;
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list