Changeset: 4281ea8b8699 for MonetDB URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=4281ea8b8699 Added Files: sql/server/rel_remote.c sql/server/rel_remote.h sql/test/Users/Tests/copyinto.stable.err sql/test/Users/Tests/copyinto.stable.out sql/test/miscellaneous/Tests/trace_test.stable.out Modified Files: clients/Tests/exports.stable.out common/stream/Makefile.ag common/stream/stream.c configure.ag monetdb5/mal/Tests/tst611.stable.err monetdb5/mal/mal.c monetdb5/mal/mal_client.c monetdb5/mal/mal_dataflow.c monetdb5/mal/mal_debugger.c monetdb5/mal/mal_interpreter.c monetdb5/mal/mal_interpreter.h monetdb5/mal/mal_module.c monetdb5/mal/mal_module.h monetdb5/mal/mal_resolve.c monetdb5/mal/mal_resolve.h monetdb5/mal/mal_runtime.c monetdb5/mal/mal_runtime.h monetdb5/mal/mal_stack.c monetdb5/mal/mal_stack.h monetdb5/mal/mal_type.c monetdb5/mal/mal_type.h monetdb5/modules/mal/clients.c monetdb5/optimizer/opt_mitosis.c monetdb5/optimizer/opt_pushselect.c sql/backends/monet5/rel_bin.c sql/backends/monet5/sql.c sql/backends/monet5/sql_gencode.c sql/backends/monet5/sql_gencode.h sql/backends/monet5/sql_statement.c sql/backends/monet5/sql_statement.h sql/common/sql_mem.c sql/common/sql_string.c sql/common/sql_string.h sql/include/sql_catalog.h sql/include/sql_mem.h sql/include/sql_relation.h sql/server/Makefile.ag sql/server/rel_distribute.h sql/server/rel_dump.c sql/server/rel_exp.c sql/server/rel_exp.h sql/server/rel_optimizer.c sql/server/rel_planner.c sql/server/rel_psm.c sql/server/rel_psm.h sql/server/rel_schema.c sql/server/rel_schema.h sql/server/rel_select.c sql/server/rel_select.h sql/server/rel_updates.c sql/server/rel_xml.c sql/server/sql_atom.c sql/server/sql_atom.h sql/server/sql_mvc.c sql/server/sql_mvc.h sql/server/sql_parser.y sql/server/sql_semantic.c sql/server/sql_semantic.h sql/server/sql_symbol.c sql/server/sql_symbol.h sql/storage/sql_catalog.c sql/test/BugTracker-2015/Tests/constant-random.Bug-3836.sql sql/test/BugTracker-2015/Tests/constant-random.Bug-3836.stable.out sql/test/Users/Tests/dropManyUsers.Bug-3764.stable.out sql/test/miscellaneous/Tests/All sql/test/miscellaneous/Tests/trace_test.sql testing/Mfilter.py Branch: leftmart Log Message:
Merge with default branch. diffs (truncated from 4046 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 @@ -2016,7 +2016,6 @@ void deriveModule(Module scope, str nme) malType destinationType(MalBlkPtr mb, InstrPtr p); str diffRef; str disconnectRef; -void displayVolume(Client cntxt, lng vol); str divRef; void dumpExceptionsToStream(stream *out, str msg); void dumpHelpTable(stream *f, Module s, str text, int flag); @@ -2031,7 +2030,6 @@ void expandMalBlk(MalBlkPtr mb, int line str expandRef; str exportOperationRef; str export_tableRef; -int fcnBinder(stream *out, Module scope, MalBlkPtr mb, InstrPtr p); str fcnDefinition(MalBlkPtr mb, InstrPtr p, str s, int flg, str base, size_t len); int findGDKtype(int type); int findInstruction(Module scope, MalBlkPtr mb, InstrPtr pci); @@ -2126,7 +2124,6 @@ str ilikethetasubselectRef; str ilikeuselectRef; void initHeartbeat(void); void initLibraries(void); -void initMALstack(MalBlkPtr mb, MalStkPtr stk); void initNamespace(void); void initParser(void); void initProfiler(void); @@ -2146,7 +2143,6 @@ str io_stderr(Client cntxt, MalBlkPtr mb str io_stdin(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci); str io_stdout(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci); int isAllScalar(MalBlkPtr mb, InstrPtr p); -int isAmbiguousType(int type); int isBlocking(InstrPtr p); int isDelta(InstrPtr q); int isDependent(InstrPtr p, InstrPtr q); @@ -2175,7 +2171,6 @@ int isSubJoin(InstrPtr q); int isSubSelect(InstrPtr q); int isTmpName(const char *n); int isTopn(InstrPtr q); -int isTypeName(str n); int isUnsafeFunction(InstrPtr q); int isUnsafeInstruction(InstrPtr q); int isUpdateInstruction(InstrPtr p); @@ -2293,7 +2288,6 @@ InstrPtr newStmt(MalBlkPtr mb, char *mod InstrPtr newStmt1(MalBlkPtr mb, str module, char *name); InstrPtr newStmt2(MalBlkPtr mb, str module, char *name); Symbol newSymbol(str nme, int kind); -str newTmpName(char tag, int i); int newTmpSink(MalBlkPtr mb, malType type); int newTmpVariable(MalBlkPtr mb, malType type); int newTypeVariable(MalBlkPtr mb, malType type); @@ -2376,7 +2370,6 @@ str rankRef; str rapiRef; int readConsole(Client cntxt); MalStkPtr reallocGlobalStack(MalStkPtr s, int cnt); -MalStkPtr reallocStack(MalStkPtr s, int cnt); str reconnectRef; MalBlkPtr recycleBlk; int recycleCacheLimit; @@ -2384,7 +2377,6 @@ str recycleRef; str reenterMAL(Client cntxt, MalBlkPtr mb, int startpc, int stoppc, MalStkPtr stk); str refineRef; str registerRef; -void releaseBAT(MalBlkPtr mb, MalStkPtr stk, int bid); str remapRef; str remoteRef; void removeDataflow(MalBlkPtr mb); @@ -2416,7 +2408,6 @@ void runtimeProfileBegin(Client cntxt, M void runtimeProfileExit(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci, RuntimeProfile prof); void runtimeProfileFinish(Client cntxt, MalBlkPtr mb); void runtimeProfileInit(Client cntxt, MalBlkPtr mb, MalStkPtr stk); -str safeguardStack(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci); int safetyBarrier(InstrPtr p, InstrPtr q); str schedulerRef; str selectNotNilRef; @@ -2443,7 +2434,6 @@ void showException(stream *out, enum mal void showFlowGraph(MalBlkPtr mb, MalStkPtr stk, str fname); void showHelp(Module m, str txt, stream *fs); void showMalBlkHistory(stream *out, MalBlkPtr mb); -void showModuleStatistics(stream *f, Module s); void showOptimizerHistory(void); void showOptimizerStep(str fnme, int i, int flg); void showScenario(stream *f, Scenario s); @@ -2519,7 +2509,6 @@ void unloadLibraries(void); str unlockRef; str unpackRef; str unpinRef; -void updateFootPrint(MalBlkPtr mb, MalStkPtr stk, int varid); str updateRef; void updateScenario(str scen, str nme, MALfcn fcn); str userRef; diff --git a/common/stream/Makefile.ag b/common/stream/Makefile.ag --- a/common/stream/Makefile.ag +++ b/common/stream/Makefile.ag @@ -10,6 +10,7 @@ MTSAFE INCLUDES = $(zlib_CFLAGS) \ $(BZ_CFLAGS) \ + $(liblzma_CFLAGS) \ $(openssl_CFLAGS) \ $(curl_CFLAGS) @@ -19,6 +20,7 @@ lib_stream = { LIBS = $(SOCKET_LIBS) \ $(zlib_LIBS) \ $(BZ_LIBS) \ + $(liblzma_LIBS) \ $(openssl_LIBS) \ $(curl_LIBS) \ $(LTLIBICONV) diff --git a/common/stream/stream.c b/common/stream/stream.c --- a/common/stream/stream.c +++ b/common/stream/stream.c @@ -90,6 +90,9 @@ #ifdef HAVE_LIBBZ2 #include <bzlib.h> #endif +#ifdef HAVE_LIBLZMA +#include <lzma.h> +#endif #ifdef HAVE_ICONV #ifdef HAVE_ICONV_H @@ -1389,6 +1392,295 @@ open_bzwastream(const char *filename, co #endif /* ------------------------------------------------------------------ */ +/* streams working on a lzma-compressed disk file */ + +#ifdef HAVE_LIBLZMA +#define XZBUFSIZ 64*1024 +typedef struct xz_stream { + FILE *fp; + lzma_stream strm; + int todo; + uint8_t buf[XZBUFSIZ]; +} xz_stream; + +static ssize_t +stream_xzread(stream *s, void *buf, size_t elmsize, size_t cnt) +{ + xz_stream *xz = s->stream_data.p; + size_t size = elmsize * cnt, origsize = size, ressize = 0; + uint8_t *outbuf = buf; + lzma_action action = LZMA_RUN; + + if (xz == NULL) { + s->errnr = MNSTR_READ_ERROR; + return -1; + } + + xz->strm.next_in = xz->buf; + xz->strm.avail_in = xz->todo; + xz->strm.next_out = outbuf; + xz->strm.avail_out = size; + while (size && (xz->strm.avail_in || !feof(xz->fp))) { + lzma_ret ret; + size_t sz = (size>XZBUFSIZ) ? XZBUFSIZ : size; + + if (!xz->strm.avail_in && + (xz->strm.avail_in = fread(xz->buf, 1, sz, xz->fp)) == 0) { + s->errnr = MNSTR_READ_ERROR; + return -1; + } + xz->strm.next_in = xz->buf; + if (feof(xz->fp)) + action = LZMA_FINISH; + ret = lzma_code(&xz->strm, action); + if (xz->strm.avail_out == 0 || ret == LZMA_STREAM_END) { + origsize -= xz->strm.avail_out; /* remaining space */ + xz->todo = xz->strm.avail_in; + if (xz->todo > 0) + memmove(xz->buf, xz->strm.next_in, xz->todo); + outbuf[origsize] = 0; /* add EOS */ + ressize = origsize; + break; + } + if (ret != LZMA_OK) { + s->errnr = MNSTR_READ_ERROR; + return -1; + } + } + if (ressize) { +#ifdef WIN32 + /* on Windows when in text mode, convert \r\n line + * endings to \n */ + if (s->type == ST_ASCII) { + char *p1, *p2, *pe; + + p1 = buf; + pe = p1 + ressize; + while (p1 < pe && *p1 != '\r') + p1++; + p2 = p1; + while (p1 < pe) { + if (*p1 == '\r' && p1[1] == '\n') + ressize--; + else + *p2++ = *p1; + p1++; + } + } +#endif + return (ssize_t) (ressize / elmsize); + } + return 0; +} + +static ssize_t +stream_xzwrite(stream *s, const void *buf, size_t elmsize, size_t cnt) +{ + xz_stream *xz = s->stream_data.p; + size_t size = elmsize * cnt; + lzma_action action = LZMA_RUN; + + if (xz == NULL) { + s->errnr = MNSTR_WRITE_ERROR; + return -1; + } + + xz->strm.next_in = buf; + xz->strm.avail_in = size; + xz->strm.next_out = xz->buf; + xz->strm.avail_out = XZBUFSIZ; + + size = 0; + while (xz->strm.avail_in) { + size_t sz = 0, isz = xz->strm.avail_in; + + lzma_ret ret = lzma_code(&xz->strm, action); + if (xz->strm.avail_out == 0 || ret != LZMA_OK) { + s->errnr = MNSTR_WRITE_ERROR; + return -1; + } + sz = XZBUFSIZ - xz->strm.avail_out; + if (fwrite(xz->buf, 1, sz, xz->fp) != sz) { + s->errnr = MNSTR_WRITE_ERROR; + return -1; + } + assert(xz->strm.avail_in == 0); + size += isz; + xz->strm.next_out = xz->buf; + xz->strm.avail_out = XZBUFSIZ; + } + if (size) + return (ssize_t) (size / elmsize); + return (ssize_t) cnt; +} + +static void +stream_xzclose(stream *s) +{ + xz_stream *xz = s->stream_data.p; + + if (xz) { + if (s->access == ST_WRITE) { + lzma_ret ret = lzma_code(&xz->strm, LZMA_FINISH); + + if (xz->strm.avail_out && ret == LZMA_STREAM_END) { + size_t sz = XZBUFSIZ - xz->strm.avail_out; + if (fwrite(xz->buf, 1, sz, xz->fp) != sz) + s->errnr = MNSTR_WRITE_ERROR; + } + } + fflush(xz->fp); + fclose(xz->fp); + lzma_end(&xz->strm); + free(xz); + } + s->stream_data.p = NULL; +} + +static int +stream_xzflush(stream *s) +{ + xz_stream *xz = s->stream_data.p; + + if (xz == NULL) + return -1; + if (s->access == ST_WRITE && fflush(xz->fp)) + return -1; + return 0; +} + +static stream * +open_xzstream(const char *filename, const char *flags) +{ + stream *s; + xz_stream *xz; + uint32_t preset = 0; + + if ((xz = malloc(sizeof(struct xz_stream))) == NULL) + return NULL; + if (xz) + memset(xz, 0, sizeof(xz_stream)); + if (((flags[0] == 'r' && + lzma_stream_decoder(&xz->strm, UINT64_MAX, LZMA_CONCATENATED) != LZMA_OK)) || + (flags[0] == 'w' && + lzma_easy_encoder(&xz->strm, preset, LZMA_CHECK_CRC64) != LZMA_OK)) { + free(xz); _______________________________________________ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list