Skip to content

Commit

Permalink
Update get_affected_rows to int64_t return value usage
Browse files Browse the repository at this point in the history
  • Loading branch information
zann1x committed Jun 8, 2022
1 parent 25e01db commit ad41518
Show file tree
Hide file tree
Showing 21 changed files with 48 additions and 42 deletions.
3 changes: 2 additions & 1 deletion include/soci/db2/soci-db2.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include <sstream>
#include <string>
#include <cstring>
#include <stdint.h>

#include <sqlcli1.h>

Expand Down Expand Up @@ -190,7 +191,7 @@ struct SOCI_DB2_DECL db2_statement_backend : details::statement_backend
exec_fetch_result execute(int number) SOCI_OVERRIDE;
exec_fetch_result fetch(int number) SOCI_OVERRIDE;

long long get_affected_rows() SOCI_OVERRIDE;
int64_t get_affected_rows() SOCI_OVERRIDE;
int get_number_of_rows() SOCI_OVERRIDE;
std::string get_parameter_name(int index) const SOCI_OVERRIDE;

Expand Down
3 changes: 2 additions & 1 deletion include/soci/empty/soci-empty.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include <soci/soci-backend.h>

#include <cstddef>
#include <stdint.h>
#include <string>

namespace soci
Expand Down Expand Up @@ -107,7 +108,7 @@ struct SOCI_EMPTY_DECL empty_statement_backend : details::statement_backend
exec_fetch_result execute(int number) SOCI_OVERRIDE;
exec_fetch_result fetch(int number) SOCI_OVERRIDE;

long long get_affected_rows() SOCI_OVERRIDE;
int64_t get_affected_rows() SOCI_OVERRIDE;
int get_number_of_rows() SOCI_OVERRIDE;
std::string get_parameter_name(int index) const SOCI_OVERRIDE;

Expand Down
4 changes: 2 additions & 2 deletions include/soci/firebird/soci-firebird.h
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ struct firebird_statement_backend : details::statement_backend
exec_fetch_result execute(int number) SOCI_OVERRIDE;
exec_fetch_result fetch(int number) SOCI_OVERRIDE;

long long get_affected_rows() SOCI_OVERRIDE;
int64_t get_affected_rows() SOCI_OVERRIDE;
int get_number_of_rows() SOCI_OVERRIDE;
std::string get_parameter_name(int index) const SOCI_OVERRIDE;

Expand Down Expand Up @@ -228,7 +228,7 @@ struct firebird_statement_backend : details::statement_backend
int rowsFetched_;
bool endOfRowSet_;

long long rowsAffectedBulk_; // number of rows affected by the last bulk operation
int64_t rowsAffectedBulk_; // number of rows affected by the last bulk operation

virtual void exchangeData(bool gotData, int row);
virtual void prepareSQLDA(XSQLDA ** sqldap, short size = 10);
Expand Down
4 changes: 2 additions & 2 deletions include/soci/mysql/soci-mysql.h
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ struct mysql_statement_backend : details::statement_backend
exec_fetch_result execute(int number) SOCI_OVERRIDE;
exec_fetch_result fetch(int number) SOCI_OVERRIDE;

long long get_affected_rows() SOCI_OVERRIDE;
int64_t get_affected_rows() SOCI_OVERRIDE;
int get_number_of_rows() SOCI_OVERRIDE;
std::string get_parameter_name(int index) const SOCI_OVERRIDE;

Expand All @@ -201,7 +201,7 @@ struct mysql_statement_backend : details::statement_backend
std::vector<std::string> queryChunks_;
std::vector<std::string> names_; // list of names for named binds

long long rowsAffectedBulk_; // number of rows affected by the last bulk operation
int64_t rowsAffectedBulk_; // number of rows affected by the last bulk operation

int numberOfRows_; // number of rows retrieved from the server
int currentRow_; // "current" row number to consume in postFetch
Expand Down
4 changes: 2 additions & 2 deletions include/soci/odbc/soci-odbc.h
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ struct odbc_statement_backend : details::statement_backend
exec_fetch_result execute(int number) SOCI_OVERRIDE;
exec_fetch_result fetch(int number) SOCI_OVERRIDE;

