Changeset: f2a03a0197db for MonetDB URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=f2a03a0197db Modified Files: MacOSX/MonetDB.pkgproj NT/monetdb_config.h.in clients/mapiclient/ReadlineTools.c clients/mapiclient/Tests/mclient--help.stable.err clients/mapiclient/Tests/mclient--help.stable.err.Windows clients/mapiclient/dump.c clients/mapiclient/stethoscope.c clients/mapiclient/tachograph.c clients/mapiclient/tomograph.c clients/mapilib/mapi.c clients/odbc/driver/SQLExecute.c common/options/monet_options.c common/stream/stream.c common/utils/mutils.c gdk/gdk_bbp.c testing/Mtest.py.in Branch: embedded Log Message:
merge with default diffs (truncated from 716 to 300 lines): diff --git a/MacOSX/MonetDB.pkgproj b/MacOSX/MonetDB.pkgproj --- a/MacOSX/MonetDB.pkgproj +++ b/MacOSX/MonetDB.pkgproj @@ -504,7 +504,7 @@ <key>CONCLUSION_ACTION</key> <integer>0</integer> <key>IDENTIFIER</key> - <string>com.monetdbsolutions.pkg.monetdb</string> + <string>org.monetdb.pkg.monetdb</string> <key>NAME</key> <string>MonetDB</string> <key>OVERWRITE_PERMISSIONS</key> @@ -815,13 +815,6 @@ <key>PATH_TYPE</key> <integer>1</integer> </dict> - <key>CERTIFICATE</key> - <dict> - <key>NAME</key> - <string>Developer ID Installer: MonetDB Solutions B.V. (YEJLE7L8A4)</string> - <key>PATH</key> - <string>/Users/sjoerd/Library/Keychains/login.keychain</string> - </dict> <key>EXCLUDED_FILES</key> <array> <dict> @@ -991,7 +984,7 @@ </dict> </array> <key>NAME</key> - <string>MonetDB</string> + <string>MonetDB-unsigned</string> </dict> </dict> <key>TYPE</key> diff --git a/NT/monetdb_config.h.in b/NT/monetdb_config.h.in --- a/NT/monetdb_config.h.in +++ b/NT/monetdb_config.h.in @@ -49,6 +49,14 @@ #include <stddef.h> #include <ws2tcpip.h> +#include <sys/types.h> +#include <stdio.h> /* NULL, printf etc. */ +#include <stdlib.h> +#include <errno.h> +#include <stdarg.h> /* va_alist.. */ + +#include <assert.h> + /* indicate to sqltypes.h that windows.h has already been included and that it doesn't have to define Windows constants */ #define ALREADY_HAVE_WINDOWS_TYPE 1 @@ -995,9 +1003,37 @@ /* #undef size_t */ #if _MSC_VER < 1900 -#ifndef snprintf -#define snprintf _snprintf -#endif +#define snprintf c99_snprintf +#define vsnprintf c99_vsnprintf + +/* Microsoft _snprintf returns -1 and does not null-terminate when the + * buffer is too small, so work around that */ + +static inline int +c99_vsnprintf(char *outBuf, size_t size, const char *format, va_list ap) +{ + int count = -1; + + if (size != 0) + count = _vsnprintf_s(outBuf, size, _TRUNCATE, format, ap); + if (count == -1) + count = _vscprintf(format, ap); + + return count; +} + +static inline int +c99_snprintf(char *outBuf, size_t size, const char *format, ...) +{ + int count; + va_list ap; + + va_start(ap, format); + count = c99_vsnprintf(outBuf, size, format, ap); + va_end(ap); + + return count; +} #endif /* type used by connect */ @@ -1020,20 +1056,6 @@ typedef unsigned short uint16_t; typedef unsigned int uint32_t; typedef unsigned __int64 uint64_t; -#if _MSC_VER < 1500 -#ifndef vsnprintf -#define vsnprintf _vsnprintf -#endif -#endif - -#include <sys/types.h> -#include <stdio.h> /* NULL, printf etc. */ -#include <stdlib.h> -#include <errno.h> -#include <stdarg.h> /* va_alist.. */ - -#include <assert.h> - /* normally defined in stdbool.h, but that doesn't exist on Windows */ #define true 1 #define false 0 diff --git a/clients/mapiclient/ReadlineTools.c b/clients/mapiclient/ReadlineTools.c --- a/clients/mapiclient/ReadlineTools.c +++ b/clients/mapiclient/ReadlineTools.c @@ -61,12 +61,16 @@ sql_tablename_generator(const char *text static MapiHdl table_hdl; if (!state) { - char query[512]; + char *query; seekpos = 0; len = strlen(text); - snprintf(query, sizeof(query), "SELECT t.\"name\", s.\"name\" FROM \"sys\".\"tables\" t, \"sys\".\"schemas\" s where t.schema_id = s.id AND t.\"name\" like '%s%%'", text); - if ((table_hdl = mapi_query(_mid, query)) == NULL || mapi_error(_mid)) { + if ((query = malloc(len + 128)) == NULL) + return NULL; + snprintf(query, len + 128, "SELECT t.\"name\", s.\"name\" FROM \"sys\".\"tables\" t, \"sys\".\"schemas\" s where t.schema_id = s.id AND t.\"name\" like '%s%%'", text); + table_hdl = mapi_query(_mid, query); + free(query); + if (table_hdl == NULL || mapi_error(_mid)) { if (table_hdl) { mapi_explain_query(table_hdl, stderr); mapi_close_handle(table_hdl); @@ -176,7 +180,7 @@ static char *mal_commands[] = { static int mal_help(int cnt, int key) { - char *name, *c, buf[512]; + char *name, *c, *buf; int seekpos = 0, rowcount; MapiHdl table_hdl; @@ -188,8 +192,12 @@ mal_help(int cnt, int key) c--; while (c > rl_line_buffer && !isspace(*c)) c--; - snprintf(buf, sizeof(buf), "manual.help(\"%s\");", c); - if ((table_hdl = mapi_query(_mid, buf)) == NULL || mapi_error(_mid)) { + if ((buf = malloc(strlen(c) + 20)) == NULL) + return 0; + snprintf(buf, strlen(c) + 20, "manual.help(\"%s\");", c); + table_hdl = mapi_query(_mid, buf); + free(buf); + if (table_hdl == NULL || mapi_error(_mid)) { if (table_hdl) { mapi_explain_query(table_hdl, stderr); mapi_close_handle(table_hdl); @@ -220,7 +228,7 @@ mal_command_generator(const char *text, static int idx; static int seekpos, len, rowcount; static MapiHdl table_hdl; - char *name, buf[512]; + char *name, *buf; /* we pick our own portion of the linebuffer */ text = rl_line_buffer + strlen(rl_line_buffer) - 1; @@ -250,14 +258,18 @@ mal_command_generator(const char *text, text = c + 2; while (isspace((int) *text)) text++; + if ((buf = malloc(strlen(text) + 32)) == NULL) + return NULL; if (strchr(text, '.') == NULL) - snprintf(buf, sizeof(buf), + snprintf(buf, strlen(text) + 32, "manual.completion(\"%s.*(\");", text); else - snprintf(buf, sizeof(buf), + snprintf(buf, strlen(text) + 32, "manual.completion(\"%s(\");", text); seekpos = 0; - if ((table_hdl = mapi_query(_mid, buf)) == NULL || mapi_error(_mid)) { + table_hdl = mapi_query(_mid, buf); + free(buf); + if (table_hdl == NULL || mapi_error(_mid)) { if (table_hdl) { mapi_explain_query(table_hdl, stderr); mapi_close_handle(table_hdl); diff --git a/clients/mapiclient/Tests/mclient--help.stable.err b/clients/mapiclient/Tests/mclient--help.stable.err --- a/clients/mapiclient/Tests/mclient--help.stable.err +++ b/clients/mapiclient/Tests/mclient--help.stable.err @@ -38,7 +38,6 @@ SQL specific opions -w nr | --width=nr for pagination -D | --dump create an SQL dump -N | --inserts use INSERT INTO statements when dumping - -P | --progress show progress bar The file argument can be - for stdin # 18:57:57 > diff --git a/clients/mapiclient/Tests/mclient--help.stable.err.Windows b/clients/mapiclient/Tests/mclient--help.stable.err.Windows --- a/clients/mapiclient/Tests/mclient--help.stable.err.Windows +++ b/clients/mapiclient/Tests/mclient--help.stable.err.Windows @@ -37,7 +37,6 @@ SQL specific opions -w nr | --width=nr for pagination -D | --dump create an SQL dump -N | --inserts use INSERT INTO statements when dumping - -P | --progress show progress bar The file argument can be - for stdin # 18:57:57 > diff --git a/clients/mapiclient/dump.c b/clients/mapiclient/dump.c --- a/clients/mapiclient/dump.c +++ b/clients/mapiclient/dump.c @@ -212,7 +212,7 @@ dump_foreign_keys(Mapi mid, const char * "fkt.name = '%s' " "ORDER BY fkk.name, nr", schema, tname); } else if (tid != NULL) { - maxquerylen = 1024; + maxquerylen = 1024 + strlen(tid); query = malloc(maxquerylen); snprintf(query, maxquerylen, "SELECT ps.name, " /* 0 */ @@ -529,6 +529,8 @@ dump_column_definition(Mapi mid, stream maxquerylen = 1024; if (tid == NULL) maxquerylen += strlen(tname) + strlen(schema); + else + maxquerylen += strlen(tid); if ((query = malloc(maxquerylen)) == NULL) goto bailout; diff --git a/clients/mapiclient/stethoscope.c b/clients/mapiclient/stethoscope.c --- a/clients/mapiclient/stethoscope.c +++ b/clients/mapiclient/stethoscope.c @@ -110,14 +110,14 @@ int main(int argc, char **argv) { ssize_t n; - size_t len; + size_t len, buflen; char *host = NULL; int portnr = 0; char *dbname = NULL; char *uri = NULL; char *user = NULL; char *password = NULL; - char buf[BUFSIZ], *e, *response; + char buf[BUFSIZ], *buffer, *e, *response; int line = 0; FILE *trace = NULL; @@ -268,11 +268,17 @@ main(int argc, char **argv) fprintf(stderr,"Could not create trace file\n"); len = 0; - while ((n = mnstr_read(conn, buf + len, 1, BUFSIZ - len)) > 0) { - buf[len + n] = 0; + buflen = BUFSIZ; + buffer = (char *) malloc(buflen); + if( buffer == NULL){ + fprintf(stderr,"Could not create input buffer\n"); + exit(-1); + } + while ((n = mnstr_read(conn, buffer + len, 1, buflen - len)) > 0) { + buffer[len + n] = 0; if( trace) - fprintf(trace,"%s",buf); - response = buf; + fprintf(trace,"%s",buffer); + response = buffer; while ((e = strchr(response, '\n')) != NULL) { *e = 0; printf("%s\n", response); @@ -281,12 +287,22 @@ main(int argc, char **argv) } response = e + 1; } + /* handle the case that the line is not yet completed */ + if( response == buffer){ + char *new = (char *) realloc(buffer, buflen + BUFSIZ); + if( new == NULL){ + fprintf(stderr,"Could not extend input buffer\n"); + exit(-1); + } + buffer = new; + buflen += BUFSIZ; + } /* handle last line in buffer */ if (*response) { if (debug) printf("LASTLINE:%s", response); len = strlen(response); - strncpy(buf, response, len + 1); + strncpy(buffer, response, len + 1); } else _______________________________________________ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list