Changeset: 2e4687cc809e for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=2e4687cc809e Added Files: clients/odbc/driver/ODBCQueries.h monetdb5/modules/mal/Tests/remote13.stable.err monetdb5/modules/mal/Tests/remote13.stable.out sql/test/BugTracker-2018/Tests/sqlitelogictest-in-query.Bug-6545.stable.err sql/test/BugTracker-2018/Tests/sqlitelogictest-in-query.Bug-6545.stable.out sql/test/BugTracker-2018/Tests/sqlitelogictest-in-with-division.Bug-6546.stable.err sql/test/BugTracker-2018/Tests/sqlitelogictest-in-with-division.Bug-6546.stable.out sql/test/Users/Tests/grantAndRevokeUserLoggedIN.Bug-3476.SQL.py sql/test/Users/Tests/grantAndRevokeUserLoggedIN.Bug-3476.stable.err sql/test/Users/Tests/grantAndRevokeUserLoggedIN.Bug-3476.stable.out sql/type.txt Removed Files: sql/test/Users/Tests/grantAndRevokeUserLogedIN.Bug-3476.SQL.py sql/test/Users/Tests/grantAndRevokeUserLogedIN.Bug-3476.stable.err sql/test/Users/Tests/grantAndRevokeUserLogedIN.Bug-3476.stable.out Modified Files: clients/ChangeLog.Mar2018 clients/Tests/MAL-signatures.stable.out clients/Tests/MAL-signatures.stable.out.int128 clients/Tests/exports.stable.out clients/mapiclient/mclient.c clients/mapiclient/mnc.c clients/mapilib/mapi.c clients/mapilib/mapi.h clients/odbc/driver/Makefile.ag clients/odbc/driver/ODBCDbc.c clients/odbc/driver/ODBCDbc.h clients/odbc/driver/SQLColumnPrivileges.c clients/odbc/driver/SQLColumns.c clients/odbc/driver/SQLConnect.c clients/odbc/driver/SQLDisconnect.c clients/odbc/driver/SQLGetFunctions.c clients/odbc/driver/SQLGetInfo.c clients/odbc/driver/SQLProcedureColumns.c clients/odbc/driver/SQLProcedures.c clients/odbc/driver/SQLSpecialColumns.c clients/odbc/driver/SQLTablePrivileges.c clients/odbc/driver/SQLTables.c gdk/gdk.h gdk/gdk_batop.c gdk/gdk_private.h gdk/gdk_project.c gdk/gdk_qsort.c gdk/gdk_select.c gdk/gdk_ssort_impl.h monetdb5/modules/mal/mal_mapi.c monetdb5/optimizer/opt_prelude.c monetdb5/optimizer/opt_prelude.h sql/ChangeLog.Mar2018 sql/backends/monet5/rel_bin.c sql/backends/monet5/sql.c sql/backends/monet5/sql_cat.c sql/backends/monet5/sql_cat.h sql/backends/monet5/sql_result.c sql/backends/monet5/sql_statement.c sql/backends/monet5/sql_upgrades.c sql/backends/monet5/sqlcatalog.mal sql/common/sql_keyword.c sql/include/sql_relation.h sql/scripts/21_dependency_views.sql sql/scripts/97_comments.sql sql/server/rel_optimizer.c sql/server/rel_schema.c sql/server/rel_select.c sql/server/sql_mvc.c sql/server/sql_mvc.h sql/server/sql_parser.y sql/server/sql_scan.c sql/storage/store.c sql/test/BugTracker-2016/Tests/storagemodel.sql sql/test/BugTracker-2016/Tests/storagemodel.stable.out sql/test/BugTracker-2017/Tests/crash_correlated_subqueries_in_select.Bug-6254.stable.out sql/test/BugTracker-2018/Tests/truncate_bam_tables.Bug-6543.stable.err sql/test/BugTracker-2018/Tests/truncate_sys_netcdf_tables.Bug-6543.stable.err sql/test/BugTracker-2018/Tests/truncate_sys_tables.Bug-6543.stable.err sql/test/BugTracker-2018/Tests/truncate_sys_tables.Bug-6543.stable.out sql/test/Dependencies/Tests/Dependencies.stable.out sql/test/Dependencies/Tests/Dependencies.stable.out.int128 sql/test/Dependencies/Tests/dependency_loop.stable.out sql/test/Dependencies/Tests/dependency_loop.stable.out.int128 sql/test/FeatureRequests/Tests/All sql/test/FeatureRequests/Tests/foreign_key_outer_join_dead_code_elimination-plan-1join-query.sql sql/test/FeatureRequests/Tests/foreign_key_outer_join_dead_code_elimination-plan-1join-query.stable.out sql/test/FeatureRequests/Tests/foreign_key_outer_join_dead_code_elimination-plan-1join-view.stable.out sql/test/FeatureRequests/Tests/foreign_key_outer_join_dead_code_elimination-plan-2join-query.sql sql/test/FeatureRequests/Tests/foreign_key_outer_join_dead_code_elimination-plan-2join-query.stable.out sql/test/FeatureRequests/Tests/foreign_key_outer_join_dead_code_elimination-plan-2join-view.stable.out sql/test/FeatureRequests/Tests/foreign_key_outer_join_dead_code_elimination-prologue.stable.out sql/test/Users/Tests/All sql/test/emptydb-upgrade-chain-hge/Tests/upgrade.stable.out.int128 sql/test/emptydb-upgrade-chain-hge/Tests/upgrade.stable.out.powerpc64 sql/test/emptydb-upgrade-chain/Tests/upgrade.stable.out sql/test/emptydb-upgrade-chain/Tests/upgrade.stable.out.32bit sql/test/emptydb-upgrade-chain/Tests/upgrade.stable.out.int128 sql/test/emptydb-upgrade-chain/Tests/upgrade.stable.out.powerpc64 sql/test/emptydb-upgrade-hge/Tests/upgrade.stable.out.int128 sql/test/emptydb-upgrade/Tests/upgrade.stable.out sql/test/emptydb-upgrade/Tests/upgrade.stable.out.32bit sql/test/emptydb-upgrade/Tests/upgrade.stable.out.int128 sql/test/emptydb/Tests/check.stable.out sql/test/emptydb/Tests/check.stable.out.32bit sql/test/emptydb/Tests/check.stable.out.int128 sql/test/mergetables/Tests/alter.stable.err sql/test/testdb-upgrade-chain-hge/Tests/upgrade.stable.out.int128 sql/test/testdb-upgrade-chain/Tests/upgrade.stable.out sql/test/testdb-upgrade-chain/Tests/upgrade.stable.out.32bit sql/test/testdb-upgrade-chain/Tests/upgrade.stable.out.int128 sql/test/testdb-upgrade-hge/Tests/upgrade.stable.out.int128 sql/test/testdb-upgrade/Tests/upgrade.stable.out sql/test/testdb-upgrade/Tests/upgrade.stable.out.32bit sql/test/testdb-upgrade/Tests/upgrade.stable.out.int128 testing/Mtest.py.in tools/merovingian/daemon/connections.c tools/mserver/mserver5.c Branch: data-vaults Log Message:
Merge with default diffs (truncated from 8359 to 300 lines): diff --git a/clients/ChangeLog.Mar2018 b/clients/ChangeLog.Mar2018 --- a/clients/ChangeLog.Mar2018 +++ b/clients/ChangeLog.Mar2018 @@ -1,6 +1,9 @@ # ChangeLog file for clients # This file is updated with Maddlog +* Wed Feb 28 2018 Sjoerd Mullender <sjo...@acm.org> +- ODBC: The driver function SQLProcedureColumns was implemented. + * Thu Feb 1 2018 Sjoerd Mullender <sjo...@acm.org> - ODBC: Changed table types as used by SQLTables from "LOCAL TEMPORARY" and "GLOBAL TEMPORARY" to "LOCAL TEMPORARY TABLE" and "GLOBAL TEMPORARY diff --git a/clients/Tests/MAL-signatures.stable.out b/clients/Tests/MAL-signatures.stable.out --- a/clients/Tests/MAL-signatures.stable.out +++ b/clients/Tests/MAL-signatures.stable.out @@ -10979,6 +10979,7 @@ Ready. [ "sqlcatalog", "alter_set_table", "pattern sqlcatalog.alter_set_table(sname:str, tnme:str, access:int):void ", "SQLalter_set_table;", "Catalog operation alter_set_table" ] [ "sqlcatalog", "alter_table", "pattern sqlcatalog.alter_table(sname:str, tname:str, tbl:ptr, action:int):void ", "SQLalter_table;", "Catalog operation alter_table" ] [ "sqlcatalog", "alter_user", "pattern sqlcatalog.alter_user(sname:str, passwrd:str, enc:int, schema:str, oldpasswrd:str):void ", "SQLalter_user;", "Catalog operation alter_user" ] +[ "sqlcatalog", "comment_on", "pattern sqlcatalog.comment_on(objid:int, remark:str):void ", "SQLcomment_on;", "Catalog operation comment_on" ] [ "sqlcatalog", "create_function", "pattern sqlcatalog.create_function(sname:str, fname:str, fcn:ptr):void ", "SQLcreate_function;", "Catalog operation create_function" ] [ "sqlcatalog", "create_role", "pattern sqlcatalog.create_role(sname:str, role:str, grator:int):void ", "SQLcreate_role;", "Catalog operation create_role" ] [ "sqlcatalog", "create_schema", "pattern sqlcatalog.create_schema(sname:str, auth:str, ifnotexists:int, action:int):void ", "SQLcreate_schema;", "Catalog operation create_schema" ] diff --git a/clients/Tests/MAL-signatures.stable.out.int128 b/clients/Tests/MAL-signatures.stable.out.int128 --- a/clients/Tests/MAL-signatures.stable.out.int128 +++ b/clients/Tests/MAL-signatures.stable.out.int128 @@ -15192,6 +15192,7 @@ Ready. [ "sqlcatalog", "alter_set_table", "pattern sqlcatalog.alter_set_table(sname:str, tnme:str, access:int):void ", "SQLalter_set_table;", "Catalog operation alter_set_table" ] [ "sqlcatalog", "alter_table", "pattern sqlcatalog.alter_table(sname:str, tname:str, tbl:ptr, action:int):void ", "SQLalter_table;", "Catalog operation alter_table" ] [ "sqlcatalog", "alter_user", "pattern sqlcatalog.alter_user(sname:str, passwrd:str, enc:int, schema:str, oldpasswrd:str):void ", "SQLalter_user;", "Catalog operation alter_user" ] +[ "sqlcatalog", "comment_on", "pattern sqlcatalog.comment_on(objid:int, remark:str):void ", "SQLcomment_on;", "Catalog operation comment_on" ] [ "sqlcatalog", "create_function", "pattern sqlcatalog.create_function(sname:str, fname:str, fcn:ptr):void ", "SQLcreate_function;", "Catalog operation create_function" ] [ "sqlcatalog", "create_role", "pattern sqlcatalog.create_role(sname:str, role:str, grator:int):void ", "SQLcreate_role;", "Catalog operation create_role" ] [ "sqlcatalog", "create_schema", "pattern sqlcatalog.create_schema(sname:str, auth:str, ifnotexists:int, action:int):void ", "SQLcreate_schema;", "Catalog operation create_schema" ] 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 @@ -253,8 +253,8 @@ gdk_return GDKmmapfile(str buffer, size_ int GDKms(void); int GDKnr_threads; void GDKprepareExit(void); -void GDKqsort(void *h, void *t, const void *base, size_t n, int hs, int ts, int tpe); -void GDKqsort_rev(void *h, void *t, const void *base, size_t n, int hs, int ts, int tpe); +void GDKqsort(void *restrict h, void *restrict t, const void *restrict base, size_t n, int hs, int ts, int tpe); +void GDKqsort_rev(void *restrict h, void *restrict t, const void *restrict base, size_t n, int hs, int ts, int tpe); void *GDKrealloc(void *pold, size_t size) __attribute__((__warn_unused_result__)); void GDKregister(MT_Id pid); gdk_return GDKreleasemmap(void *ptr, size_t size, size_t id, str *msg); @@ -533,6 +533,7 @@ int64_t mapi_get_querytime(MapiHdl hdl); int mapi_get_querytype(MapiHdl hdl); int64_t mapi_get_row_count(MapiHdl hdl); int mapi_get_scale(MapiHdl hdl, int fnr); +int64_t mapi_get_sqloptimizertime(MapiHdl hdl); char *mapi_get_table(MapiHdl hdl, int fnr); int mapi_get_tableid(MapiHdl hdl); stream *mapi_get_to(Mapi mid); @@ -2027,6 +2028,7 @@ ssize_t color_fromstr(const char *colorS ssize_t color_tostr(char **colorStr, size_t *len, const color *c); str columnBindRef; str columnRef; +str comment_onRef; str commitRef; str compileAllOptimizers(Client cntxt); str compileOptimizer(Client cntxt, const char *name); diff --git a/clients/mapiclient/mclient.c b/clients/mapiclient/mclient.c --- a/clients/mapiclient/mclient.c +++ b/clients/mapiclient/mclient.c @@ -1844,7 +1844,7 @@ format_result(Mapi mid, MapiHdl hdl, int } // get the timings as reported by the backend - sqloptimizer = 0; + sqloptimizer = mapi_get_sqloptimizertime(hdl); maloptimizer = mapi_get_maloptimizertime(hdl); querytime = mapi_get_querytime(hdl); timerHumanStop(); diff --git a/clients/mapiclient/mnc.c b/clients/mapiclient/mnc.c --- a/clients/mapiclient/mnc.c +++ b/clients/mapiclient/mnc.c @@ -213,6 +213,7 @@ main(int argc, char **argv) #endif if (connect(s, serv, sizeof(server)) == SOCKET_ERROR) { + closesocket(s); fprintf(stderr, "initiating connection on socket failed: %s\n", strerror(errno)); @@ -253,13 +254,20 @@ main(int argc, char **argv) server.sin_port = htons((unsigned short) ((port) & 0xFFFF)); if (bind(sock, (SOCKPTR) &server, length) == SOCKET_ERROR) { + closesocket(sock); fprintf(stderr, "bind to port %d failed: %s\n", port, strerror(errno)); exit(1); } - listen(sock, 1); + if(listen(sock, 1) == -1) { + closesocket(sock); + fprintf(stderr, "failed to set socket to listen: %s\n", + strerror(errno)); + exit(1); + } if ((s = accept4(sock, (SOCKPTR)0, (socklen_t *)0, SOCK_CLOEXEC)) == INVALID_SOCKET) { + closesocket(sock); fprintf(stderr, "failed to accept connection: %s\n", strerror(errno)); exit(1); @@ -288,8 +296,11 @@ main(int argc, char **argv) /* on Windows: unsigned int, * elsewhere: size_t, but then * unsigned int shouldn't harm */ - if (!write(1, buf, (unsigned int) len)) + if (!write(1, buf, (unsigned int) len)) { + mnstr_destroy(in); + mnstr_destroy(out); exit(2); + } seenflush = 0; } else { /* flush or error */ diff --git a/clients/mapilib/mapi.c b/clients/mapilib/mapi.c --- a/clients/mapilib/mapi.c +++ b/clients/mapilib/mapi.c @@ -876,6 +876,7 @@ struct MapiResultSet { int64_t last_id; int64_t querytime; int64_t maloptimizertime; + int64_t sqloptimizertime; int fieldcnt; int maxfields; char *errorstr; /* error from server */ @@ -1442,6 +1443,7 @@ new_result(MapiHdl hdl) result->errorstr = NULL; result->querytime = 0; result->maloptimizertime = 0; + result->sqloptimizertime = 0; memset(result->sqlstate, 0, sizeof(result->sqlstate)); result->tuple_count = 0; @@ -3764,12 +3766,14 @@ parse_header_line(MapiHdl hdl, char *lin result->commentonly = 0; result->querytime = 0; result->maloptimizertime = 0; + result->sqloptimizertime = 0; nline++; /* skip space */ switch (qt) { case Q_SCHEMA: result->querytime = strtoll(nline, &nline, 10); result->maloptimizertime = strtoll(nline, &nline, 10); + result->sqloptimizertime = strtoll(nline, &nline, 10); break; case Q_TRANS: if (*nline == 'f') @@ -3783,14 +3787,16 @@ parse_header_line(MapiHdl hdl, char *lin queryid = strtoll(nline, &nline, 10); result->querytime = strtoll(nline, &nline, 10); result->maloptimizertime = strtoll(nline, &nline, 10); + result->sqloptimizertime = strtoll(nline, &nline, 10); break; case Q_TABLE: - if (sscanf(nline, "%d %" SCNd64 " %d %" SCNd64 " %" SCNu64 " %" SCNd64 " %" SCNd64, + if (sscanf(nline, "%d %" SCNd64 " %d %" SCNd64 " %" SCNu64 " %" SCNd64 " %" SCNd64 " %" SCNd64, &result->tableid, &result->row_count, &result->fieldcnt, &result->tuple_count, - &queryid, &result->querytime, &result->maloptimizertime) < 7){ + &queryid, &result->querytime, &result->maloptimizertime, &result->sqloptimizertime) < 8){ result->querytime = 0; result->maloptimizertime = 0; + result->sqloptimizertime = 0; } (void) queryid; /* ignored for now */ break; @@ -5323,6 +5329,17 @@ mapi_get_maloptimizertime(MapiHdl hdl) return result->maloptimizertime; } +int64_t +mapi_get_sqloptimizertime(MapiHdl hdl) +{ + struct MapiResultSet *result; + + mapi_hdl_check(hdl, "mapi_get_sqloptimizertime"); + if ((result = hdl->result) == NULL) + return 0; + return result->sqloptimizertime; +} + char * mapi_get_dbname(Mapi mid) { diff --git a/clients/mapilib/mapi.h b/clients/mapilib/mapi.h --- a/clients/mapilib/mapi.h +++ b/clients/mapilib/mapi.h @@ -192,6 +192,7 @@ mapi_export int64_t mapi_get_last_id(Map mapi_export int64_t mapi_rows_affected(MapiHdl hdl); mapi_export int64_t mapi_get_querytime(MapiHdl hdl); mapi_export int64_t mapi_get_maloptimizertime(MapiHdl hdl); +mapi_export int64_t mapi_get_sqloptimizertime(MapiHdl hdl); mapi_export char *mapi_fetch_field(MapiHdl hdl, int fnr); mapi_export size_t mapi_fetch_field_len(MapiHdl hdl, int fnr); diff --git a/clients/odbc/driver/Makefile.ag b/clients/odbc/driver/Makefile.ag --- a/clients/odbc/driver/Makefile.ag +++ b/clients/odbc/driver/Makefile.ag @@ -24,6 +24,7 @@ lib_MonetODBC = { ODBCError.c \ ODBCError.h \ ODBCGlobal.h \ + ODBCQueries.h \ ODBCStmt.c \ ODBCStmt.h \ ODBCUtil.c \ diff --git a/clients/odbc/driver/ODBCDbc.c b/clients/odbc/driver/ODBCDbc.c --- a/clients/odbc/driver/ODBCDbc.c +++ b/clients/odbc/driver/ODBCDbc.c @@ -66,7 +66,8 @@ newODBCDbc(ODBCEnv *env) dbc->port = 0; dbc->dbname = NULL; - dbc->Connected = 0; + dbc->Connected = false; + dbc->has_comment = false; dbc->sql_attr_autocommit = SQL_AUTOCOMMIT_ON; /* default is autocommit */ dbc->sql_attr_metadata_id = SQL_FALSE; dbc->sql_attr_connection_timeout = 0; diff --git a/clients/odbc/driver/ODBCDbc.h b/clients/odbc/driver/ODBCDbc.h --- a/clients/odbc/driver/ODBCDbc.h +++ b/clients/odbc/driver/ODBCDbc.h @@ -53,7 +53,8 @@ typedef struct tODBCDRIVERDBC { char *host; /* Server host */ int port; /* Server port */ char *dbname; /* Database Name or NULL */ - int Connected; /* 1 is Yes, 0 is No */ + bool Connected; /* whether we are connecte to a server */ + bool has_comment; /* whether the server has sys.comments */ SQLUINTEGER sql_attr_autocommit; SQLUINTEGER sql_attr_metadata_id; SQLUINTEGER sql_attr_connection_timeout; diff --git a/clients/odbc/driver/ODBCQueries.h b/clients/odbc/driver/ODBCQueries.h new file mode 100644 --- /dev/null +++ b/clients/odbc/driver/ODBCQueries.h @@ -0,0 +1,292 @@ +/* + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * Copyright 1997 - July 2008 CWI, August 2008 - 2018 MonetDB B.V. + */ + +/* this file contains parts of queries that are used in multiple + * places */ + +#define DATA_TYPE(t) \ + "case " #t ".type " \ + "when 'bigint' then %d " \ + "when 'blob' then %d " \ + "when 'boolean' then %d " \ + "when 'char' then %d " \ + "when 'clob' then %d " \ + "when 'date' then %d " \ + "when 'decimal' then %d " \ + "when 'double' then %d " \ + "when 'hugeint' then %d " \ + "when 'int' then %d " \ + "when 'month_interval' then " \ + "case " #t ".type_digits " \ + "when 1 then %d " \ + "when 2 then %d " \ + "when 3 then %d " \ + "end " \ + "when 'real' then %d " \ + "when 'sec_interval' then " \ + "case " #t ".type_digits " \ + "when 4 then %d " \ + "when 5 then %d " \ + "when 6 then %d " \ + "when 7 then %d " \ + "when 8 then %d " \ + "when 9 then %d " \ + "when 10 then %d " \ + "when 11 then %d " \ + "when 12 then %d " \ + "when 13 then %d " \ + "end " \ + "when 'smallint' then %d " \ + "when 'time' then %d " \ + "when 'timestamp' then %d " \ + "when 'timestamptz' then %d " \ + "when 'timetz' then %d " \ + "when 'tinyint' then %d " \ + "when 'varchar' then %d " \ + "end as data_type" +#define DATA_TYPE_ARGS \ + SQL_BIGINT, SQL_LONGVARBINARY, SQL_BIT, SQL_WCHAR, \ _______________________________________________ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list