Changeset: 8714eb7a5b6c for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=8714eb7a5b6c
Modified Files:
        
Branch: default
Log Message:

Merge with Dec2011 branch.


diffs (truncated from 525 to 300 lines):

diff --git a/clients/odbc/driver/SQLFetch.c b/clients/odbc/driver/SQLFetch.c
--- a/clients/odbc/driver/SQLFetch.c
+++ b/clients/odbc/driver/SQLFetch.c
@@ -47,14 +47,15 @@
 SQLRETURN
 SQLFetch_(ODBCStmt *stmt)
 {
-       ODBCDesc *desc;
+       ODBCDesc *ard, *ird;
        ODBCDescRec *rec;
        int i;
        SQLULEN row;
        SQLINTEGER offset;
        SQLUSMALLINT *statusp;
 
-       desc = stmt->ApplRowDescr;
+       ard = stmt->ApplRowDescr;
+       ird = stmt->ImplRowDescr;
 
        stmt->retrieved = 0;
        stmt->currentCol = 0;
@@ -70,12 +71,12 @@ SQLFetch_(ODBCStmt *stmt)
 
        stmt->State = FETCHED;
 
-       statusp = desc->sql_desc_array_status_ptr;
+       statusp = ird->sql_desc_array_status_ptr;
 
        if (stmt->retrieveData == SQL_RD_OFF) {
                /* don't really retrieve the data, just do as if,
                   updating the SQL_DESC_ARRAY_STATUS_PTR */
-               stmt->rowSetSize = desc->sql_desc_array_size;
+               stmt->rowSetSize = ard->sql_desc_array_size;
 
                if (stmt->startRow + stmt->rowSetSize > (SQLLEN) stmt->rowcount)
                        stmt->rowSetSize = stmt->rowcount - stmt->startRow;
@@ -87,20 +88,20 @@ SQLFetch_(ODBCStmt *stmt)
                if (statusp) {
                        for (row = 0; (SQLLEN) row < stmt->rowSetSize; row++)
                                *statusp++ = SQL_ROW_SUCCESS;
-                       for (; row < desc->sql_desc_array_size; row++)
+                       for (; row < ard->sql_desc_array_size; row++)
                                *statusp++ = SQL_ROW_NOROW;
                }
                return SQL_SUCCESS;
        }
 
-       if (desc->sql_desc_bind_offset_ptr)
-               offset = *desc->sql_desc_bind_offset_ptr;
+       if (ard->sql_desc_bind_offset_ptr)
+               offset = *ard->sql_desc_bind_offset_ptr;
        else
                offset = 0;
-       for (row = 0; row < desc->sql_desc_array_size; row++) {
+       for (row = 0; row < ard->sql_desc_array_size; row++) {
                if (mapi_fetch_row(stmt->hdl) == 0) {
-                       if (desc->sql_desc_rows_processed_ptr)
-                               *desc->sql_desc_rows_processed_ptr = row;
+                       if (ird->sql_desc_rows_processed_ptr)
+                               *ird->sql_desc_rows_processed_ptr = row;
                        switch (mapi_error(stmt->Dbc->mid)) {
                        case MOK:
                                if (row == 0)
@@ -126,8 +127,8 @@ SQLFetch_(ODBCStmt *stmt)
 
                stmt->rowSetSize++;
 
-               for (i = 1; i <= desc->sql_desc_count; i++) {
-                       rec = &desc->descRec[i];
+               for (i = 1; i <= ard->sql_desc_count; i++) {
+                       rec = &ard->descRec[i];
                        if (rec->sql_desc_data_ptr == NULL)
                                continue;
                        stmt->retrieved = 0;
@@ -148,11 +149,11 @@ SQLFetch_(ODBCStmt *stmt)
                if (statusp)
                        statusp++;
        }
-       if (desc->sql_desc_rows_processed_ptr)
-               *desc->sql_desc_rows_processed_ptr = (SQLULEN) stmt->rowSetSize;
+       if (ird->sql_desc_rows_processed_ptr)
+               *ird->sql_desc_rows_processed_ptr = (SQLULEN) stmt->rowSetSize;
 
        if (statusp)
-               while (row++ < desc->sql_desc_array_size)
+               while (row++ < ard->sql_desc_array_size)
                        *statusp++ = SQL_ROW_NOROW;
 
        if (stmt->rowSetSize > 1) {
diff --git a/java/build.xml b/java/build.xml
--- a/java/build.xml
+++ b/java/build.xml
@@ -48,6 +48,8 @@ All Rights Reserved.
     value="${jardir}/monetdb-jdbc-${JDBC_MAJOR}.${JDBC_MINOR}.jar" />
   <property name="jdbcclient-jar"
     value="${jardir}/jdbcclient.jar" />
+  <property name="jmonetdb-jar"
+    value="${jardir}/jmonetdb.jar" />
   <property name="mcl-jar"
     value="${jardir}/monetdb-mcl-${MCL_MAJOR}.${MCL_MINOR}.jar" />
 
@@ -70,7 +72,7 @@ All Rights Reserved.
 
   <target name="default">
     <antcall target="jar_jdbcclient" />
-    <antcall target="jar_mero_control" />
+    <antcall target="jar_jmonetdb" />
   </target>
 
   <target name="distjdbc">
@@ -130,6 +132,25 @@ All Rights Reserved.
     </jar>
   </target>
 
+  <!-- a convenience jar of MeroControl plus the JMonetDB utility -->
+  <target name="jar_jmonetdb"
+    depends="compile_mcl,compile_util,compile_mero_control,compile_client"
+    unless="uptodate.jmonetdb-jar">
+    <echo message="Building MeroControl + JmonetDB convenience jar" />
+    <jar jarfile="${jmonetdb-jar}">
+      <fileset dir="${builddir}">
+        <include name="${mero-control-package}/**/*.class" />
+        <include name="${mcl-package}/**/*.class" />
+        <include name="${client-package}/**/JMonetDB.class" />
+        <include name="${util-package}/**/*.class" />
+      </fileset>
+      <manifest>
+        <attribute name="Built-By" value="${user.name}" />
+        <attribute name="Main-Class" value="nl.cwi.monetdb.client.JMonetDB" />
+      </manifest>
+    </jar>
+  </target>
+
   <target name="jar_mero_control"
     depends="compile_mero_control">
     <jar jarfile="${mero-control-jar}">
@@ -279,6 +300,13 @@ All Rights Reserved.
         <include name="${mcl-package}/**/*.java" />
       </srcfiles>
     </uptodate>
+    <uptodate targetfile="${jmonetdb-jar}" property="uptodate.jmonetdb-jar">
+      <srcfiles dir="${srcdir}">
+        <include name="${client-package}/**/*.java" />
+        <include name="${mero-control-package}/**/*.java" />
+        <include name="${mcl-package}/**/*.java" />
+      </srcfiles>
+    </uptodate>
     <condition property="uptodate.drivers">
       <and>
         <uptodate 
targetfile="${builddir}/src/${jdbc-package}/MonetDriver.java">
diff --git a/java/src/nl/cwi/monetdb/client/JMonetDB.java 
b/java/src/nl/cwi/monetdb/client/JMonetDB.java
new file mode 100644
--- /dev/null
+++ b/java/src/nl/cwi/monetdb/client/JMonetDB.java
@@ -0,0 +1,153 @@
+/*
+ * 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.
+ */
+
+package nl.cwi.monetdb.client;
+
+import nl.cwi.monetdb.util.*;
+import nl.cwi.monetdb.merovingian.*;
+import java.io.*;
+import java.util.*;
+
+/**
+ * This program mimics the monetdb tool.  It is meant as demonstration
+ * and test of the MeroControl library.
+ *
+ * @author Fabian Groffen <[email protected]>
+ * @version 1.0
+ */
+
+public class JMonetDB {
+       private static PrintWriter out;
+
+       public final static void main(String[] args) throws Exception {
+               CmdLineOpts copts = new CmdLineOpts();
+
+               // arguments which take exactly one argument
+               copts.addOption("h", "host", CmdLineOpts.CAR_ONE, "localhost",
+                               "The hostname of the host that runs the MonetDB 
server.  " +
+                               "A port number can be supplied by use of a 
colon, i.e. " +
+                               "-h somehost:12345.");
+               copts.addOption("p", "port", CmdLineOpts.CAR_ONE, "50000",
+                               "The port number to connect to.");
+               copts.addOption("P", "passphrase", CmdLineOpts.CAR_ONE, null,
+                               "The passphrase to tell the MonetDB server");
+               copts.addOption("c", "command", CmdLineOpts.CAR_ONE_MANY, null,
+                               "The command to execute on the MonetDB server");
+
+               // arguments which have no argument(s)
+               copts.addOption(null, "help", CmdLineOpts.CAR_ZERO, null,
+                               "This help screen.");
+
+               // extended options
+               copts.addOption(null, "Xhash", CmdLineOpts.CAR_ONE, null,
+                               "Use the given hash algorithm during challenge 
response.  " +
+                               "Supported algorithm names: SHA256, SHA1, 
MD5.");
+               // arguments which can have zero or one argument(s)
+               copts.addOption(null, "Xdebug", CmdLineOpts.CAR_ZERO_ONE, null,
+                               "Writes a transmission log to disk for 
debugging purposes.  " +
+                               "If a file name is given, it is used, otherwise 
a file " +
+                               "called monet<timestamp>.log is created.  A 
given file " +
+                               "never be overwritten; instead a unique 
variation of the " +
+                               "file is used.");
+
+               try {
+                       copts.processArgs(args);
+               } catch (OptionsException e) {
+                       System.err.println("Error: " + e.getMessage());
+                       System.exit(-1);
+               }
+
+               if (copts.getOption("help").isPresent()) {
+                       System.out.print(
+"Usage java -jar jmonetdb.jar\n" +
+"                  -h host[:port] -p port -P passphrase [-X<opt>] -c cmd 
...\n" +
+"or using long option equivalents --host --port --passphrase.\n" +
+"Arguments may be written directly after the option like -p50000.\n" +
+"\n" +
+"If no host and port are given, localhost and 50000 are assumed.\n" +
+"\n" +
+"OPTIONS\n" +
+copts.produceHelpMessage()
+);
+                       System.exit(0);
+               }
+
+               out = new PrintWriter(new BufferedWriter(new 
OutputStreamWriter(System.out)));
+
+               String pass = copts.getOption("passphrase").getArgument();
+
+               // we need the password from the user, fetch it with a pseudo
+               // password protector
+               if (pass == null) {
+                       try {
+                               char[] tmp = 
PasswordField.getPassword(System.in, "passhrase: ");
+                               if (tmp != null) pass = String.valueOf(tmp);
+                       } catch (IOException ioe) {
+                               System.err.println("Invalid passphrase!");
+                               System.exit(-1);
+                       }
+                       System.out.println("");
+               }
+
+               // build the hostname
+               String host = copts.getOption("host").getArgument();
+               String sport = copts.getOption("port").getArgument();
+               int pos;
+               if ((pos = host.indexOf(":")) != -1) {
+                       sport = host.substring(pos + 1);
+                       host = host.substring(0, pos);
+               }
+               int port = Integer.parseInt(sport);
+
+               String hash = null;
+               if (copts.getOption("Xhash").isPresent())
+                       hash = copts.getOption("Xhash").getArgument();
+
+               if (!copts.getOption("command").isPresent()) {
+                       System.err.println("need a command to execute (-c)");
+                       System.exit(-1);
+               }
+
+               Control ctl = null;
+               try {
+                       ctl = new Control(host, port, pass);
+               } catch (IllegalArgumentException e) {
+                       System.err.println(e.getMessage());
+                       System.exit(-1);
+               }
+               // FIXME: Control needs to respect Xhash
+
+               String[] commands = copts.getOption("command").getArguments();
+               if (commands[0].equals("status")) {
+                       List<SabaothDB> sdbs;
+                       if (commands.length == 1) {
+                               sdbs = ctl.getAllStatuses();
+                       } else {
+                               sdbs = new ArrayList<SabaothDB>();
+                               for (int i = 1; i < commands.length; i++)
+                                       sdbs.add(ctl.getStatus(commands[i]));
+                       }
_______________________________________________
Checkin-list mailing list
[email protected]
http://mail.monetdb.org/mailman/listinfo/checkin-list

Reply via email to