Changeset: bfe947789953 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=bfe947789953
Modified Files:
        NT/rules.msc
        clients/mapiclient/dump.c
        sql/server/rel_optimizer.c
        sql/test/Tests/comment-on.sql
        sql/test/Tests/comment-on.stable.err
        sql/test/Tests/comment-on.stable.out
Branch: default
Log Message:

merged with Mar2018


diffs (truncated from 342 to 300 lines):

diff --git a/NT/rules.msc b/NT/rules.msc
--- a/NT/rules.msc
+++ b/NT/rules.msc
@@ -39,12 +39,6 @@ BITSMCHN=X64
 !ENDIF
 
 !IFDEF DEBUG
-DEBUGLIB=d
-!ELSE
-DEBUGLIB=
-!ENDIF
-
-!IFDEF DEBUG
 # force W_CFLAGS off in debug builds: using icc, you get way more
 # warnings about casts which results in the code being uncompilable
 W_CFLAGS =
@@ -98,7 +92,7 @@ PYTHON_LIBDIR=$(PYTHON3_LIBDIR)
 !IFNDEF LIBPCRE
 LIBPCRE = C:\Program Files\PCRE
 !ENDIF
-pcre_LIBS = "$(LIBPCRE)\lib\pcre$(DEBUGLIB).lib"
+pcre_LIBS = "$(LIBPCRE)\lib\pcre.lib"
 pcre_CFLAGS = -DHAVE_LIBPCRE "-I$(LIBPCRE)\include"
 !ENDIF
 
@@ -116,7 +110,7 @@ openssl_CFLAGS = -DHAVE_OPENSSL "-I$(LIB
 !IFNDEF LIBICONV
 LIBICONV = C:\iconv-1.9.2.win$(bits)
 !ENDIF
-LTLIBICONV = "$(LIBICONV)\lib\iconv$(DEBUGLIB).lib"
+LTLIBICONV = "$(LIBICONV)\lib\iconv.lib"
 ICONV_CFLAGS = -DHAVE_ICONV "-I$(LIBICONV)\include"
 !ENDIF
 
@@ -135,7 +129,7 @@ LIBZLIB = C:\zlib-1.2.3.win$(bits)
 !IFNDEF LIBZLIBFILE
 LIBZLIBFILE=zlib1
 !ENDIF
-zlib_LIBS = "$(LIBZLIB)\lib\$(LIBZLIBFILE)$(DEBUGLIB).lib"
+zlib_LIBS = "$(LIBZLIB)\lib\$(LIBZLIBFILE).lib"
 zlib_CFLAGS = -DHAVE_LIBZ "-I$(LIBZLIB)\include"
 !ENDIF
 
@@ -144,7 +138,7 @@ zlib_CFLAGS = -DHAVE_LIBZ "-I$(LIBZLIB)\
 !IFNDEF LIBBZIP2
 LIBBZIP2 = C:\bzip2-1.0.5.win$(bits)
 !ENDIF
-BZ_LIBS = "$(LIBBZIP2)\lib\libbz2$(DEBUGLIB).lib"
+BZ_LIBS = "$(LIBBZIP2)\lib\libbz2.lib"
 BZ_CFLAGS = -DHAVE_LIBBZ2 "-I$(LIBBZIP2)\include"
 !ENDIF
 
@@ -154,17 +148,13 @@ BZ_CFLAGS = -DHAVE_LIBBZ2 "-I$(LIBBZIP2)
 LIBXML2 = C:\libxml2-2.6.30.win$(bits)
 !ENDIF
 libxml2_CFLAGS = -DHAVE_LIBXML "-I$(LIBXML2)\include" $(zlib_CFLAGS) 
$(ICONV_CFLAGS)
-libxml2_LIBS = "$(LIBXML2)\lib\libxml2$(DEBUGLIB).lib" $(zlib_LIBS) 
$(ICONV_LIBS)
+libxml2_LIBS = "$(LIBXML2)\lib\libxml2.lib" $(zlib_LIBS) $(ICONV_LIBS)
 !ENDIF
 
 !IFNDEF LIBGEOS
 LIBGEOS = C:\geos-3.0.win$(bits)
 !ENDIF
-!IFDEF DEBUG
-GEOS_LIBS = $(LIBGEOS)\lib\geos_c_i$(GEOSDEBUGLIB).lib
-!ELSE
 GEOS_LIBS = $(LIBGEOS)\lib\geos_c_i.lib
-!ENDIF
 GEOS_INCS = -I$(LIBGEOS)\include
 
 !IFDEF HAVE_LIBR