long long get_affected_rows() SOCI_OVERRIDE;
int64_t get_affected_rows() SOCI_OVERRIDE;
int get_number_of_rows() SOCI_OVERRIDE;
std::string get_parameter_name(int index) const SOCI_OVERRIDE;

Expand All @@ -271,7 +271,7 @@ struct odbc_statement_backend : details::statement_backend
bool boundByName_;
bool boundByPos_;

long long rowsAffected_; // number of rows affected by the last operation
int64_t rowsAffected_; // number of rows affected by the last operation

std::string query_;
std::vector<std::string> names_; // list of names for named binds
Expand Down
2 changes: 1 addition & 1 deletion include/soci/oracle/soci-oracle.h
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ struct oracle_statement_backend : details::statement_backend
exec_fetch_result execute(int number) SOCI_OVERRIDE;
exec_fetch_result fetch(int number) SOCI_OVERRIDE;

long long get_affected_rows() SOCI_OVERRIDE;
int64_t get_affected_rows() SOCI_OVERRIDE;
int get_number_of_rows() SOCI_OVERRIDE;
std::string get_parameter_name(int index) const SOCI_OVERRIDE;

Expand Down
4 changes: 2 additions & 2 deletions include/soci/postgresql/soci-postgresql.h
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ struct postgresql_statement_backend : details::statement_backend
exec_fetch_result execute(int number) SOCI_OVERRIDE;
exec_fetch_result fetch(int number) SOCI_OVERRIDE;

long long get_affected_rows() SOCI_OVERRIDE;
int64_t get_affected_rows() SOCI_OVERRIDE;
int get_number_of_rows() SOCI_OVERRIDE;
std::string get_parameter_name(int index) const SOCI_OVERRIDE;

Expand All @@ -288,7 +288,7 @@ struct postgresql_statement_backend : details::statement_backend
std::string statementName_;
std::vector<std::string> names_; // list of names for named binds

long long rowsAffectedBulk_; // number of rows affected by the last bulk operation
int64_t rowsAffectedBulk_; // number of rows affected by the last bulk operation

int numberOfRows_; // number of rows retrieved from the server
int currentRow_; // "current" row number to consume in postFetch
Expand Down
2 changes: 1 addition & 1 deletion include/soci/soci-backend.h
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ class statement_backend
virtual exec_fetch_result execute(int number) = 0;
virtual exec_fetch_result fetch(int number) = 0;

virtual long long get_affected_rows() = 0;
virtual int64_t get_affected_rows() = 0;
virtual int get_number_of_rows() = 0;

virtual std::string get_parameter_name(int index) const = 0;
Expand Down
10 changes: 5 additions & 5 deletions include/soci/soci-simple.h
Original file line number Diff line number Diff line change
Expand Up @@ -205,11 +205,11 @@ SOCI_DECL blob_handle soci_get_use_blob (statement_handle st, char const * nam


// statement preparation and execution
SOCI_DECL void soci_prepare(statement_handle st, char const * query);
SOCI_DECL int soci_execute(statement_handle st, int withDataExchange);
SOCI_DECL long long soci_get_affected_rows(statement_handle st);
SOCI_DECL int soci_fetch(statement_handle st);
SOCI_DECL int soci_got_data(statement_handle st);
SOCI_DECL void soci_prepare(statement_handle st, char const * query);
SOCI_DECL int soci_execute(statement_handle st, int withDataExchange);
SOCI_DECL int64_t soci_get_affected_rows(statement_handle st);
SOCI_DECL int soci_fetch(statement_handle st);
SOCI_DECL int soci_got_data(statement_handle st);

SOCI_DECL int soci_statement_state(statement_handle s);
SOCI_DECL char const * soci_statement_error_message(statement_handle s);
Expand Down
4 changes: 2 additions & 2 deletions include/soci/sqlite3/soci-sqlite3.h
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ struct sqlite3_statement_backend : details::statement_backend
exec_fetch_result execute(int number) SOCI_OVERRIDE;
exec_fetch_result fetch(int number) SOCI_OVERRIDE;

long long get_affected_rows() SOCI_OVERRIDE;
int64_t get_affected_rows() SOCI_OVERRIDE;
int get_number_of_rows() SOCI_OVERRIDE;
std::string get_parameter_name(int index) const SOCI_OVERRIDE;

Expand All @@ -239,7 +239,7 @@ struct sqlite3_statement_backend : details::statement_backend


bool hasVectorIntoElements_;
long long rowsAffectedBulk_; // number of rows affected by the last bulk operation
int64_t rowsAffectedBulk_; // number of rows affected by the last bulk operation

private:
exec_fetch_result load_rowset(int totalRows);
Expand Down
5 changes: 3 additions & 2 deletions include/soci/statement.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include "soci/row.h"
// std
#include <cstddef>
#include <stdint.h>
#include <string>
#include <vector>

Expand Down Expand Up @@ -63,7 +64,7 @@ class SOCI_DECL statement_impl
void define_and_bind();
void undefine_and_bind();
bool execute(bool withDataExchange = false);
long long get_affected_rows();
int64_t get_affected_rows();
bool fetch();
void describe();
void set_row(row * r);
Expand Down Expand Up @@ -217,7 +218,7 @@ class SOCI_DECL statement
return gotData_;
}

