Changeset: 61979ffb7bee for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/61979ffb7bee
Modified Files:
clients/Tests/exports.stable.out
monetdb5/modules/mal/tablet.c
sql/backends/monet5/sql.c
sql/backends/monet5/sql_result.c
sql/backends/monet5/sql_result.h
sql/include/sql_catalog.h
sql/storage/bat/bat_table.c
sql/storage/bat/res_table.c
sql/storage/sql_storage.h
sql/test/emptydb/Tests/check.stable.out
sql/test/emptydb/Tests/check.stable.out.32bit
sql/test/emptydb/Tests/check.stable.out.int128
tools/monetdbe/monetdbe.c
Branch: simplify_scenario
Log Message:
order isn't passed down anymore into the result sets, ie no longer use this.
diffs (truncated from 671 to 300 lines):
diff --git a/clients/Tests/exports.stable.out b/clients/Tests/exports.stable.out
--- a/clients/Tests/exports.stable.out
+++ b/clients/Tests/exports.stable.out
@@ -1562,7 +1562,7 @@ sql_table *mvc_bind_table(mvc *c, sql_sc
str mvc_commit(mvc *c, int chain, const char *name, bool enabling_auto_commit);
int mvc_create_column(sql_column **col, mvc *m, sql_table *t, const char
*name, sql_subtype *tpe);
int mvc_result_column(backend *be, const char *tn, const char *name, const
char *typename, int digits, int scale, BAT *b);
-int mvc_result_table(backend *be, oid query_id, int nr_cols, mapi_query_t
type, BAT *order);
+int mvc_result_table(backend *be, oid query_id, int nr_cols, mapi_query_t
type);
str mvc_rollback(mvc *c, int chain, const char *name, bool
disabling_auto_commit);
str number2name(str s, int len, int i);
bool option_disable_fork;
diff --git a/monetdb5/modules/mal/tablet.c b/monetdb5/modules/mal/tablet.c
--- a/monetdb5/modules/mal/tablet.c
+++ b/monetdb5/modules/mal/tablet.c
@@ -103,22 +103,23 @@ check_BATs(Tablet *as)
cnt = BATcount(fmt[i].c);
base = fmt[i].c->hseqbase;
- if (as->nr != cnt)
+ if (as->nr != cnt) {
+ for (i = 0; i < as->nr_attrs; i++)
+ if (fmt[i].c)
+ fmt[i].p = as->offset;
return oid_nil;
+ }
for (i = 0; i < as->nr_attrs; i++) {
- BAT *b;
- BUN offset;
+ BAT *b = fmt[i].c;
- b = fmt[i].c;
if (b == NULL)
continue;
- offset = as->offset;
if (BATcount(b) != cnt || b->hseqbase != base)
return oid_nil;
- fmt[i].p = offset;
+ fmt[i].p = as->offset;
}
return base;
}
@@ -539,7 +540,6 @@ int
TABLEToutput_file(Tablet *as, BAT *order, stream *s)
{
oid base = oid_nil;
- BUN maxnr = BATcount(order);
int ret = 0;
/* only set nr if it is zero or lower (bogus) to the maximum value
@@ -547,12 +547,16 @@ TABLEToutput_file(Tablet *as, BAT *order
* preserve value such that for instance SQL's reply_size still
* works
*/
- if (as->nr == BUN_NONE || as->nr > maxnr)
- as->nr = maxnr;
+ if (order) {
+ BUN maxnr = BATcount(order);
+ if (as->nr == BUN_NONE || as->nr > maxnr)
+ as->nr = maxnr;
+ }
+ assert(as->nr != BUN_NONE);
base = check_BATs(as);
- if (!is_oid_nil(base)) {
- if (order->hseqbase == base)
+ if (!order || !is_oid_nil(base)) {
+ if (!order || order->hseqbase == base)
ret = output_file_dense(as, s);
else
ret = output_file_ordered(as, order, s);
diff --git a/sql/backends/monet5/sql.c b/sql/backends/monet5/sql.c
--- a/sql/backends/monet5/sql.c
+++ b/sql/backends/monet5/sql.c
@@ -2433,7 +2433,7 @@ mvc_result_set_wrap( Client cntxt, MalBl
msg = createException(SQL, "sql.resultSet", SQLSTATE(HY005)
"Cannot access column descriptor");
goto wrapup_result_set;
}
- res = *res_id = mvc_result_table(be, mb->tag, pci->argc - (pci->retc +
5), Q_TABLE, b);
+ res = *res_id = mvc_result_table(be, mb->tag, pci->argc - (pci->retc +
5), Q_TABLE);
BBPunfix(b->batCacheid);
if (res < 0) {
msg = createException(SQL, "sql.resultSet", SQLSTATE(HY013)
MAL_MALLOC_FAIL);
@@ -2516,7 +2516,7 @@ mvc_export_table_wrap( Client cntxt, Mal
BATiter itertbl,iteratr,itertpe,iterdig,iterscl;
backend *be;
mvc *m = NULL;
- BAT *order = NULL, *b = NULL, *tbl = NULL, *atr = NULL, *tpe =
NULL,*len = NULL,*scale = NULL;
+ BAT *b = NULL, *tbl = NULL, *atr = NULL, *tpe = NULL,*len = NULL,*scale
= NULL;
res_table *t = NULL;
bool tostdout;
char buf[80];
@@ -2534,12 +2534,7 @@ mvc_export_table_wrap( Client cntxt, Mal
}
bid = *getArgReference_bat(stk,pci,13);
- order = BATdescriptor(bid);
- if ( order == NULL) {
- msg = createException(SQL, "sql.resultSet", SQLSTATE(HY005)
"Cannot access column descriptor");
- goto wrapup_result_set1;
- }
- res = *res_id = mvc_result_table(be, mb->tag, pci->argc - (pci->retc +
12), Q_TABLE, order);
+ res = *res_id = mvc_result_table(be, mb->tag, pci->argc - (pci->retc +
12), Q_TABLE);
t = be->results;
if (res < 0) {
msg = createException(SQL, "sql.resultSet", SQLSTATE(HY013)
MAL_MALLOC_FAIL);
@@ -2634,7 +2629,6 @@ mvc_export_table_wrap( Client cntxt, Mal
wrapup_result_set1:
cntxt->qryctx.starttime = 0;
mb->optimize = 0;
- BBPreclaim(order);
if( tbl) BBPunfix(tblId);
if( atr) BBPunfix(atrId);
if( tpe) BBPunfix(tpeId);
@@ -2666,7 +2660,7 @@ mvc_row_result_wrap( Client cntxt, MalBl
if ((msg = getBackendContext(cntxt, &be)) != NULL)
return msg;
- res = *res_id = mvc_result_table(be, mb->tag, pci->argc - (pci->retc +
5), Q_TABLE, NULL);
+ res = *res_id = mvc_result_table(be, mb->tag, pci->argc - (pci->retc +
5), Q_TABLE);
if (res < 0) {
msg = createException(SQL, "sql.resultSet", SQLSTATE(HY013)
MAL_MALLOC_FAIL);
goto wrapup_result_set;
@@ -2769,7 +2763,7 @@ mvc_export_row_wrap( Client cntxt, MalBl
goto wrapup_result_set;
}
- res = *res_id = mvc_result_table(be, mb->tag, pci->argc - (pci->retc +
12), Q_TABLE, NULL);
+ res = *res_id = mvc_result_table(be, mb->tag, pci->argc - (pci->retc +
12), Q_TABLE);
t = be->results;
if (res < 0){
@@ -2879,30 +2873,28 @@ str
mvc_table_result_wrap(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci)
{
str res = MAL_SUCCEED;
- BAT *order;
backend *be = NULL;
str msg;
int *res_id;
int nr_cols;
mapi_query_t qtype;
- bat order_bid;
if ( pci->argc > 6)
return mvc_result_set_wrap(cntxt,mb,stk,pci);
+ assert(0);
res_id = getArgReference_int(stk, pci, 0);
nr_cols = *getArgReference_int(stk, pci, 1);
qtype = (mapi_query_t) *getArgReference_int(stk, pci, 2);
- order_bid = *getArgReference_bat(stk, pci, 3);
+ bat order_bid = *getArgReference_bat(stk, pci, 3);
+ (void)order_bid;
+ /* TODO remove use */
if ((msg = getBackendContext(cntxt, &be)) != NULL)
return msg;
- if ((order = BATdescriptor(order_bid)) == NULL)
- throw(SQL, "sql.resultSet", SQLSTATE(HY005) "Cannot access
column descriptor");
- *res_id = mvc_result_table(be, mb->tag, nr_cols, qtype, order);
+ *res_id = mvc_result_table(be, mb->tag, nr_cols, qtype);
if (*res_id < 0)
res = createException(SQL, "sql.resultSet", SQLSTATE(HY013)
MAL_MALLOC_FAIL);
- BBPunfix(order->batCacheid);
return res;
}
@@ -3045,7 +3037,7 @@ mvc_scalar_value_wrap(Client cntxt, MalB
p = *(ptr *) p;
// scalar values are single-column result sets
- if ((res_id = mvc_result_table(be, mb->tag, 1, Q_TABLE, NULL)) < 0) {
+ if ((res_id = mvc_result_table(be, mb->tag, 1, Q_TABLE)) < 0) {
cntxt->qryctx.starttime = 0;
mb->optimize = 0;
throw(SQL, "sql.exportValue", SQLSTATE(HY013) MAL_MALLOC_FAIL);
diff --git a/sql/backends/monet5/sql_result.c b/sql/backends/monet5/sql_result.c
--- a/sql/backends/monet5/sql_result.c
+++ b/sql/backends/monet5/sql_result.c
@@ -716,7 +716,6 @@ create_prepare_result(backend *b, cq *q,
BAT* bschema = COLnew(0, TYPE_str, nrows, TRANSIENT);
BAT* btable = COLnew(0, TYPE_str, nrows, TRANSIENT);
BAT* bcolumn = COLnew(0, TYPE_str, nrows, TRANSIENT);
- BAT* order = NULL;
node *n;
const int nr_columns = (b->client->protocol == PROTOCOL_COLUMNAR ||
GDKembedded()) ? 7 : 6;
@@ -827,18 +826,13 @@ create_prepare_result(backend *b, cq *q,
}
}
- if (!(order = BATdense(0, 0, BATcount(btype)))) {
- error = -1;
- goto wrapup;
- }
b->results = res_table_create(
b->mvc->session->tr,
b->result_id++,
b->mb? b->mb->tag: 0
/*TODO check if this is sensible*/,
nr_columns,
Q_PREPARE,
- b->results,
- order);
+ b->results);
if (!b->results) {
error = -1;
goto wrapup;
@@ -868,8 +862,7 @@ create_prepare_result(backend *b, cq *q,
if (error < 0 && b->results) {
res_table_destroy(b->results);
b->results = NULL;
- } else
- BBPreclaim(order);
+ }
return error;
}
@@ -1166,7 +1159,7 @@ mvc_export_table_columnar(stream *s, res
}
static int
-mvc_export_table_(mvc *m, int output_format, stream *s, res_table *t, BAT
*order, BUN offset, BUN nr, const char *btag, const char *sep, const char
*rsep, const char *ssep, const char *ns)
+mvc_export_table_(mvc *m, int output_format, stream *s, res_table *t, BUN
offset, BUN nr, const char *btag, const char *sep, const char *rsep, const char
*ssep, const char *ns)
{
Tablet as;
Column *fmt;
@@ -1287,7 +1280,7 @@ mvc_export_table_(mvc *m, int output_for
}
}
if (i == t->nr_cols + 1)
- ok = TABLEToutput_file(&as, order, s);
+ ok = TABLEToutput_file(&as, NULL, s);
for (i = 0; i <= t->nr_cols; i++) {
fmt[i].sep = NULL;
fmt[i].rsep = NULL;
@@ -1306,9 +1299,9 @@ mvc_export_table_(mvc *m, int output_for
}
static int
-mvc_export_table(backend *b, stream *s, res_table *t, BAT *order, BUN offset,
BUN nr, const char *btag, const char *sep, const char *rsep, const char *ssep,
const char *ns)
+mvc_export_table(backend *b, stream *s, res_table *t, BUN offset, BUN nr,
const char *btag, const char *sep, const char *rsep, const char *ssep, const
char *ns)
{
- return mvc_export_table_(b->mvc, b->output_format, s, t, order, offset,
nr, btag, sep, rsep, ssep, ns);
+ return mvc_export_table_(b->mvc, b->output_format, s, t, offset, nr,
btag, sep, rsep, ssep, ns);
}
int
@@ -1318,12 +1311,10 @@ mvc_export(mvc *m, stream *s, res_table
b.mvc = m;
b.results = t;
b.reloptimizer = 0;
- t->order = t->cols[0].b;
t->nr_rows = nr;
- BBPretain(t->order);
if (mvc_export_head(&b, s, t->id, TRUE, TRUE, 0/*starttime*/,
0/*maloptimizer*/) < 0)
return -1;
- return mvc_export_table_(m, OFMT_CSV, s, t, BBPquickdesc(t->cols[0].b),
0, nr, "[ ", ",\t", "\t]\n", "\"", "NULL");
+ return mvc_export_table_(m, OFMT_CSV, s, t, 0, nr, "[ ", ",\t",
"\t]\n", "\"", "NULL");
}
@@ -1553,13 +1544,6 @@ mvc_export_affrows(backend *b, stream *s
return mvc_affrows(b->mvc, s, val, w, query_id, b->last_id, starttime,
maloptimizer, b->reloptimizer);
}
-static int
-export_error(BAT *order)
-{
- BBPreclaim(order);
- return -4;
-}
-
int
mvc_export_head(backend *b, stream *s, int res_id, int only_header, int
compute_lengths, lng starttime, lng maloptimizer)
{
@@ -1583,7 +1567,7 @@ mvc_export_head(backend *b, stream *s, i
/* tuple count */
if (only_header) {
- if (t->order) {
+ if (t->cols[0].b) {
count = t->nr_rows;
} else {
count = 1;
@@ -1706,18 +1690,13 @@ mvc_export_file(backend *b, stream *s, r
{
int res = 0;
BUN count;
- BAT *order = NULL;
- if (!t->order) {
+ if (!t->cols[0].b) {
res = mvc_export_row(b, s, t, "", t->tsep, t->rsep, t->ssep,
t->ns);
} else {
- order = BATdescriptor(t->order);
- if (!order)
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]