Changeset: 9002fbfe0dac for MonetDB URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=9002fbfe0dac 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:
protobuf prototype and bstream zapping diffs (truncated from 1067 to 300 lines): diff --git a/bootstrap b/bootstrap --- a/bootstrap +++ b/bootstrap @@ -59,3 +59,5 @@ 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 +SUBDIRS = stream options utils protobuf diff --git a/configure.ag b/configure.ag --- a/configure.ag +++ b/configure.ag @@ -1641,6 +1641,51 @@ 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]) @@ -3284,6 +3329,7 @@ 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,6 +6,7 @@ INCLUDES = ../../common/options \ ../../common/stream \ + ../../common/protobuf \ ../../common/utils \ ../../clients/mapilib \ ../../gdk \ @@ -37,7 +38,6 @@ 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,7 +42,6 @@ /* (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" @@ -94,7 +93,7 @@ MCinit(void) } int -MCpushClientInput(Client c, bstream *new_input, int listing, char *prompt) +MCpushClientInput(Client c, stream *new_input, int listing, char *prompt) { ClientInput *x = (ClientInput *) GDKmalloc(sizeof(ClientInput)); if (x == 0) @@ -119,7 +118,7 @@ MCpopClientInput(Client c) ClientInput *x = c->bak; if (c->fdin) { /* missing protection against closing stdin stream */ - (void) bstream_destroy(c->fdin); + (void) close_stream(c->fdin); } GDKfree(c->prompt); c->fdin = x->fdin; @@ -193,7 +192,7 @@ MCexitClient(Client c) assert(c->bak == NULL); if (c->fdin) { /* missing protection against closing stdin stream */ - (void) bstream_destroy(c->fdin); + (void) close_stream(c->fdin); } c->fdout = NULL; c->fdin = NULL; @@ -201,7 +200,7 @@ MCexitClient(Client c) } Client -MCinitClientRecord(Client c, oid user, bstream *fin, stream *fout) +MCinitClientRecord(Client c, oid user, stream *fin, stream *fout) { str prompt; @@ -212,7 +211,7 @@ MCinitClientRecord(Client c, oid user, b 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; @@ -266,7 +265,7 @@ MCinitClientRecord(Client c, oid user, b } Client -MCinitClient(oid user, bstream *fin, stream *fout) +MCinitClient(oid user, stream *fin, stream *fout) { Client c = NULL; @@ -524,10 +523,16 @@ 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) + { - bstream *in = c->fdin; + assert(0); + (void) c; +#if 0 + buffer *in = &c->buf; #ifdef MAL_CLIENT_DEBUG printf("# streamClient %d %d\n", c->idx, isa_block_stream(in->s)); @@ -538,21 +543,15 @@ MCreadClient(Client c) in->buf[in->pos] == ';' || !in->buf[in->pos])) in->pos++; - if (in->pos >= in->len || in->mode) { + if (in->pos >= in->len) { ssize_t rd, sum = 0; - 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; - } + // FIXME: while ((rd = bstream_next(in)) > 0 && !in->eof) { sum += rd; - if (!in->mode) /* read one line at a time in line mode */ - break; + } - if (in->mode) { /* find last new line */ + { /* find last new line */ char *p = in->buf + in->len - 1; while (p > in->buf && *p != '\n') { @@ -575,7 +574,7 @@ MCreadClient(Client c) #endif if (c->bak) { MCpopClientInput(c); - if (c->fdin == NULL) + if (c->buf.buf == NULL) return 0; return MCreadClient(c); } @@ -586,6 +585,8 @@ 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 { - bstream *fdin; + stream *fdin; int yycur; int listing; char *prompt; @@ -92,7 +92,8 @@ typedef struct CLIENT { * It will simply terminate after consuming the input buffer. */ str srcFile; /* NULL for stdin, or file name */ - bstream *fdin; + stream *fdin; + buffer buf; int yycur; /* the scanners current position */ /* * Keeping track of instructions executed is a valuable tool for @@ -191,8 +192,8 @@ mal_export ClientRec *mal_clients; mal_export int MCdefault; mal_export Client MCgetClient(int id); -mal_export Client MCinitClient(oid user, bstream *fin, stream *fout); -mal_export Client MCinitClientRecord(Client c, oid user, bstream *fin, stream *fout); +mal_export Client MCinitClient(oid user, stream *fin, stream *fout); +mal_export Client MCinitClientRecord(Client c, oid user, stream *fin, stream *fout); mal_export int MCinitClientThread(Client c); mal_export Client MCforkClient(Client father); mal_export void MCstopClients(Client c); @@ -201,7 +202,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, bstream *new_input, int listing, char *prompt); +mal_export int MCpushClientInput(Client c, stream *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,7 +12,6 @@ */ #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() */ @@ -386,7 +385,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 */ @@ -409,17 +408,17 @@ retryRead: if (cntxt->mode == FINISHCLIENT) break; /* SQL patch, it should only react to Smessages, Xclose requests to be ignored */ - if (strncmp(cntxt->fdin->buf, "Xclose", 6) == 0) { - cntxt->fdin->pos = cntxt->fdin->len; + if (strncmp(cntxt->buf.buf, "Xclose", 6) == 0) { + cntxt->buf.pos = cntxt->buf.len; goto retryRead; } } _______________________________________________ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list