long long get_affected_rows()
int64_t get_affected_rows()
{
return impl_->get_affected_rows();
}
Expand Down
5 changes: 3 additions & 2 deletions src/backends/db2/statement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#define SOCI_DB2_SOURCE
#include "soci/db2/soci-db2.h"
#include <cctype>
#include <stdint.h>

using namespace soci;
using namespace soci::details;
Expand Down Expand Up @@ -184,7 +185,7 @@ db2_statement_backend::fetch(int number )
return ef_success;
}

long long db2_statement_backend::get_affected_rows()
int64_t db2_statement_backend::get_affected_rows()
{
SQLLEN rows;

Expand All @@ -198,7 +199,7 @@ long long db2_statement_backend::get_affected_rows()
throw soci_error("Error getting affected row count: statement did not perform an update, insert, delete, or merge");
}

return rows;
return static_cast<int64_t>(rows);
}

int db2_statement_backend::get_number_of_rows()
Expand Down
3 changes: 2 additions & 1 deletion src/backends/empty/statement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

#define SOCI_EMPTY_SOURCE
#include "soci/empty/soci-empty.h"
#include <stdint.h>

#ifdef _MSC_VER
#pragma warning(disable:4355)
Expand Down Expand Up @@ -51,7 +52,7 @@ empty_statement_backend::fetch(int /* number */)
return ef_success;
}

long long empty_statement_backend::get_affected_rows()
int64_t empty_statement_backend::get_affected_rows()
{
// ...
return -1;
Expand Down
9 changes: 5 additions & 4 deletions src/backends/firebird/statement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ firebird_statement_backend::execute(int number)

if (useType_ == eVector)
{
long long rowsAffectedBulkTemp = 0;
int64_t rowsAffectedBulkTemp = 0;

// Here we have to explicitly loop to achieve the
// effect of inserting or updating with vector use elements.
Expand Down Expand Up @@ -562,7 +562,7 @@ void firebird_statement_backend::exchangeData(bool gotData, int row)
}
}

long long firebird_statement_backend::get_affected_rows()
int64_t firebird_statement_backend::get_affected_rows()
{
if (rowsAffectedBulk_ >= 0)
{
Expand Down Expand Up @@ -597,7 +597,7 @@ long long firebird_statement_backend::get_affected_rows()

// Examine the 4 sub-blocks each of which has a header indicating the block
// type, its value length in bytes and the value itself.
long long row_count = 0;
int64_t row_count = 0;

for ( char* p = sql_rec_buf; !row_count && p < sql_rec_buf + length; )
{
Expand All @@ -611,7 +611,8 @@ long long firebird_statement_backend::get_affected_rows()
int len = isc_vax_integer(p, 2);
p += 2;

row_count += isc_vax_integer(p, static_cast<short>(len));
row_count += static_cast<int64_t>(
isc_vax_integer(p, static_cast<short>(len)));
p += len;
}
break;
Expand Down
8 changes: 4 additions & 4 deletions src/backends/mysql/statement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ mysql_statement_backend::execute(int number)
"Binding for use elements must be either by position "
"or by name.");
}
long long rowsAffectedBulkTemp = -1;
int64_t rowsAffectedBulkTemp = -1;
for (int i = 0; i != numberOfExecutions; ++i)
{
std::vector<char *> paramValues;
Expand Down Expand Up @@ -245,7 +245,7 @@ mysql_statement_backend::execute(int number)
{
rowsAffectedBulkTemp = 0;
}
rowsAffectedBulkTemp += static_cast<long long>(mysql_affected_rows(session_.conn_));
rowsAffectedBulkTemp += static_cast<int64_t>(mysql_affected_rows(session_.conn_));
}
if (mysql_field_count(session_.conn_) != 0)
{
Expand Down Expand Up @@ -365,13 +365,13 @@ mysql_statement_backend::fetch(int number)
}
}

