summaryrefslogtreecommitdiff
path: root/libodbcpp/column.h
diff options
context:
space:
mode:
authorrandomdan <randomdan@localhost>2011-02-18 12:58:59 +0000
committerrandomdan <randomdan@localhost>2011-02-18 12:58:59 +0000
commitc3f2a299a734494a61a49709a8e4cc335570b3d3 (patch)
treeb5bf5bb8e01ad1e41ff5957c17fb60e3c353cfd9 /libodbcpp/column.h
parentAdd check function for when a connection is finished with, but you don't want... (diff)
downloadlibdbpp-odbc-c3f2a299a734494a61a49709a8e4cc335570b3d3.tar.bz2
libdbpp-odbc-c3f2a299a734494a61a49709a8e4cc335570b3d3.tar.xz
libdbpp-odbc-c3f2a299a734494a61a49709a8e4cc335570b3d3.zip
Handle the case when the driver tries to save more data than the buffer is big enough, and doesn't bother to mention it
Use the driver's bindSize as a hint as to how much buffer to allocate up front
Diffstat (limited to 'libodbcpp/column.h')
-rw-r--r--libodbcpp/column.h10
1 files changed, 5 insertions, 5 deletions
diff --git a/libodbcpp/column.h b/libodbcpp/column.h
index 71118f8..e981a14 100644
--- a/libodbcpp/column.h
+++ b/libodbcpp/column.h
@@ -4,6 +4,7 @@
#include "../libdbpp/column.h"
#include <typeinfo>
#include <glibmm/ustring.h>
+#include <algorithm>
#include "bind.h"
#include "param.h"
@@ -16,8 +17,7 @@ namespace ODBC {
void bind();
virtual void * rwDataAddress() = 0;
void rebind(DB::Command *, unsigned int idx) const;
- virtual void resize(SQLHANDLE);
- virtual void onScroll();
+ virtual bool resize();
virtual operator int () const { throw std::bad_cast(); }
virtual operator long () const { throw std::bad_cast(); }
@@ -45,11 +45,11 @@ namespace ODBC {
class CharArrayColumn : public Column, public Param {
public:
typedef std::vector<char> CharArray;
- CharArrayColumn(SelectCommand * sc, const Glib::ustring & n, unsigned int i) :
+ CharArrayColumn(SelectCommand * sc, const Glib::ustring & n, unsigned int i, SQLULEN sizeHint) :
DB::Column(n, i),
Column(sc, n, i)
{
- data.resize(256);
+ data.resize(std::max<SQLULEN>(sizeHint, 64) + 1);
}
virtual SQLSMALLINT ctype() const { return SQL_C_CHAR; }
virtual SQLSMALLINT stype() const { return SQL_CHAR; }
@@ -58,7 +58,7 @@ namespace ODBC {
virtual const void * dataAddress() const { return &data.front(); }
virtual void * rwDataAddress() { return &data.front(); }
void operator=(const Glib::ustring & d);
- void resize(SQLHANDLE);
+ bool resize();
virtual operator std::string () const { return std::string(&data.front(), bindLen); }
virtual operator Glib::ustring () const { return std::string(&data.front(), bindLen); }
virtual void apply(DB::HandleField &) const;