Changeset: 762c8e29b2d9 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=762c8e29b2d9
Modified Files:
        java/example/XQueryLoad.java
        monetdb5/optimizer/Tests/roberto1.stable.out
        monetdb5/optimizer/Tests/tst4820.stable.out
        sql/backends/monet5/sql.mx
        
sql/test/BugTracker-2010/Tests/group-by_ordered_column.Bug-2564.stable.out.FreeBSD
        
sql/test/BugTracker-2011/Tests/func_iter_vs_bulk.Bug-2826.stable.out.FreeBSD
Branch: gdk-calc
Log Message:

Merge with default branch.


diffs (truncated from 2367 to 300 lines):

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
@@ -590,9 +590,6 @@
 /* Define to 1 if you have the <time.h> header file. */
 #define HAVE_TIME_H 1
 
-/* Define to 1 if you have the timezone and daylight variables. */
-#define HAVE_TIMEZONE 1
-
 /* Define to 1 if you have the `trunc' function. */
 /* #undef HAVE_TRUNC */
 
diff --git a/clients/mapiclient/mclient.1 b/clients/mapiclient/mclient.1
--- a/clients/mapiclient/mclient.1
+++ b/clients/mapiclient/mclient.1
@@ -368,5 +368,27 @@ Enable auto commit mode.
 .TP
 \fB\ea\fP
 Disable auto commit mode.
+.SH EXAMPLES
+Efficiently import data from a CSV (comma-separated values) file into
+a table.  The file must be readable by the server.  $file is the
+absolute path name of the file, $table is the name of the table, $db
+is the name of the database.
+.PP
+mclient -d $db -s "COPY INTO $table FROM '$file' USING DELIMITERS 
',','\e\en','\e"'"
+.PP
+Efficiently import data from a CSV file into a table when the file is
+to be read by mclient (e.g. the server has no access to the file).
+$file is the (absolute or relative) path name of the file, $table is
+the name of the table, $db is the name of the database.
+.PP
+mclient -d $db -s "COPY INTO $table FROM STDIN USING DELIMITERS 
',','\e\en','\e"'" - < $file
+.PP
+Note that in this latter case, if a count of records is supplied, it
+should be at least as large as the number of records actually present
+in the CSV file.  This, because otherwise the remainder of the file
+will be interpreted as SQL queries.
+.PP
+See http://www.monetdb.org/Documentation/Manuals/SQLreference/CopyInto
+for more information about the COPY INTO query.
 .SH SEE ALSO
 .IR msqldump (1)
diff --git a/clients/mapiclient/mclient.c b/clients/mapiclient/mclient.c
--- a/clients/mapiclient/mclient.c
+++ b/clients/mapiclient/mclient.c
@@ -2491,19 +2491,19 @@ doFile(Mapi mid, const char *file, int u
 static void
 set_timezone(Mapi mid)
 {
-#ifdef HAVE_TIMEZONE
-#ifdef _MSC_VER
-#define timezone _timezone
-#endif
        char buf[128];
-       struct tm *tm;
-       time_t t;
+       time_t t, lt, gt;
+       struct tm *tmp;
        long tzone;
        MapiHdl hdl;
 
+       /* figure out our current timezone */
        t = time(NULL);
-       tm = localtime(&t);
-       tzone = timezone - 3600 * tm->tm_isdst;
+       tmp = gmtime(&t);
+       gt = mktime(tmp);
+       tmp = localtime(&t);
+       lt = mktime(tmp);
+       tzone = (long) (gt - lt);
        if (tzone < 0)
                snprintf(buf, sizeof(buf),
                         "SET TIME ZONE INTERVAL '+%02ld:%02ld' HOUR TO MINUTE",
@@ -2518,9 +2518,6 @@ set_timezone(Mapi mid)
                return;
        }
        mapi_close_handle(hdl);
-#else
-       (void) mid;
-#endif
 }
 
 static void usage(const char *prog, int xit)
diff --git a/clients/odbc/driver/SQLConnect.c b/clients/odbc/driver/SQLConnect.c
--- a/clients/odbc/driver/SQLConnect.c
+++ b/clients/odbc/driver/SQLConnect.c
@@ -58,19 +58,19 @@
 static void
 set_timezone(Mapi mid)
 {
-#ifdef HAVE_TIMEZONE
-#ifdef _MSC_VER
-#define timezone _timezone
-#define daylight _daylight
-#define tzset _tzset
-#endif
        char buf[128];
+       time_t t, lt, gt;
+       struct tm *tmp;
        long tzone;
        MapiHdl hdl;
 
-       /* timezone and daylight are POSIX-defined variables */
-       tzset();
-       tzone = timezone - 3600 * daylight;
+       /* figure out our current timezone */
+       t = time(NULL);
+       tmp = gmtime(&t);
+       gt = mktime(tmp);
+       tmp = localtime(&t);
+       lt = mktime(tmp);
+       tzone = (long) (gt - lt);
        if (tzone < 0)
                snprintf(buf, sizeof(buf),
                         "SET TIME ZONE INTERVAL '+%02ld:%02ld' HOUR TO MINUTE",
@@ -81,9 +81,6 @@ set_timezone(Mapi mid)
                         tzone / 3600, (tzone % 3600) / 60);
        if ((hdl = mapi_query(mid, buf)) != NULL)
                mapi_close_handle(hdl);
-#else
-       (void) mid;
-#endif
 }
 
 static void
diff --git a/configure.ag b/configure.ag
--- a/configure.ag
+++ b/configure.ag
@@ -2530,16 +2530,6 @@ AH_VERBATIM([__attribute__],
 #endif
 ])
 
