Commit b634576c authored by Mateusz Loskot's avatar Mateusz Loskot

Move DB2 maxBuffer out of public soci-db2.h

parent 159dfce8
//
// Copyright (C) 2013 Mateusz Loskot <mateusz@loskot.net>
// Copyright (C) 2011-2013 Denis Chapligin
// Copyright (C) 2004-2006 Maciej Sobczak, Stephen Hutton
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
#ifndef SOCI_DB2_COMMON_H_INCLUDED
#define SOCI_DB2_COMMON_H_INCLUDED
#include <cstddef>
namespace soci { namespace details { namespace db2 {
const std::size_t cli_max_buffer = 1024 * 1024 * 1024; //CLI limit is about 3 GB, but 1GB should be enough
}}} // namespace soci::details::db2
#endif // SOCI_DB2_COMMON_H_INCLUDED
......@@ -31,6 +31,7 @@
#include <vector>
#include <iostream>
#include <sstream>
#include <string>
#include <cstring>
#include <sqlcli1.h>
......@@ -38,7 +39,6 @@
namespace soci
{
static const std::size_t maxBuffer = 1024 * 1024 * 1024; //CLI limit is about 3 GB, but 1GB should be enough
class db2_soci_error : public soci_error {
public:
db2_soci_error(std::string const & msg, SQLRETURN rc) : soci_error(msg),errorCode(rc) {};
......
......@@ -8,6 +8,7 @@
#define SOCI_DB2_SOURCE
#include "soci-db2.h"
#include "common.h"
#include <ctime>
using namespace soci;
......@@ -37,7 +38,7 @@ void db2_standard_into_type_backend::define_by_pos(
// Patch: set to min between column size and 100MB (used ot be 32769)
// Column size for text data type can be too large for buffer allocation
size = statement_.column_size(this->position);
size = size > maxBuffer ? maxBuffer : size;
size = size > details::db2::cli_max_buffer ? details::db2::cli_max_buffer : size;
size++;
buf = new char[size];
data = buf;
......@@ -133,7 +134,7 @@ void db2_standard_into_type_backend::post_fetch(
{
std::string *s = static_cast<std::string *>(data);
*s = buf;
if (s->size() >= (maxBuffer - 1))
if (s->size() >= (details::db2::cli_max_buffer - 1))
{
throw soci_error("Buffer size overflow; maybe got too large string");
}
......
......@@ -186,8 +186,9 @@ void db2_standard_use_type_backend::pre_use(indicator const *ind)
}
}
void db2_standard_use_type_backend::post_use(bool gotData, indicator *ind)
void db2_standard_use_type_backend::post_use(bool /*gotData*/, indicator* /*ind*/)
{
}
void db2_standard_use_type_backend::clean_up()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment