Changeset: 9786385f19cc for MonetDB URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=9786385f19cc Modified Files: bootstrap common/Makefile.ag configure.ag monetdb5/mal/Makefile.ag monetdb5/mal/mal_client.c monetdb5/mal/mal_client.h monetdb5/mal/mal_debugger.c monetdb5/mal/mal_import.c monetdb5/mal/mal_interpreter.c monetdb5/mal/mal_parser.c monetdb5/mal/mal_parser.h monetdb5/mal/mal_session.c monetdb5/mal/mal_session.h monetdb5/modules/mal/Makefile.ag monetdb5/modules/mal/mal_io.c monetdb5/modules/mal/mal_mapi.c monetdb5/modules/mal/remote.c monetdb5/optimizer/opt_pipes.c sql/backends/monet5/sql_scenario.c sql/server/sql_mvc.c sql/server/sql_mvc.h sql/server/sql_scan.c sql/server/sql_scan.h Branch: protocol Log Message:
Backed out changeset 9002fbfe0dac diffs (truncated from 1066 to 300 lines): diff --git a/bootstrap b/bootstrap --- a/bootstrap +++ b/bootstrap @@ -59,5 +59,3 @@ autoconf if [ -f buildtools/conf/install-sh -a ! -x buildtools/conf/install-sh ]; then chmod +x buildtools/conf/install-sh fi - -protoc-c common/protobuf/mhapi.proto --c_out common/protobuf diff --git a/common/Makefile.ag b/common/Makefile.ag --- a/common/Makefile.ag +++ b/common/Makefile.ag @@ -4,4 +4,4 @@ # # Copyright 1997 - July 2008 CWI, August 2008 - 2016 MonetDB B.V. -SUBDIRS = stream options utils protobuf +SUBDIRS = stream options utils diff --git a/configure.ag b/configure.ag --- a/configure.ag +++ b/configure.ag @@ -1641,51 +1641,6 @@ AM_CONDITIONAL([HAVE_LIBSNAPPY], [test x -dnl check for protobuf-c serialization library -org_have_protobuf=auto -have_protobuf=$org_have_protobuf -protobuf_CFLAGS="" -protobuf_LIBS="" -AC_ARG_WITH([protobuf], - [AS_HELP_STRING([--with-protobuf=DIR], - [protobuf library is installed in DIR])], - [have_protobuf="$withval"]) - -AS_CASE(["$have_protobuf"], - [yes|no|auto], [], - [ - protobuf_CFLAGS="-I$withval/include" - protobuf_LIBS="-L$withval/lib"]) - -AC_MSG_CHECKING([for protobuf]) -AS_VAR_IF([have_protobuf], [no], [], [ - save_CPPFLAGS="$CPPFLAGS" - CPPFLAGS="$CPPFLAGS $protobuf_CFLAGS" - save_LIBS="$LIBS" - LIBS="$LIBS $protobuf_LIBS -lprotobuf-c" - AC_LINK_IFELSE([AC_LANG_PROGRAM([[@%:@include <stdio.h> -@%:@include <protobuf-c/protobuf-c.h>]], [[(void)protobuf_c_version_number();]])], - protobuf_LIBS="$protobuf_LIBS -lprotobuf-c", - [ AS_VAR_IF([have_protobuf], [auto], [], [ - AC_MSG_ERROR([protobuf library not found])]) - have_protobuf=no - why_have_protobuf="(protobuf library not found)" ]) - LIBS="$save_LIBS" - CPPFLAGS="$save_CPPFLAGS"]) - -AS_VAR_IF([have_protobuf], [no], [], [ - AC_DEFINE([HAVE_LIBPROTOBUF], 1, [Define if you have the protobuf library]) - AC_MSG_RESULT([yes: $protobuf_LIBS])], [ - protobuf_CFLAGS="" - protobuf_LIBS="" - AC_MSG_RESULT([no])]) - -AC_SUBST([protobuf_CFLAGS]) -AC_SUBST([protobuf_LIBS]) -AM_CONDITIONAL([HAVE_LIBPROTOBUF], [test x$have_protobuf != xno]) - - - DL_LIBS="" AC_CHECK_LIB([dl], [dlopen], [DL_LIBS="-ldl" ] ) AC_SUBST([DL_LIBS]) @@ -3329,7 +3284,6 @@ for comp in \ 'pcre ' \ 'perl ' \ 'proj ' \ - 'protobuf ' \ 'pthread ' \ 'python2 ' \ 'python3 ' \ diff --git a/monetdb5/mal/Makefile.ag b/monetdb5/mal/Makefile.ag --- a/monetdb5/mal/Makefile.ag +++ b/monetdb5/mal/Makefile.ag @@ -6,7 +6,6 @@ INCLUDES = ../../common/options \ ../../common/stream \ - ../../common/protobuf \ ../../common/utils \ ../../clients/mapilib \ ../../gdk \ @@ -38,6 +37,7 @@ lib_mal = { mal_namespace.c mal_namespace.h \ mal_parser.c mal_parser.h \ mal_profiler.c mal_profiler.h \ + mal_readline.c mal_readline.h \ mal_resolve.c mal_resolve.h \ mal_sabaoth.c mal_sabaoth.h \ mal_scenario.c mal_scenario.h \ diff --git a/monetdb5/mal/mal_client.c b/monetdb5/mal/mal_client.c --- a/monetdb5/mal/mal_client.c +++ b/monetdb5/mal/mal_client.c @@ -42,6 +42,7 @@ /* (author) M.L. Kersten */ #include "monetdb_config.h" #include "mal_client.h" +#include "mal_readline.h" #include "mal_import.h" #include "mal_parser.h" #include "mal_namespace.h" @@ -93,7 +94,7 @@ MCinit(void) } int -MCpushClientInput(Client c, stream *new_input, int listing, char *prompt) +MCpushClientInput(Client c, bstream *new_input, int listing, char *prompt) { ClientInput *x = (ClientInput *) GDKmalloc(sizeof(ClientInput)); if (x == 0) @@ -118,7 +119,7 @@ MCpopClientInput(Client c) ClientInput *x = c->bak; if (c->fdin) { /* missing protection against closing stdin stream */ - (void) close_stream(c->fdin); + (void) bstream_destroy(c->fdin); } GDKfree(c->prompt); c->fdin = x->fdin; @@ -192,7 +193,7 @@ MCexitClient(Client c) assert(c->bak == NULL); if (c->fdin) { /* missing protection against closing stdin stream */ - (void) close_stream(c->fdin); + (void) bstream_destroy(c->fdin); } c->fdout = NULL; c->fdin = NULL; @@ -200,7 +201,7 @@ MCexitClient(Client c) } Client -MCinitClientRecord(Client c, oid user, stream *fin, stream *fout) +MCinitClientRecord(Client c, oid user, bstream *fin, stream *fout) { str prompt; @@ -211,7 +212,7 @@ MCinitClientRecord(Client c, oid user, s c->srcFile = NULL; c->blkmode = 0; - c->fdin = fin; // ? fin : bstream_create(GDKin, 0); + c->fdin = fin ? fin : bstream_create(GDKin, 0); c->yycur = 0; c->bak = NULL; @@ -265,7 +266,7 @@ MCinitClientRecord(Client c, oid user, s } Client -MCinitClient(oid user, stream *fin, stream *fout) +MCinitClient(oid user, bstream *fin, stream *fout) { Client c = NULL; @@ -523,16 +524,10 @@ MCawakeClient(int id) * The next statement block is to be read. Send a prompt to warn the * front-end to issue the request. */ - -// fixme: this will need to read a protocol message from the client and dump its contents into buf int MCreadClient(Client c) - { - assert(0); - (void) c; -#if 0 - buffer *in = &c->buf; + bstream *in = c->fdin; #ifdef MAL_CLIENT_DEBUG printf("# streamClient %d %d\n", c->idx, isa_block_stream(in->s)); @@ -543,15 +538,21 @@ MCreadClient(Client c) in->buf[in->pos] == ';' || !in->buf[in->pos])) in->pos++; - if (in->pos >= in->len) { + if (in->pos >= in->len || in->mode) { ssize_t rd, sum = 0; - // FIXME: + if (in->eof || !isa_block_stream(c->fdout)) { + if (!isa_block_stream(c->fdout) && c->promptlength > 0) + mnstr_write(c->fdout, c->prompt, c->promptlength, 1); + mnstr_flush(c->fdout); + in->eof = 0; + } while ((rd = bstream_next(in)) > 0 && !in->eof) { sum += rd; - + if (!in->mode) /* read one line at a time in line mode */ + break; } - { /* find last new line */ + if (in->mode) { /* find last new line */ char *p = in->buf + in->len - 1; while (p > in->buf && *p != '\n') { @@ -574,7 +575,7 @@ MCreadClient(Client c) #endif if (c->bak) { MCpopClientInput(c); - if (c->buf.buf == NULL) + if (c->fdin == NULL) return 0; return MCreadClient(c); } @@ -585,8 +586,6 @@ MCreadClient(Client c) printf("#%s\n", in->buf); #endif return 1; -#endif - return 42; } diff --git a/monetdb5/mal/mal_client.h b/monetdb5/mal/mal_client.h --- a/monetdb5/mal/mal_client.h +++ b/monetdb5/mal/mal_client.h @@ -41,7 +41,7 @@ enum clientmode { * initialization string. See the documentation on Scenarios. */ typedef struct CLIENT_INPUT { - stream *fdin; + bstream *fdin; int yycur; int listing; char *prompt; @@ -92,8 +92,7 @@ typedef struct CLIENT { * It will simply terminate after consuming the input buffer. */ str srcFile; /* NULL for stdin, or file name */ - stream *fdin; - buffer buf; + bstream *fdin; int yycur; /* the scanners current position */ /* * Keeping track of instructions executed is a valuable tool for @@ -192,8 +191,8 @@ mal_export ClientRec *mal_clients; mal_export int MCdefault; mal_export Client MCgetClient(int id); -mal_export Client MCinitClient(oid user, stream *fin, stream *fout); -mal_export Client MCinitClientRecord(Client c, oid user, stream *fin, stream *fout); +mal_export Client MCinitClient(oid user, bstream *fin, stream *fout); +mal_export Client MCinitClientRecord(Client c, oid user, bstream *fin, stream *fout); mal_export int MCinitClientThread(Client c); mal_export Client MCforkClient(Client father); mal_export void MCstopClients(Client c); @@ -202,7 +201,7 @@ mal_export int MCactiveClients(void); mal_export void MCcloseClient(Client c); mal_export str MCsuspendClient(int id); mal_export str MCawakeClient(int id); -mal_export int MCpushClientInput(Client c, stream *new_input, int listing, char *prompt); +mal_export int MCpushClientInput(Client c, bstream *new_input, int listing, char *prompt); mal_export int MCvalid(Client c); mal_export str PROFinitClient(Client c); diff --git a/monetdb5/mal/mal_debugger.c b/monetdb5/mal/mal_debugger.c --- a/monetdb5/mal/mal_debugger.c +++ b/monetdb5/mal/mal_debugger.c @@ -12,6 +12,7 @@ */ #include "monetdb_config.h" #include "mal.h" +#include "mal_readline.h" #include "mal_debugger.h" #include "mal_interpreter.h" /* for getArgReference() */ #include "mal_linker.h" /* for getAddress() */ @@ -385,7 +386,7 @@ mdbCommand(Client cntxt, MalBlkPtr mb, M int stepsize = 1000; char oldcmd[1024] = { 0 }; do { -// int r; + int r; if (p != NULL) { if (cntxt != mal_clients) /* help mclients with fake prompt */ @@ -408,17 +409,17 @@ retryRead: if (cntxt->mode == FINISHCLIENT) break; /* SQL patch, it should only react to Smessages, Xclose requests to be ignored */ - if (strncmp(cntxt->buf.buf, "Xclose", 6) == 0) { - cntxt->buf.pos = cntxt->buf.len; + if (strncmp(cntxt->fdin->buf, "Xclose", 6) == 0) { + cntxt->fdin->pos = cntxt->fdin->len; goto retryRead; } } _______________________________________________ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list