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

Merge with Dec2011 branch.


diffs (169 lines):

diff --git a/clients/ChangeLog.Dec2011 b/clients/ChangeLog.Dec2011
--- a/clients/ChangeLog.Dec2011
+++ b/clients/ChangeLog.Dec2011
@@ -1,6 +1,12 @@
 # ChangeLog file for clients
 # This file is updated with Maddlog
 
+* Wed Nov  2 2011 Sjoerd Mullender <[email protected]>
+- ODBC: Improved internal query for SQLSpecialColumns.  Before, the query
+  returned all columns taking part in a PRIMARY KEY *and* all columns
+  taking part in a UNIQUE constraint.  Now it returns only one or the
+  other set.
+
 * Fri Oct 28 2011 Sjoerd Mullender <[email protected]>
 - ODBC: The database name is now used as the catalog name throughout.
   Functions that return a catalog name return the database name, and
diff --git a/clients/odbc/driver/SQLSpecialColumns.c 
b/clients/odbc/driver/SQLSpecialColumns.c
--- a/clients/odbc/driver/SQLSpecialColumns.c
+++ b/clients/odbc/driver/SQLSpecialColumns.c
@@ -172,7 +172,9 @@ SQLSpecialColumns_(ODBCStmt *stmt,
                /* Note: SCOPE is SQL_SCOPE_TRANSACTION */
                /* Note: PSEUDO_COLUMN is SQL_PC_NOT_PSEUDO */
                sprintf(query_end,
-                       "select cast(%d as smallint) as scope,"
+                       "with sc as ("
+                       "select t.id as table_id, k.type as type,"
+                             " cast(%d as smallint) as scope,"
                              " c.\"name\" as column_name,"
                              " case c.\"type\""
                                   " when 'bigint' then %d"
@@ -354,8 +356,10 @@ SQLSpecialColumns_(ODBCStmt *stmt,
                                        " end"
                              " end as decimal_digits,"
                              " cast(%d as smallint) as pseudo_column"
-                       " from sys.\"schemas\" s, sys.\"tables\" t,"
-                            " sys.\"columns\" c, sys.\"keys\" k,"
+                       " from sys.\"schemas\" s,"
+                            " sys.\"tables\" t,"
+                            " sys.\"columns\" c,"
+                            " sys.\"keys\" k,"
                             " sys.\"objects\" kc,"
                             " sys.\"env\"() e "
                        " where s.\"id\" = t.\"schema_id\" and"
@@ -363,7 +367,7 @@ SQLSpecialColumns_(ODBCStmt *stmt,
                              " t.\"id\" = k.\"table_id\" and"
                              " c.\"name\" = kc.\"name\" and"
                              " kc.\"id\" = k.\"id\" and"
-                             " k.\"type\" in (0, 1) and"
+                             " k.\"type\" = 0 and"
                              " e.\"name\" = 'gdk_dbname'",
                        /* scope: */
                        SQL_SCOPE_TRANSACTION,
@@ -382,7 +386,7 @@ SQLSpecialColumns_(ODBCStmt *stmt,
                        SQL_VARCHAR, SQL_INTEGER, SQL_BIGINT,
                        /* pseudo_column: */
                        SQL_PC_NOT_PSEUDO);
-               assert(strlen(query) < 4800);
+               assert(strlen(query) < 4300);
                query_end += strlen(query_end);
                /* TODO: improve the SQL to get the correct result:
                   - only one set of columns should be returned, also
@@ -423,6 +427,39 @@ SQLSpecialColumns_(ODBCStmt *stmt,
                        query_end += strlen(query_end);
                }
 
+               /* we don't actually need a UNION.  Except for a bug
+                * in the server, we could use instead: "select
+                * sk.scope, sk.column_name, sk.data_type,
+                * sk.type_name, sk.column_size, sk.buffer_length,
+                * sk.decimal_digits, sk.pseudo_column from sk where
+                * (sk.type = 0 and sk.table_id in (select tid from
+                * tid)) or (sk.type = 1 and sk.table_id not in
+                * (select tid from tid))" as SELECT query after the
+                * definition of "tid". */
+               strcpy(query_end,
+                      "),"
+                      " tid as ("
+                          "select t.id as tid"
+                          " from sys._tables t, sys.keys k"
+                          " where t.id = k.table_id and k.type = 0"
+                      ")"
+                      " select sc.scope, sc.column_name, sc.data_type,"
+                             " sc.type_name, sc.column_size,"
+                             " sc.buffer_length, sc.decimal_digits,"
+                             " sc.pseudo_column"
+                      " from sc"
+                      " where sc.type = 0 and"
+                            " sc.table_id in (select tid from tid)"
+                      " union"
+                      " select sc.scope, sc.column_name, sc.data_type,"
+                             " sc.type_name, sc.column_size,"
+                             " sc.buffer_length, sc.decimal_digits,"
+                             " sc.pseudo_column"
+                      " from sc"
+                      " where sc.type = 1 and"
+                            " sc.table_id not in (select tid from tid)");
+               query_end += strlen(query_end);
+
                /* no ordering needed */
        } else {
                assert(IdentifierType == SQL_ROWVER);
diff --git a/monetdb5/modules/kernel/calc.mx b/monetdb5/modules/kernel/calc.mx
--- a/monetdb5/modules/kernel/calc.mx
+++ b/monetdb5/modules/kernel/calc.mx
@@ -341,7 +341,7 @@ comment "Concatenate two strings";
                comment "negative value";
                command sizeof(x:@1):int
                address CALCsizeof@1;
-               command sign(x:@1) :@1 
+               command sign(x:@1) :int
                address CALCunary@1SIGN 
                comment "Returns +1, 0, -1 based on the sign of the given 
expression";
 @= unary_ops
@@ -620,7 +620,7 @@ str CALCsizeof@1(int *res , @1 *a ) {
 @:calc_unop(ABS,calc_abs,@1)@
 @:check_unop(INV,calc_inv,@1)@
 @:calc_unop(NEG,calc_neg,@1)@
-@:calc_unop(SIGN,calc_sign,@1)@
+@:calc_unopint(SIGN,calc_sign,@1)@
 @:calc_length(@1)@
 @
 @c
@@ -1188,6 +1188,20 @@ str CALCunary@3@1(@3 *res , @3 *a ) {
    return(MAL_SUCCEED);
 }
 @
+@= calc_unopint
+calc_export str CALCunary@3@1(int *res , @3 *a );
+str CALCunary@3@1(int *res , @3 *a ) {
+#ifdef DEBUG
+       printf( "CALCunary@3@1\n");
+#endif
+   if (*a == @3_nil) {
+          *res = int_nil;
+   } else {
+                  *res = (int) (@2 (*a));
+   }
+   return(MAL_SUCCEED);
+}
+@
 @= check_unop
 calc_export str CALCunarycheck@3@1(@3 *res , @3 *a );
 str CALCunarycheck@3@1(@3 *res , @3 *a ) {
diff --git a/sql/ChangeLog.Aug2011 b/sql/ChangeLog.Aug2011
--- a/sql/ChangeLog.Aug2011
+++ b/sql/ChangeLog.Aug2011
@@ -1,6 +1,10 @@
 # ChangeLog file for sql
 # This file is updated with Maddlog
 
+* Wed Nov  2 2011 Sjoerd Mullender <[email protected]>
+- Changed a bug where the sign() function returned the same type as its
+  argument instead of always an INTEGER.
+
 * Wed Oct 26 2011 Fabian Groffen <[email protected]>
 - Added a fix for bug #2834, which caused weird (failing) behaviour
   with PreparedStatements.
diff --git a/sql/common/sql_types.c b/sql/common/sql_types.c
--- a/sql/common/sql_types.c
+++ b/sql/common/sql_types.c
@@ -1307,7 +1307,7 @@ sqltypeinit(void)
                sql_create_func("sql_neg", "calc", "-", *t, NULL, *t, INOUT);
                sql_create_func("sql_pos", "calc", "+", *t, NULL, *t, INOUT);
                sql_create_func("abs", "calc", "abs", *t, NULL, *t, SCALE_FIX);
-               sql_create_func("sign", "calc", "sign", *t, NULL, *t, 
SCALE_FIX);
+               sql_create_func("sign", "calc", "sign", *t, NULL, INT, 
SCALE_NONE);
                /* scale fixing for all numbers */
                sql_create_func("scale_up", "calc", "*", *t, lt->type, *t, 
SCALE_NONE);
                sql_create_func("scale_down", "sql", "dec_round", *t, lt->type, 
*t, SCALE_NONE);
_______________________________________________
Checkin-list mailing list
[email protected]
http://mail.monetdb.org/mailman/listinfo/checkin-list

Reply via email to