diff --git a/clients/mapiclient/dump.c b/clients/mapiclient/dump.c
--- a/clients/mapiclient/dump.c
+++ b/clients/mapiclient/dump.c
@@ -947,21 +947,22 @@ describe_table(Mapi mid, const char *sch
                }
                mapi_close_handle(hdl);
                hdl = NULL;
-               snprintf(query, maxquerylen,
-                        "SELECT col.name, com.remark FROM sys._columns col, 
sys.comments com WHERE col.id = com.id AND col.table_id = (SELECT id FROM 
sys._tables WHERE schema_id = (SELECT id FROM sys.schemas WHERE name = '%s') 
AND name = '%s') ORDER BY number", schema, tname);
-               if ((hdl = mapi_query(mid, query)) == NULL || mapi_error(mid))
-                       goto bailout;
-               while (mapi_fetch_row(hdl) != 0) {
-                       comment_on(toConsole, "COLUMN", schema, tname,
-                                  mapi_fetch_field(hdl, 0),
-                                  mapi_fetch_field(hdl, 1));
-               }
-               mapi_close_handle(hdl);
-               hdl = NULL;
-               if (mapi_error(mid))
-                       goto bailout;
        }
 
+       snprintf(query, maxquerylen,
+                "SELECT col.name, com.remark FROM sys._columns col, 
sys.comments com WHERE col.id = com.id AND col.table_id = (SELECT id FROM 
sys._tables WHERE schema_id = (SELECT id FROM sys.schemas WHERE name = '%s') 
AND name = '%s') ORDER BY number", schema, tname);
+       if ((hdl = mapi_query(mid, query)) == NULL || mapi_error(mid))
+               goto bailout;
+       while (mapi_fetch_row(hdl) != 0) {
+               comment_on(toConsole, "COLUMN", schema, tname,
+                          mapi_fetch_field(hdl, 0),
+                          mapi_fetch_field(hdl, 1));
+       }
+       mapi_close_handle(hdl);
+       hdl = NULL;
+       if (mapi_error(mid))
+               goto bailout;
+
        if (view)
                free(view);
        if (remark)
diff --git a/sql/server/rel_optimizer.c b/sql/server/rel_optimizer.c
--- a/sql/server/rel_optimizer.c
+++ b/sql/server/rel_optimizer.c
@@ -2900,16 +2900,22 @@ exp_simplify_math( mvc *sql, sql_exp *e,
                if (!f->func->s && !strcmp(f->func->base.name, "sql_mul") && 
list_length(l) == 2) {
                        sql_exp *le = l->h->data;
                        sql_exp *re = l->h->next->data;
+                       sql_subtype *et = exp_subtype(e);
+
                        /* 0*a = 0 */
                        if (exp_is_atom(le) && exp_is_zero(sql, le) && 
exp_is_atom(re) && exp_is_not_null(sql, re)) {
                                (*changes)++;
                                exp_setname(sql->sa, le, exp_relname(e), 
exp_name(e));
+                               if (subtype_cmp(et, exp_subtype(le)) != 0)
+                                       le = exp_convert(sql->sa, le, 
exp_subtype(le), et);
                                return le;
                        }
                        /* a*0 = 0 */
                        if (exp_is_atom(re) && exp_is_zero(sql, re) && 
exp_is_atom(le) && exp_is_not_null(sql, le)) {
                                (*changes)++;
                                exp_setname(sql->sa, re, exp_relname(e), 
exp_name(e));
+                               if (subtype_cmp(et, exp_subtype(re)) != 0)
+                                       re = exp_convert(sql->sa, re, 
exp_subtype(re), et);
                                return re;
                        }
                        /* 1*a = a
diff --git a/sql/test/Tests/comment-on.sql b/sql/test/Tests/comment-on.sql
--- a/sql/test/Tests/comment-on.sql
+++ b/sql/test/Tests/comment-on.sql
@@ -87,6 +87,10 @@ COMMENT ON COLUMN tab.j IS 'jj';
 COMMENT ON COLUMN foo.tab.i IS 'ii';
 \d tab
 
+COMMENT ON COLUMN vivi.j IS 'vjj';
+COMMENT ON COLUMN foo.vivi.i IS 'vii';
+\d vivi
+
 /* comment on index works */
 CREATE INDEX idx ON tab(j,i);
 COMMENT ON INDEX idx IS 'index on j';
@@ -134,6 +138,36 @@ COMMENT ON PROCEDURE g IS 'proc!';
 -- if there is ambiguity we can't
 COMMENT ON FUNCTION f IS 'ambiguous';
 
+
+-- test all COMMENT ON <db-objecttype> variations with an object name which 
does not exist, so should report a "no such <db-objecttype>: abc" error
+COMMENT ON SCHEMA "abc" IS 'schema abc';
+COMMENT ON TABLE "abc" IS 'table abc';
+COMMENT ON VIEW "abc" IS 'view abc';
+COMMENT ON COLUMN "abc".abc IS 'column abc';
+COMMENT ON INDEX "abc" IS 'index abc';
+COMMENT ON SEQUENCE "abc" IS 'seq abc';
+COMMENT ON FUNCTION "abc" IS 'function abc';
+COMMENT ON PROCEDURE "abc" IS 'procedure abc';
+COMMENT ON AGGREGATE "abc" IS 'aggregate abc';
+COMMENT ON FILTER FUNCTION "abc" IS 'filter function abc';
+COMMENT ON LOADER "abc" IS 'loader abc';
+
+-- test COMMENT ON <db-objecttype> for db-objecttypes for which we do NOT 
support comments to be set, so should report a syntax error
+COMMENT ON TYPE "int" IS 'signed integer number 32 bits';
+COMMENT ON TRIGGER "abc" IS 'trigger abc';
+COMMENT ON PRIMARY KEY "abc" IS 'primary key abc';
+COMMENT ON FOREIGN KEY "abc" IS 'foreign key abc';
+COMMENT ON UNIQUE KEY "abc" IS 'unique key abc';
+COMMENT ON KEY "abc" IS 'key abc';
+COMMENT ON FUNCTION ARGUMENT abc.i IS 'function argument abc.i';
+COMMENT ON PROCEDURE ARGUMENT abc.i IS 'procedure argument abc.i';
+COMMENT ON DATABASE "abc" IS 'database abc';
+
+
+-- before cleanup show the created comments
+SELECT remark FROM sys.comments order by remark;
+
+-- cleanup
 DROP FUNCTION f();
 DROP FUNCTION f(INT);
 DROP FUNCTION f(INT,INT);
@@ -147,3 +181,7 @@ DROP TABLE tab;
 
 SET SCHEMA sys;
 DROP SCHEMA foo;
+
+-- after dropping all the created objects, the comments should be removed also
+SELECT remark FROM sys.comments order by remark;
+
diff --git a/sql/test/Tests/comment-on.stable.err 
b/sql/test/Tests/comment-on.stable.err
--- a/sql/test/Tests/comment-on.stable.err
+++ b/sql/test/Tests/comment-on.stable.err
@@ -48,6 +48,86 @@ MAPI  = (monetdb) /var/tmp/mtest-69226/.
 QUERY = COMMENT ON FUNCTION f IS 'ambiguous';
 ERROR = !COMMENT FUNCTION: there are more than one function called 'f', please 
use the full signature
 CODE  = 42000
+MAPI  = (monetdb) /var/tmp/mtest-19692/.s.monetdb.35755
+QUERY = COMMENT ON SCHEMA "abc" IS 'schema abc';
+ERROR = !COMMENT ON:no such schema: abc
+CODE  = 3F000
+MAPI  = (monetdb) /var/tmp/mtest-19692/.s.monetdb.35755
+QUERY = COMMENT ON TABLE "abc" IS 'table abc';
+ERROR = !COMMENT ON:no such table: foo.abc
+CODE  = 42S02
+MAPI  = (monetdb) /var/tmp/mtest-19692/.s.monetdb.35755
+QUERY = COMMENT ON VIEW "abc" IS 'view abc';
+ERROR = !COMMENT ON:no such view: foo.abc
+CODE  = 42S02
+MAPI  = (monetdb) /var/tmp/mtest-19692/.s.monetdb.35755
+QUERY = COMMENT ON COLUMN "abc".abc IS 'column abc';
+ERROR = !COMMENT ON:no such table: foo.abc
+CODE  = 42S02
+MAPI  = (monetdb) /var/tmp/mtest-19692/.s.monetdb.35755
+QUERY = COMMENT ON INDEX "abc" IS 'index abc';
+ERROR = !COMMENT ON:no such index: foo.abc
+CODE  = 42S12
+MAPI  = (monetdb) /var/tmp/mtest-19692/.s.monetdb.35755
+QUERY = COMMENT ON SEQUENCE "abc" IS 'seq abc';
+ERROR = !COMMENT ON:no such sequence: foo.abc
+CODE  = 42000
+MAPI  = (monetdb) /var/tmp/mtest-19692/.s.monetdb.35755
+QUERY = COMMENT ON FUNCTION "abc" IS 'function abc';
+ERROR = !COMMENT FUNCTION: no such function 'abc'
+CODE  = 42000
+MAPI  = (monetdb) /var/tmp/mtest-19692/.s.monetdb.35755
+QUERY = COMMENT ON PROCEDURE "abc" IS 'procedure abc';
+ERROR = !COMMENT PROCEDURE: no such procedure 'abc'
+CODE  = 42000
+MAPI  = (monetdb) /var/tmp/mtest-19692/.s.monetdb.35755
+QUERY = COMMENT ON AGGREGATE "abc" IS 'aggregate abc';
+ERROR = !COMMENT AGGREGATE: no such aggregate 'abc'
+CODE  = 42000
+MAPI  = (monetdb) /var/tmp/mtest-19692/.s.monetdb.35755
+QUERY = COMMENT ON FILTER FUNCTION "abc" IS 'filter function abc';
+ERROR = !COMMENT FILTER FUNCTION: no such filter function 'abc'
+CODE  = 42000
+MAPI  = (monetdb) /var/tmp/mtest-19692/.s.monetdb.35755
+QUERY = COMMENT ON LOADER "abc" IS 'loader abc';
+ERROR = !COMMENT PROCEDURE: no such procedure 'abc'
+CODE  = 42000
+MAPI  = (monetdb) /var/tmp/mtest-19692/.s.monetdb.35755
+QUERY = COMMENT ON TYPE "int" IS 'signed integer number 32 bits';
+ERROR = !syntax error, unexpected TYPE in: "comment on type"
+CODE  = 42000
+MAPI  = (monetdb) /var/tmp/mtest-19692/.s.monetdb.35755
+QUERY = COMMENT ON TRIGGER "abc" IS 'trigger abc';
+ERROR = !syntax error, unexpected TRIGGER in: "comment on trigger"
+CODE  = 42000
+MAPI  = (monetdb) /var/tmp/mtest-19692/.s.monetdb.35755
+QUERY = COMMENT ON PRIMARY KEY "abc" IS 'primary key abc';
+ERROR = !syntax error, unexpected PRIMARY in: "comment on primary"
+CODE  = 42000
+MAPI  = (monetdb) /var/tmp/mtest-19692/.s.monetdb.35755
+QUERY = COMMENT ON FOREIGN KEY "abc" IS 'foreign key abc';
+ERROR = !syntax error, unexpected FOREIGN in: "comment on foreign"
+CODE  = 42000
+MAPI  = (monetdb) /var/tmp/mtest-19692/.s.monetdb.35755
+QUERY = COMMENT ON UNIQUE KEY "abc" IS 'unique key abc';
+ERROR = !syntax error, unexpected UNIQUE in: "comment on unique"
+CODE  = 42000
+MAPI  = (monetdb) /var/tmp/mtest-19692/.s.monetdb.35755
+QUERY = COMMENT ON KEY "abc" IS 'key abc';
+ERROR = !syntax error, unexpected KEY in: "comment on key"
+CODE  = 42000
+MAPI  = (monetdb) /var/tmp/mtest-19692/.s.monetdb.35755
+QUERY = COMMENT ON FUNCTION ARGUMENT abc.i IS 'function argument abc.i';
+ERROR = !syntax error, unexpected IDENT, expecting IS in: "comment on function 
argument abc"
+CODE  = 42000
+MAPI  = (monetdb) /var/tmp/mtest-19692/.s.monetdb.35755
+QUERY = COMMENT ON PROCEDURE ARGUMENT abc.i IS 'procedure argument abc.i';
+ERROR = !syntax error, unexpected IDENT, expecting IS in: "comment on 
procedure argument abc"
+CODE  = 42000
+MAPI  = (monetdb) /var/tmp/mtest-19692/.s.monetdb.35755
+QUERY = COMMENT ON DATABASE "abc" IS 'database abc';
+ERROR = !syntax error, unexpected IDENT in: "comment on database"
+CODE  = 42000
 
 # 15:45:23 >  
 # 15:45:23 >  "Done."
diff --git a/sql/test/Tests/comment-on.stable.out 
b/sql/test/Tests/comment-on.stable.out
--- a/sql/test/Tests/comment-on.stable.out
+++ b/sql/test/Tests/comment-on.stable.out
@@ -122,6 +122,12 @@ CREATE TABLE "foo"."tab" (
 COMMENT ON TABLE "foo"."tab" IS 'table';
 COMMENT ON COLUMN "foo"."tab"."i" IS 'ii';
 COMMENT ON COLUMN "foo"."tab"."j" IS 'jj';
+#COMMENT ON COLUMN vivi.j IS 'vjj';
+#COMMENT ON COLUMN foo.vivi.i IS 'vii';
+create view vivi as select * from tab;
+COMMENT ON VIEW "foo"."vivi" IS 'phew';
+COMMENT ON COLUMN "foo"."vivi"."i" IS 'vii';
+COMMENT ON COLUMN "foo"."vivi"."j" IS 'vjj';
 #CREATE INDEX idx ON tab(j,i);
 CREATE TABLE "foo"."tab" (
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to