Date: Wednesday, January 11, 2006 @ 17:25:05
  Author: marc
    Path: /cvsroot/carob/odbsequoia/src

   Added: abstract_item.cpp (1.1)
Modified: GNUmakefile (1.3 -> 1.4) abstract_item.hpp (1.2 -> 1.3)
          explicit_type.cpp (1.2 -> 1.3)

Implemented SQLGetDiagRecW() in abstract_item.cpp. No setter yet.


-------------------+
 GNUmakefile       |    2 -
 abstract_item.cpp |   58 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 abstract_item.hpp |   20 +++++++++++++++++
 explicit_type.cpp |   55 +++++++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 134 insertions(+), 1 deletion(-)


Index: odbsequoia/src/GNUmakefile
diff -u odbsequoia/src/GNUmakefile:1.3 odbsequoia/src/GNUmakefile:1.4
--- odbsequoia/src/GNUmakefile:1.3      Mon Jan  9 11:47:29 2006
+++ odbsequoia/src/GNUmakefile  Wed Jan 11 17:25:05 2006
@@ -29,7 +29,7 @@
 CAROB=carob
 
 
-OBJS=util.o explicit_type.o env.o connect.o stmt.o
+OBJS=util.o explicit_type.o env.o connect.o stmt.o abstract_item.o
 CXXFLAGS=-Wall -g3 -I${CAROB_PATH}/include
 
 
Index: odbsequoia/src/abstract_item.cpp
diff -u /dev/null odbsequoia/src/abstract_item.cpp:1.1
--- /dev/null   Wed Jan 11 17:25:05 2006
+++ odbsequoia/src/abstract_item.cpp    Wed Jan 11 17:25:05 2006
@@ -0,0 +1,58 @@
+/*
+ * Sequoia: Database clustering technology.
+ * Copyright (C) 2006 Continuent, Inc.
+ * Contact: [EMAIL PROTECTED]
+ * 
+ * Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Initial developer(s): Marc Herbert
+ * Contributor(s): 
+ */
+
+#include "util.hpp"
+
+#include "abstract_item.hpp"
+
+using namespace ODBSeqNS;
+
+SQLRETURN
+ODBCItem::get_diag_recw(SQLSMALLINT RecNumber,
+                        SQLWCHAR * Sqlstate, SQLINTEGER * NativeErrorPtr,
+                        SQLWCHAR * MessageText,
+                        SQLSMALLINT BufferLength, SQLSMALLINT * TextLengthPtr)
+{
+
+    if (RecNumber > (SQLSMALLINT) this->diag_records.size())
+        return SQL_NO_DATA;
+
+    const diag_record_t& this_rec = this->diag_records[RecNumber - 1];
+
+    toSQLW(this_rec.sql_state, Sqlstate, 6, TextLengthPtr /* ignored */);
+
+    *NativeErrorPtr = this_rec.native_err;
+
+    if(toSQLW(this_rec.message, MessageText, BufferLength, TextLengthPtr))
+        return SQL_SUCCESS_WITH_INFO; // truncated
+    else
+        return SQL_SUCCESS;
+}
+
+
+
+/*
+ * Local Variables:
+ * c-file-style: "bsd"
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
Index: odbsequoia/src/abstract_item.hpp
diff -u odbsequoia/src/abstract_item.hpp:1.2 
odbsequoia/src/abstract_item.hpp:1.3
--- odbsequoia/src/abstract_item.hpp:1.2        Mon Jan  9 11:46:02 2006
+++ odbsequoia/src/abstract_item.hpp    Wed Jan 11 17:25:05 2006
@@ -20,14 +20,34 @@
  * Contributor(s): 
  */
 
+#include <sql.h>
+#include <sqlucode.h>
+
+#include <vector>
+
 namespace ODBSeqNS {
 
+typedef struct _diagrec
+{
+    std::wstring sql_state;
+    SQLINTEGER native_err;
+    std::wstring message;
+} diag_record_t;
 
 class ODBCItem
 {
 public:
     ODBCItem(ODBCItem& creator) : owner(creator) { }
+
+    virtual SQLRETURN
+    get_diag_recw(SQLSMALLINT RecNumber,
+                  SQLWCHAR * Sqlstate, SQLINTEGER * NativeErrorPtr,
+                  SQLWCHAR * MessageText,
+                  SQLSMALLINT BufferLength, SQLSMALLINT * TextLengthPtr);
+    virtual ~ODBCItem() { };
+
 protected:
+    std::vector<diag_record_t> diag_records;
     ODBCItem& owner;
 };
 
Index: odbsequoia/src/explicit_type.cpp
diff -u odbsequoia/src/explicit_type.cpp:1.2 
odbsequoia/src/explicit_type.cpp:1.3
--- odbsequoia/src/explicit_type.cpp:1.2        Fri Jan  6 16:19:48 2006
+++ odbsequoia/src/explicit_type.cpp    Wed Jan 11 17:25:05 2006
@@ -32,6 +32,30 @@
 
 using namespace ODBSeqNS;
 
+
+namespace {
+
+ODBCItem *
+objectify(SQLSMALLINT HandleType, SQLHANDLE Handle)
+{
+    switch (HandleType)
+    {
+    case SQL_HANDLE_DESC:
+        return NULL; // TODO
+
+    case SQL_HANDLE_ENV:
+    case SQL_HANDLE_DBC:
+    case SQL_HANDLE_STMT:
+        return static_cast<ODBCItem *>(Handle);
+
+    default:
+        return NULL; // TODO: invalid handletype        
+    }
+}
+
+}
+
+
 /*  SQLAllocConnect/SQLAllocEnv/SQLAllocStmt mapped to SQLAllocHandle() here 
by DM */
 SQLRETURN              
 SQLAllocHandle(SQLSMALLINT HandleType, SQLHANDLE InputHandle,
@@ -76,8 +100,39 @@
     return ret;
 }
 
+SQLRETURN
+SQLGetDiagRecW(SQLSMALLINT HandleType, SQLHANDLE Handle,
+               SQLSMALLINT RecNumber,
+               SQLWCHAR * Sqlstate, SQLINTEGER * NativeErrorPtr,
+               SQLWCHAR * MessageText,
+               SQLSMALLINT BufferLength, SQLSMALLINT * TextLengthPtr)
+{
+    ODBCItem *item = objectify(HandleType, Handle);
+    
+    return item->get_diag_recw(RecNumber, Sqlstate, NativeErrorPtr,
+                               MessageText, BufferLength, TextLengthPtr);
+}
 
 
+SQLRETURN
+SQLGetDiagFieldW(
+     SQLSMALLINT     HandleType,
+     SQLHANDLE     Handle,
+     SQLSMALLINT     RecNumber,
+     SQLSMALLINT     DiagIdentifier,
+     SQLPOINTER     DiagInfoPtr,
+     SQLSMALLINT     BufferLength,
+     SQLSMALLINT *     StringLengthPtr)
+{
+    ODBCItem *item = objectify(HandleType, Handle);
+
+    // Not implemented: debugguer trap
+    item = NULL; delete item;
+    
+    return SQL_ERROR;
+
+}
+
 /*
  * Local Variables:
  * c-file-style: "bsd"

_______________________________________________
Carob-commits mailing list
[email protected]
https://forge.continuent.org/mailman/listinfo/carob-commits

Reply via email to