Changeset: ece709d3b8a0 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=ece709d3b8a0 Modified Files: monetdb5/modules/mal/mal_mapi.c sql/backends/monet5/sql.c sql/backends/monet5/sql.mal Branch: Apr2019 Log Message:
approved output diffs (truncated from 567 to 300 lines): diff --git a/monetdb5/modules/mal/mal_mapi.c b/monetdb5/modules/mal/mal_mapi.c --- a/monetdb5/modules/mal/mal_mapi.c +++ b/monetdb5/modules/mal/mal_mapi.c @@ -290,11 +290,9 @@ SERVERlistenThread(SOCKET *Sock) MT_Id tid; stream *s; - if (*Sock) { - sock = Sock[0]; - usock = Sock[1]; - GDKfree(Sock); - } + sock = Sock[0]; + usock = Sock[1]; + GDKfree(Sock); (void) ATOMIC_INC(&nlistener); @@ -508,7 +506,9 @@ error: * hostname address is used, to make the info usable for servers outside * localhost. */ -static void SERVERannounce(struct in_addr addr, int port, str usockfile) { +static void +SERVERannounce(struct in_addr addr, int port, const char *usockfile) +{ str buf; char host[128]; @@ -546,7 +546,7 @@ static void SERVERannounce(struct in_add } static str -SERVERlisten(int *Port, str *Usockfile, int *Maxusers) +SERVERlisten(int port, const char *usockfile, int maxusers) { struct sockaddr_in server; SOCKET sock = INVALID_SOCKET; @@ -561,9 +561,6 @@ SERVERlisten(int *Port, str *Usockfile, int on = 1; int i = 0; MT_Id pid; - int port; - int maxusers; - char *usockfile; #ifdef DEBUG_SERVER char msg[512], host[512]; Client cntxt= mal_clients; @@ -577,29 +574,18 @@ SERVERlisten(int *Port, str *Usockfile, return MAL_SUCCEED; } - psock = GDKmalloc(sizeof(SOCKET) * 3); + psock = GDKmalloc(sizeof(SOCKET) * 2); if (psock == NULL) throw(MAL,"mal_mapi.listen", SQLSTATE(HY001) MAL_MALLOC_FAIL); - port = *Port; - if (Usockfile == NULL || *Usockfile == 0 || - *Usockfile[0] == '\0' || strcmp(*Usockfile, str_nil) == 0) - { + if (usockfile == NULL || strcmp(usockfile, str_nil) == 0) { usockfile = NULL; } else { -#ifdef HAVE_SYS_UN_H - usockfile = GDKstrdup(*Usockfile); - if (usockfile == NULL) { - GDKfree(psock); - throw(MAL,"mal_mapi.listen", SQLSTATE(HY001) MAL_MALLOC_FAIL); - } -#else - usockfile = NULL; +#ifndef HAVE_SYS_UN_H GDKfree(psock); throw(IO, "mal_mapi.listen", OPERATION_FAILED ": UNIX domain sockets are not supported"); #endif } - maxusers = *Maxusers; maxusers = (maxusers ? maxusers : SERVERMAXUSERS); if (port <= 0 && usockfile == NULL) { @@ -609,7 +595,6 @@ SERVERlisten(int *Port, str *Usockfile, if (port > 65535) { GDKfree(psock); - GDKfree(usockfile); throw(ILLARG, "mal_mapi.listen", OPERATION_FAILED ": port number should be between 1 and 65535"); } @@ -622,7 +607,6 @@ SERVERlisten(int *Port, str *Usockfile, if (sock == INVALID_SOCKET) { int e = errno; GDKfree(psock); - GDKfree(usockfile); errno = e; throw(IO, "mal_mapi.listen", OPERATION_FAILED ": creation of stream socket failed: %s", @@ -644,7 +628,6 @@ SERVERlisten(int *Port, str *Usockfile, const char *err = strerror(errno); #endif GDKfree(psock); - GDKfree(usockfile); closesocket(sock); throw(IO, "mal_mapi.listen", OPERATION_FAILED ": setsockptr failed %s", err); } @@ -678,7 +661,6 @@ SERVERlisten(int *Port, str *Usockfile, } closesocket(sock); GDKfree(psock); - GDKfree(usockfile); errno = e; throw(IO, "mal_mapi.listen", OPERATION_FAILED ": bind to stream socket port %d " @@ -698,7 +680,6 @@ SERVERlisten(int *Port, str *Usockfile, int e = errno; closesocket(sock); GDKfree(psock); - GDKfree(usockfile); errno = e; throw(IO, "mal_mapi.listen", OPERATION_FAILED ": failed getting socket name: %s", @@ -713,7 +694,6 @@ SERVERlisten(int *Port, str *Usockfile, int e = errno; closesocket(sock); GDKfree(psock); - GDKfree(usockfile); errno = e; throw(IO, "mal_mapi.listen", OPERATION_FAILED ": failed to set socket to listen %s", @@ -727,6 +707,19 @@ SERVERlisten(int *Port, str *Usockfile, } #ifdef HAVE_SYS_UN_H if (usockfile) { + /* prevent silent truncation, sun_path is typically around 108 + * chars long :/ */ + if (strlen(usockfile) >= sizeof(userver.sun_path)) { + char *e; + if (sock != INVALID_SOCKET) + closesocket(sock); + GDKfree(psock); + e = createException(MAL, "mal_mapi.listen", + OPERATION_FAILED ": UNIX socket path too long: %s", + usockfile); + return e; + } + usock = socket(AF_UNIX, SOCK_STREAM #ifdef SOCK_CLOEXEC | SOCK_CLOEXEC @@ -735,7 +728,6 @@ SERVERlisten(int *Port, str *Usockfile, if (usock == INVALID_SOCKET ) { int e = errno; GDKfree(psock); - GDKfree(usockfile); errno = e; if (sock != INVALID_SOCKET) closesocket(sock); @@ -752,21 +744,6 @@ SERVERlisten(int *Port, str *Usockfile, (void) fcntl(usock, F_SETFD, FD_CLOEXEC); #endif - /* prevent silent truncation, sun_path is typically around 108 - * chars long :/ */ - if (strlen(usockfile) >= sizeof(userver.sun_path)) { - char *e; - if (sock != INVALID_SOCKET) - closesocket(sock); - closesocket(usock); - GDKfree(psock); - e = createException(MAL, "mal_mapi.listen", - OPERATION_FAILED ": UNIX socket path too long: %s", - usockfile); - GDKfree(usockfile); - return e; - } - userver.sun_family = AF_UNIX; strncpy(userver.sun_path, usockfile, sizeof(userver.sun_path)); userver.sun_path[sizeof(userver.sun_path) - 1] = 0; @@ -777,7 +754,6 @@ SERVERlisten(int *Port, str *Usockfile, if (sock != INVALID_SOCKET) closesocket(sock); closesocket(usock); - GDKfree(usockfile); GDKfree(psock); return e; } @@ -800,7 +776,6 @@ SERVERlisten(int *Port, str *Usockfile, strerror(errno) #endif ); - GDKfree(usockfile); return e; } if(listen(usock, maxusers) == SOCKET_ERROR) { @@ -822,7 +797,6 @@ SERVERlisten(int *Port, str *Usockfile, strerror(errno) #endif ); - GDKfree(usockfile); return e; } } @@ -838,7 +812,6 @@ SERVERlisten(int *Port, str *Usockfile, #else psock[1] = INVALID_SOCKET; #endif - psock[2] = INVALID_SOCKET; if (MT_create_thread(&pid, (void (*)(void *)) SERVERlistenThread, psock, MT_THR_DETACHED, "listenThread") != 0) { if (sock != INVALID_SOCKET) @@ -848,8 +821,6 @@ SERVERlisten(int *Port, str *Usockfile, closesocket(usock); #endif GDKfree(psock); - if (usockfile) - GDKfree(usockfile); throw(MAL, "mal_mapi.listen", OPERATION_FAILED ": starting thread failed"); } #ifdef DEBUG_SERVER @@ -863,8 +834,6 @@ SERVERlisten(int *Port, str *Usockfile, srand((unsigned int) GDKusec()); SERVERannounce(server.sin_addr, port, usockfile); - if (usockfile) - GDKfree(usockfile); return MAL_SUCCEED; } @@ -880,32 +849,27 @@ SERVERlisten_default(int *ret) { int port = SERVERPORT; str p; - int maxusers = SERVERMAXUSERS; (void) ret; p = GDKgetenv("mapi_port"); if (p) port = (int) strtol(p, NULL, 10); p = GDKgetenv("mapi_usock"); - return SERVERlisten(&port, &p, &maxusers); + return SERVERlisten(port, p, SERVERMAXUSERS); } str SERVERlisten_usock(int *ret, str *usock) { - int maxusers = SERVERMAXUSERS; (void) ret; - return SERVERlisten(0, usock, &maxusers); + return SERVERlisten(0, usock ? *usock : NULL, SERVERMAXUSERS); } str SERVERlisten_port(int *ret, int *pid) { - int port = *pid; - int maxusers = SERVERMAXUSERS; - (void) ret; - return SERVERlisten(&port, 0, &maxusers); + return SERVERlisten(*pid, NULL, SERVERMAXUSERS); } /* * The internet connection listener may be terminated from the server console, 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 @@ -1106,9 +1106,9 @@ mvc_bind_wrap(Client cntxt, MalBlkPtr mb str mvc_delta_values(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci) { - const char *sname = *getArgReference_str(stk, pci, 7); - const char *tname = *getArgReference_str(stk, pci, 8); - const char *cname = *getArgReference_str(stk, pci, 9); + const char *sname = *getArgReference_str(stk, pci, 7), + *tname = (pci->argc > 8) ? *getArgReference_str(stk, pci, 8) : NULL, + *cname = (pci->argc > 9) ? *getArgReference_str(stk, pci, 9) : NULL; mvc *m; str msg = MAL_SUCCEED; BAT *col1 = NULL, *col2 = NULL, *col3 = NULL, *col4 = NULL, *col5 = NULL, *col6 = NULL, *col7 = NULL; @@ -1123,93 +1123,202 @@ mvc_delta_values(Client cntxt, MalBlkPtr sql_schema *s = NULL; sql_table *t = NULL; sql_column *c = NULL; + node *n; bool cleared; int level = 0; - lng all, readonly, inserted, updates, deletes; + lng nrows = 0, all, readonly, inserted, updates, deletes; if ((msg = getSQLContext(cntxt, mb, &m, NULL)) != NULL) goto cleanup; if ((msg = checkSQLContext(cntxt)) != NULL) goto cleanup; - if (!sname || strcmp(sname, str_nil) == 0 || *sname == '\0') - throw(SQL, "sql.delta", SQLSTATE(3F000) "Invalid schema name"); - if (!tname || strcmp(tname, str_nil) == 0 || *tname == '\0') - throw(SQL, "sql.delta", SQLSTATE(3F000) "Invalid table name"); _______________________________________________ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list