Changeset: a83dd09114c4 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=a83dd09114c4
Modified Files:
clients/Tests/exports.stable.out
monetdb5/modules/mal/tablet.c
monetdb5/modules/mal/tablet.h
sql/backends/monet5/sql.c
sql/backends/monet5/sql_result.c
sql/backends/monet5/sql_result.h
Branch: default
Log Message:
Merge with Aug2018 branch.
Note that changeset d5b35d896228 had to be done differently because of
the ON CLIENT option in COPY INTO.
diffs (128 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
@@ -1797,7 +1797,7 @@ str SERVERsuspend(void *ret);
str SERVERtrace(void *ret, int *mid, int *flag);
ssize_t SQLBLOBfromstr(const char *instr, size_t *l, blob **val, bool
external);
ssize_t SQLBLOBtostr(str *tostr, size_t *l, const blob *pin, bool external);
-BUN SQLload_file(Client cntxt, Tablet *as, bstream *b, stream *out, const char
*csep, const char *rsep, char quote, lng skip, lng maxrow, int best);
+BUN SQLload_file(Client cntxt, Tablet *as, bstream *b, stream *out, const char
*csep, const char *rsep, char quote, lng skip, lng maxrow, int best, bool
from_stdin);
str STRBytes(int *res, const str *arg1);
str STRConcat(str *res, const str *val1, const str *val2);
str STRFromWChr(str *res, const int *at);
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
@@ -627,6 +627,7 @@ typedef struct {
lng *time, wtime; /* time per col + time per
thread */
int rounds; /* how often did we
divide the work */
bool ateof; /* io control */
+ bool from_stdin;
bstream *b;
stream *out;
MT_Id tid;
@@ -1235,8 +1236,8 @@ SQLproducer(void *p)
READERtask *task = (READERtask *) p;
int consoleinput = 0;
int cur = 0; // buffer being filled
- bool blocked[MAXBUFFERS] = { 0 };
- bool ateof[MAXBUFFERS] = { 0 };
+ bool blocked[MAXBUFFERS] = { false };
+ bool ateof[MAXBUFFERS] = { false };
BUN cnt = 0, bufcnt[MAXBUFFERS] = { 0 };
char *end, *e, *s, *base;
const char *rsep = task->rsep;
@@ -1335,6 +1336,10 @@ SQLproducer(void *p)
* scan ended (we need to back off some since we could be in
* the middle of the record separator). If this is too
* costly, we have to rethink the matter. */
+ if (task->from_stdin && *s == '\n' && task->maxrow == BUN_NONE)
{
+ ateof[cur] = true;
+ goto reportlackofinput;
+ }
for (e = s; *e && e < end && cnt < task->maxrow;) {
/* tokenize the record completely the format of the
input
* should comply to the following grammar rule [
@@ -1597,7 +1602,7 @@ create_rejects_table(Client cntxt)
}
BUN
-SQLload_file(Client cntxt, Tablet *as, bstream *b, stream *out, const char
*csep, const char *rsep, char quote, lng skip, lng maxrow, int best)
+SQLload_file(Client cntxt, Tablet *as, bstream *b, stream *out, const char
*csep, const char *rsep, char quote, lng skip, lng maxrow, int best, bool
from_stdin)
{
BUN cnt = 0, cntstart = 0, leftover = 0;
int res = 0; /* < 0: error, > 0: success, == 0: continue
processing */
@@ -1617,6 +1622,7 @@ SQLload_file(Client cntxt, Tablet *as, b
memset(ptask, 0, sizeof(ptask));
task = (READERtask) {
.cntxt = cntxt,
+ .from_stdin = from_stdin,
};
/* create the reject tables */
diff --git a/monetdb5/modules/mal/tablet.h b/monetdb5/modules/mal/tablet.h
--- a/monetdb5/modules/mal/tablet.h
+++ b/monetdb5/modules/mal/tablet.h
@@ -72,7 +72,7 @@ typedef struct Table_t {
BAT *complaints; /* lines that did not match the
required input */
} Tablet;
-mal_export BUN SQLload_file(Client cntxt, Tablet *as, bstream *b, stream *out,
const char *csep, const char *rsep, char quote, lng skip, lng maxrow, int best);
+mal_export BUN SQLload_file(Client cntxt, Tablet *as, bstream *b, stream *out,
const char *csep, const char *rsep, char quote, lng skip, lng maxrow, int best,
bool from_stdin);
mal_export str TABLETcreate_bats(Tablet *as, BUN est);
mal_export str TABLETcollect(BAT **bats, Tablet *as);
mal_export str TABLETcollect_parts(BAT **bats, Tablet *as, BUN offset);
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
@@ -2649,7 +2649,7 @@ mvc_import_table_wrap(Client cntxt, MalB
if (fname != NULL && strcmp(str_nil, fname) == 0)
fname = NULL;
if (fname == NULL) {
- msg = mvc_import_table(cntxt, &b, be->mvc, be->mvc->scanner.rs,
t, tsep, rsep, ssep, ns, sz, offset, locked, besteffort);
+ msg = mvc_import_table(cntxt, &b, be->mvc, be->mvc->scanner.rs,
t, tsep, rsep, ssep, ns, sz, offset, locked, besteffort, true);
} else {
if (onclient) {
mnstr_write(be->mvc->scanner.ws, PROMPT3,
sizeof(PROMPT3)-1, 1);
@@ -2724,7 +2724,7 @@ mvc_import_table_wrap(Client cntxt, MalB
s = bstream_create(ss, 0x200000);
#endif
if (s != NULL) {
- msg = mvc_import_table(cntxt, &b, be->mvc, s, t, tsep,
rsep, ssep, ns, sz, offset, locked, besteffort);
+ msg = mvc_import_table(cntxt, &b, be->mvc, s, t, tsep,
rsep, ssep, ns, sz, offset, locked, besteffort, false);
if (onclient) {
mnstr_write(be->mvc->scanner.ws, PROMPT3,
sizeof(PROMPT3)-1, 1);
mnstr_flush(be->mvc->scanner.ws);
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
@@ -875,7 +875,7 @@ has_whitespace(const char *s)
}
str
-mvc_import_table(Client cntxt, BAT ***bats, mvc *m, bstream *bs, sql_table *t,
const char *sep, const char *rsep, const char *ssep, const char *ns, lng sz,
lng offset, int locked, int best)
+mvc_import_table(Client cntxt, BAT ***bats, mvc *m, bstream *bs, sql_table *t,
const char *sep, const char *rsep, const char *ssep, const char *ns, lng sz,
lng offset, int locked, int best, bool from_stdin)
{
int i = 0, j;
node *n;
@@ -1007,7 +1007,7 @@ mvc_import_table(Client cntxt, BAT ***ba
}
}
if ( (locked || (msg = TABLETcreate_bats(&as, (BUN) (sz < 0 ?
1000 : sz))) == MAL_SUCCEED) ){
- if (!sz || (SQLload_file(cntxt, &as, bs, out, sep,
rsep, ssep ? ssep[0] : 0, offset, sz, best) != BUN_NONE &&
+ if (!sz || (SQLload_file(cntxt, &as, bs, out, sep,
rsep, ssep ? ssep[0] : 0, offset, sz, best, from_stdin) != BUN_NONE &&
(best || !as.error))) {
*bats = (BAT**) GDKzalloc(sizeof(BAT *) *
as.nr_attrs);
if ( *bats == NULL){
diff --git a/sql/backends/monet5/sql_result.h b/sql/backends/monet5/sql_result.h
--- a/sql/backends/monet5/sql_result.h
+++ b/sql/backends/monet5/sql_result.h
@@ -25,7 +25,7 @@ extern int mvc_export_chunk(backend *b,
extern int mvc_export_prepare(mvc *c, stream *s, cq *q, str w);
-extern str mvc_import_table(Client cntxt, BAT ***bats, mvc *c, bstream *s,
sql_table *t, const char *sep, const char *rsep, const char *ssep, const char
*ns, lng nr, lng offset, int locked, int best);
+extern str mvc_import_table(Client cntxt, BAT ***bats, mvc *c, bstream *s,
sql_table *t, const char *sep, const char *rsep, const char *ssep, const char
*ns, lng nr, lng offset, int locked, int best, bool from_stdin);
extern int mvc_result_table(mvc *m, oid query_id, int nr_cols, int type, BAT
*order);
extern int mvc_result_column(mvc *m, char *tn, char *name, char *typename, int
digits, int scale, BAT *b);
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list