Date: Wednesday, January 11, 2006 @ 12:37:55
Author: zsolt
Path: /cvsroot/carob/libmysequoia/src
Modified: CarobStmt.cpp (1.4 -> 1.5) MySQLAPI.cpp (1.24 -> 1.25)
Corrected bind_params at the prepared statements.
Implemented metadata retrieval at the prepare phase.
---------------+
CarobStmt.cpp | 20 ++++++++++++++++----
MySQLAPI.cpp | 3 +--
2 files changed, 17 insertions(+), 6 deletions(-)
Index: libmysequoia/src/CarobStmt.cpp
diff -u libmysequoia/src/CarobStmt.cpp:1.4 libmysequoia/src/CarobStmt.cpp:1.5
--- libmysequoia/src/CarobStmt.cpp:1.4 Wed Jan 11 11:25:37 2006
+++ libmysequoia/src/CarobStmt.cpp Wed Jan 11 12:37:54 2006
@@ -81,6 +81,19 @@
m_stmt->param_count = c_stmt->getParameterCount();
m_stmt->state = MYSQL_STMT_PREPARE_DONE;
m_stmt->params = new MYSQL_BIND[m_stmt->param_count];
+
+ try
+ {
+ ResultSetMetaData *rsmdPtr = c_stmt->getMetaData();
+ if (rsmdPtr)
+ {
+ m_stmt->field_count = rsmdPtr->getColumnCount();
+ get_query_fields(m_stmt->fields, rsmdPtr);
+ m_stmt->bind = new MYSQL_BIND[m_stmt->field_count];
+ }
+ } catch (BackendException)
+ {
+ }
}
catch (CarobException &e)
{
@@ -110,6 +123,7 @@
}
else
{
+ memcpy(m_stmt->params, bind, sizeof(MYSQL_BIND) * m_stmt->param_count);
MYSQL_BIND *p = m_stmt->params;
for (unsigned int no=1; no <= m_stmt->param_count && !result; no++, p++)
{
@@ -143,10 +157,7 @@
}
if (!result)
- {
- memcpy(m_stmt->params, bind, sizeof(MYSQL_BIND) * m_stmt->param_count);
m_stmt->bind_param_done= true;
- }
}
LOG4CXX_DEBUG(logger, "Leaving bind_param.");
@@ -202,6 +213,8 @@
case MYSQL_TYPE_STRING:
c_stmt->setString(no, fromString(string((char *)p->buffer,
p->buffer_length)));
break;
+ default:
+ LOG4CXX_DEBUG(logger, "This should never happen!!");
/* TODO support other types
case MYSQL_TYPE_TIME:
case MYSQL_TYPE_DATE:
@@ -210,7 +223,6 @@
case MYSQL_TYPE_DECIMAL:
case MYSQL_TYPE_NEWDECIMAL:
case MYSQL_TYPE_NULL:
- default:
*/
}
}
Index: libmysequoia/src/MySQLAPI.cpp
diff -u libmysequoia/src/MySQLAPI.cpp:1.24 libmysequoia/src/MySQLAPI.cpp:1.25
--- libmysequoia/src/MySQLAPI.cpp:1.24 Wed Jan 11 10:37:32 2006
+++ libmysequoia/src/MySQLAPI.cpp Wed Jan 11 12:37:54 2006
@@ -1130,7 +1130,7 @@
{
LOG4CXX_DEBUG(logger, "Entering mysql_stmt_prepare.");
- int result = 0;
+ int result = 1;
if (isCarobObject(stmt))
result = getCarobStmt(stmt)->prepare(query, length);
@@ -1138,7 +1138,6 @@
{
LOG4CXX_ERROR(logger, "The given mysql stmt pointer was not initialized
with mysql_stmt_init.");
//Todo maybe better errorhandling?
- result = 1;
}
LOG4CXX_DEBUG(logger, "Leaving mysql_stmt_prepare.");
_______________________________________________
Carob-commits mailing list
[email protected]
https://forge.continuent.org/mailman/listinfo/carob-commits