-AC_MSG_CHECKING([if you have timezone and daylight variables])
-AC_COMPILE_IFELSE(
-       [AC_LANG_PROGRAM(
-               [[#include <time.h>]],
-               [[printf("%ld %d\n", timezone, daylight);]])],
-       AC_MSG_RESULT([yes])
-       AC_DEFINE([HAVE_TIMEZONE], 1,
-               [Define to 1 if you have the timezone and daylight variables.]),
-       AC_MSG_RESULT([no]))
-
 dnl     checks for library functions
 case $host in
        *-darwin1[[01234]]*)
diff --git a/java/example/SQLcopyinto.java b/java/example/SQLcopyinto.java
--- a/java/example/SQLcopyinto.java
+++ b/java/example/SQLcopyinto.java
@@ -79,8 +79,8 @@ public class SQLcopyinto {
 
                        query = "COPY INTO example FROM STDIN USING DELIMITERS 
',','\\n';";
                        // the leading 's' is essential, since it is a protocol
-                       // marker that should not be ommitted, as much as the
-                       // trailing semi-colon
+                       // marker that should not be omitted, likewise the
+                       // trailing semicolon
                        out.write('s');
                        out.write(query);
                        out.newLine();
diff --git a/java/example/XQueryLoad.java b/java/example/XQueryLoad.java
deleted file mode 100644
--- a/java/example/XQueryLoad.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * The contents of this file are subject to the MonetDB Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.monetdb.org/Legal/MonetDBLicense
- *
- * Software distributed under the License is distributed on an "AS IS"
- * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
- * License for the specific language governing rights and limitations
- * under the License.
- *
- * The Original Code is the MonetDB Database System.
- *
- * The Initial Developer of the Original Code is CWI.
- * Portions created by CWI are Copyright (C) 1997-July 2008 CWI.
- * Copyright August 2008-2012 MonetDB B.V.
- * All Rights Reserved.
- */
-
-import java.sql.*;
-
-/**
- * This is an example showing the use of loading ("shredding") XML
- * documents into MonetDB/XQuery.
- *
- * @author Fabian Groffen <[email protected]>
- */
-public class XQueryLoad {
-       public static void main(String[] args) throws Exception {
-               // make sure the driver is loaded
-               Class.forName("nl.cwi.monetdb.jdbc.MonetDriver");
-               Connection con = 
DriverManager.getConnection("jdbc:monetdb://localhost/notused?language=xquery&xdebug=true",
 "monetdb", "monetdb");
-               Statement st = con.createStatement();
-
-               st.addBatch("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
-               st.addBatch("<doc>");
-               st.addBatch(" <greet kind=\"informal\">Hi </greet>");
-               st.addBatch(" <greet kind=\"casual\">Hello </greet>");
-               st.addBatch(" <location kind=\"global\">World</location>");
-               st.addBatch(" <location kind=\"local\">Amsterdam</location>");
-               st.addBatch("</doc>");
-
-               st.executeBatch();
-
-               /* The name of the document is written as warning to the
-                * Connection's warning stack.  This is kind of dirty, but since
-                * the batch cannot return a string, there is no other way here.
-                */
-               SQLWarning w = con.getWarnings();
-               while (w != null) {
-                       System.out.println(w.getMessage());
-                       w = w.getNextWarning();
-               }
-
-               st.close();
-               con.close();
-       }
-}
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
@@ -563,8 +563,8 @@ int MCreadClient(Client c){
        if (in->pos >= in->len || in->mode) {
                ssize_t rd, sum = 0;
 
-               if (in->eof || !isa_block_stream(in->s)) {
-                       if (!isa_block_stream(c->fdout) && c->promptlength > 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;
diff --git a/monetdb5/mal/mal_linker.c b/monetdb5/mal/mal_linker.c
--- a/monetdb5/mal/mal_linker.c
+++ b/monetdb5/mal/mal_linker.c
@@ -115,9 +115,9 @@ getAddress(stream *out, str filename, st
 
        (void) modnme;
        if( prev >= 0){
-                       adr = (MALfcn) dlsym(filesLoaded[prev].handle, fcnname);
-                       if( adr != NULL)
-                               return adr; /* found it */
+               adr = (MALfcn) dlsym(filesLoaded[prev].handle, fcnname);
+               if( adr != NULL)
+                       return adr; /* found it */
        }
        if( filename && prev >= 0) {
                if( strcmp(filename, filesLoaded[prev].filename)==0) {
@@ -156,7 +156,7 @@ getAddress(stream *out, str filename, st
                if( adr != NULL)
                        return adr; /* found it */
        }
-       if( !silent)
+       if (!silent)
                showException(out, MAL,"MAL.getAddress", "address of '%s.%s' 
not found",
                        (modnme?modnme:"<unknown>"), fcnname);
        return NULL;
diff --git a/monetdb5/mal/mal_type.c b/monetdb5/mal/mal_type.c
--- a/monetdb5/mal/mal_type.c
+++ b/monetdb5/mal/mal_type.c
@@ -214,6 +214,8 @@ isAmbiguousType(int type){
        switch(type){
                case TYPE_bte: case TYPE_sht: case TYPE_wrd: case TYPE_int: 
case TYPE_lng:
                return type != TYPE_int;
+               case TYPE_flt: case TYPE_dbl:
+               return type != TYPE_flt;
        }
        return 0;
 }
diff --git a/monetdb5/modules/mal/tablet_sql.c 
b/monetdb5/modules/mal/tablet_sql.c
--- a/monetdb5/modules/mal/tablet_sql.c
+++ b/monetdb5/modules/mal/tablet_sql.c
@@ -785,7 +785,7 @@ SQLload_file(Client cntxt, Tablet *as, b
        }
 
        if (task->b->pos < task->b->len && cnt < (BUN) maxrow && task->ateof) {
-               GDKerror("Incomplete record at end of file.\n");
+               showException(task->out, MAL, "copy_from", "Incomplete record 
at end of file.\n");
                /* indicate that we did read everything (even if we couldn't
                 * deal with it */
                task->b->pos = task->b->len;
diff --git a/monetdb5/optimizer/Tests/roberto1.stable.out 
b/monetdb5/optimizer/Tests/roberto1.stable.out
--- a/monetdb5/optimizer/Tests/roberto1.stable.out
+++ b/monetdb5/optimizer/Tests/roberto1.stable.out
@@ -20,7 +20,7 @@ barrier go := true;
     bat.setPersistent(a,false);
     transaction.commit();
 # alter the values 
-    a:bat[:oid,:dbl]  := batcalc.+(a,1);
+    a:bat[:oid,:dbl]  := batcalc.+(a,1:dbl);
 # store it to disk with the same name 
     bat.setName(a,"P_bat");
     bat.setPersistent(a,true);
@@ -39,7 +39,7 @@ barrier go := true;                     
_______________________________________________
Checkin-list mailing list
[email protected]
http://mail.monetdb.org/mailman/listinfo/checkin-list

Reply via email to