long long mysql_statement_backend::get_affected_rows()
int64_t mysql_statement_backend::get_affected_rows()
{
if (rowsAffectedBulk_ >= 0)
{
return rowsAffectedBulk_;
}
return static_cast<long long>(mysql_affected_rows(session_.conn_));
return static_cast<int64_t>(mysql_affected_rows(session_.conn_));
}

int mysql_statement_backend::get_number_of_rows()
Expand Down
2 changes: 1 addition & 1 deletion src/backends/odbc/statement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ odbc_statement_backend::fetch(int number)
return res;
}

long long odbc_statement_backend::get_affected_rows()
int64_t odbc_statement_backend::get_affected_rows()
{
return rowsAffected_;
}
Expand Down
4 changes: 2 additions & 2 deletions src/backends/oracle/statement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ statement_backend::exec_fetch_result oracle_statement_backend::fetch(int number)
}
}

long long oracle_statement_backend::get_affected_rows()
int64_t oracle_statement_backend::get_affected_rows()
{
ub4 row_count;
sword res = OCIAttrGet(static_cast<dvoid*>(stmtp_),
Expand All @@ -129,7 +129,7 @@ long long oracle_statement_backend::get_affected_rows()
throw_oracle_soci_error(res, session_.errhp_);
}

return row_count;
return static_cast<int64_t>(row_count);
}

int oracle_statement_backend::get_number_of_rows()
Expand Down
6 changes: 3 additions & 3 deletions src/backends/postgresql/statement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ postgresql_statement_backend::execute(int number)
"Binding for use elements must be either by position "
"or by name.");
}
long long rowsAffectedBulkTemp = 0;
int64_t rowsAffectedBulkTemp = 0;
for (int i = 0; i != numberOfExecutions; ++i)
{
std::vector<char *> paramValues;
Expand Down Expand Up @@ -677,13 +677,13 @@ postgresql_statement_backend::fetch(int number)
}
}

long long postgresql_statement_backend::get_affected_rows()
int64_t postgresql_statement_backend::get_affected_rows()
{
// PQcmdTuples() doesn't really modify the result but it takes a non-const
// pointer to it, so we can't rely on implicit conversion here.
const char * const resultStr = PQcmdTuples(result_.get_result());
char * end;
long long result = std::strtoll(resultStr, &end, 0);
int64_t result = static_cast<int64_t>(std::strtoll(resultStr, &end, 0));
if (end != resultStr)
{
return result;
Expand Down
4 changes: 2 additions & 2 deletions src/backends/sqlite3/statement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ sqlite3_statement_backend::bind_and_execute(int number)
{
statement_backend::exec_fetch_result retVal = ef_no_data;

long long rowsAffectedBulkTemp = 0;
int64_t rowsAffectedBulkTemp = 0;

rowsAffectedBulk_ = -1;

Expand Down Expand Up @@ -393,7 +393,7 @@ sqlite3_statement_backend::fetch(int number)

}

long long sqlite3_statement_backend::get_affected_rows()
int64_t sqlite3_statement_backend::get_affected_rows()
{
if (rowsAffectedBulk_ >= 0)
{
Expand Down
2 changes: 1 addition & 1 deletion src/core/soci-simple.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3370,7 +3370,7 @@ SOCI_DECL int soci_execute(statement_handle st, int withDataExchange)
}
}

SOCI_DECL long long soci_get_affected_rows(statement_handle st)
SOCI_DECL int64_t soci_get_affected_rows(statement_handle st)
{
statement_wrapper * wrapper = static_cast<statement_wrapper *>(st);

Expand Down
2 changes: 1 addition & 1 deletion src/core/statement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ bool statement_impl::execute(bool withDataExchange)
}
}

long long statement_impl::get_affected_rows()
int64_t statement_impl::get_affected_rows()
{
try
{
Expand Down

0 comments on commit ad41518

Please sign in to comment.