Skip to content

Commit

Permalink
Merge branch 'use-into-backend-cleanup'
Browse files Browse the repository at this point in the history
Minor use/into backends cleanup.

See #1201.
  • Loading branch information
vadz committed Jan 30, 2025
2 parents c2aa418 + 07f9af4 commit b13f5aa
Show file tree
Hide file tree
Showing 12 changed files with 43 additions and 54 deletions.
5 changes: 0 additions & 5 deletions include/soci/mysql/soci-mysql.h
Original file line number Diff line number Diff line change
Expand Up @@ -220,11 +220,6 @@ struct SOCI_MYSQL_DECL mysql_statement_backend : details::statement_backend
// random access to rows, since mysql_data_seek() is expensive.
std::vector<MYSQL_ROW_OFFSET> resultRowOffsets_;

bool hasIntoElements_;
bool hasVectorIntoElements_;
bool hasUseElements_;
bool hasVectorUseElements_;

// the following maps are used for finding data buffers according to
// use elements specified by the user

Expand Down
1 change: 0 additions & 1 deletion include/soci/odbc/soci-odbc.h
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,6 @@ struct SOCI_ODBC_DECL odbc_statement_backend : details::statement_backend
SQLHSTMT hstmt_;
SQLULEN numRowsFetched_;
bool fetchVectorByRows_;
bool hasVectorUseElements_;
bool boundByName_;
bool boundByPos_;

Expand Down
5 changes: 0 additions & 5 deletions include/soci/postgresql/soci-postgresql.h
Original file line number Diff line number Diff line change
Expand Up @@ -298,11 +298,6 @@ struct SOCI_POSTGRESQL_DECL postgresql_statement_backend : details::statement_ba
bool justDescribed_; // to optimize row description with immediately
// following actual statement execution

bool hasIntoElements_;
bool hasVectorIntoElements_;
bool hasUseElements_;
bool hasVectorUseElements_;

// the following maps are used for finding data buffers according to
// use elements specified by the user

Expand Down
8 changes: 8 additions & 0 deletions include/soci/soci-backend.h
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,14 @@ class statement_backend
virtual vector_into_type_backend* make_vector_into_type_backend() = 0;
virtual vector_use_type_backend* make_vector_use_type_backend() = 0;

// These are set when the corresponding make_xxx_backend() above is called
// by statement_impl. This goes against encapsulation but allows to avoid
// having to set them in all backends implementations of these functions.
bool hasIntoElements_ = false;
bool hasVectorIntoElements_ = false;
bool hasUseElements_ = false;
bool hasVectorUseElements_ = false;

private:
SOCI_NOT_COPYABLE(statement_backend)
};
Expand Down
1 change: 0 additions & 1 deletion include/soci/sqlite3/soci-sqlite3.h
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,6 @@ struct SOCI_SQLITE3_DECL sqlite3_statement_backend : details::statement_backend
sqlite3_column_info_list columns_;


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

private:
Expand Down
8 changes: 1 addition & 7 deletions src/backends/mysql/statement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@ using std::string;
mysql_statement_backend::mysql_statement_backend(
mysql_session_backend &session)
: session_(session), result_(NULL),
rowsAffectedBulk_(-1LL), justDescribed_(false),
hasIntoElements_(false), hasVectorIntoElements_(false),
hasUseElements_(false), hasVectorUseElements_(false)
rowsAffectedBulk_(-1LL), justDescribed_(false)
{
}

Expand Down Expand Up @@ -503,27 +501,23 @@ data_type mysql_statement_backend::to_data_type(db_type dbt) const
mysql_standard_into_type_backend *
mysql_statement_backend::make_into_type_backend()
{
hasIntoElements_ = true;
return new mysql_standard_into_type_backend(*this);
}

mysql_standard_use_type_backend *
mysql_statement_backend::make_use_type_backend()
{
hasUseElements_ = true;
return new mysql_standard_use_type_backend(*this);
}

mysql_vector_into_type_backend *
mysql_statement_backend::make_vector_into_type_backend()
{
hasVectorIntoElements_ = true;
return new mysql_vector_into_type_backend(*this);
}

mysql_vector_use_type_backend *
mysql_statement_backend::make_vector_use_type_backend()
{
hasVectorUseElements_ = true;
return new mysql_vector_use_type_backend(*this);
}
3 changes: 1 addition & 2 deletions src/backends/odbc/statement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ using namespace soci::details;

odbc_statement_backend::odbc_statement_backend(odbc_session_backend &session)
: session_(session), hstmt_(0), numRowsFetched_(0), fetchVectorByRows_(false),
hasVectorUseElements_(false), boundByName_(false), boundByPos_(false),
boundByName_(false), boundByPos_(false),
rowsAffected_(-1LL)
{
}
Expand Down Expand Up @@ -497,6 +497,5 @@ odbc_statement_backend::make_vector_into_type_backend()

odbc_vector_use_type_backend * odbc_statement_backend::make_vector_use_type_backend()
{
hasVectorUseElements_ = true;
return new odbc_vector_use_type_backend(*this);
}
24 changes: 0 additions & 24 deletions src/backends/oracle/standard-into-type.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,30 +33,6 @@ using namespace soci;
using namespace soci::details;
using namespace soci::details::oracle;

oracle_standard_into_type_backend *
oracle_statement_backend::make_into_type_backend()
{
return new oracle_standard_into_type_backend(*this);
}

oracle_standard_use_type_backend *
oracle_statement_backend::make_use_type_backend()
{
return new oracle_standard_use_type_backend(*this);
}

oracle_vector_into_type_backend *
oracle_statement_backend::make_vector_into_type_backend()
{
return new oracle_vector_into_type_backend(*this);
}

oracle_vector_use_type_backend *
oracle_statement_backend::make_vector_use_type_backend()
{
return new oracle_vector_use_type_backend(*this);
}

void oracle_standard_into_type_backend::define_by_pos(
int &position, void *data, exchange_type type)
{
Expand Down
24 changes: 24 additions & 0 deletions src/backends/oracle/statement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -377,3 +377,27 @@ std::size_t oracle_statement_backend::column_size(int position)

return static_cast<std::size_t>(colSize);
}

oracle_standard_into_type_backend *
oracle_statement_backend::make_into_type_backend()
{
return new oracle_standard_into_type_backend(*this);
}

oracle_standard_use_type_backend *
oracle_statement_backend::make_use_type_backend()
{
return new oracle_standard_use_type_backend(*this);
}

oracle_vector_into_type_backend *
oracle_statement_backend::make_vector_into_type_backend()
{
return new oracle_vector_into_type_backend(*this);
}

oracle_vector_use_type_backend *
oracle_statement_backend::make_vector_use_type_backend()
{
return new oracle_vector_use_type_backend(*this);
}
8 changes: 1 addition & 7 deletions src/backends/postgresql/statement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,7 @@ postgresql_statement_backend::postgresql_statement_backend(
postgresql_session_backend &session, bool single_row_mode)
: session_(session), single_row_mode_(single_row_mode),
result_(session, NULL),
rowsAffectedBulk_(-1LL), justDescribed_(false),
hasIntoElements_(false), hasVectorIntoElements_(false),
hasUseElements_(false), hasVectorUseElements_(false)
rowsAffectedBulk_(-1LL), justDescribed_(false)
{
}

Expand Down Expand Up @@ -828,27 +826,23 @@ void postgresql_statement_backend::describe_column(int colNum,
postgresql_standard_into_type_backend *
postgresql_statement_backend::make_into_type_backend()
{
hasIntoElements_ = true;
return new postgresql_standard_into_type_backend(*this);
}

postgresql_standard_use_type_backend *
postgresql_statement_backend::make_use_type_backend()
{
hasUseElements_ = true;
return new postgresql_standard_use_type_backend(*this);
}

postgresql_vector_into_type_backend *
postgresql_statement_backend::make_vector_into_type_backend()
{
hasVectorIntoElements_ = true;
return new postgresql_vector_into_type_backend(*this);
}

postgresql_vector_use_type_backend *
postgresql_statement_backend::make_vector_use_type_backend()
{
hasVectorUseElements_ = true;
return new postgresql_vector_use_type_backend(*this);
}
2 changes: 0 additions & 2 deletions src/backends/sqlite3/statement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ sqlite3_statement_backend::sqlite3_statement_backend(
, databaseReady_(false)
, boundByName_(false)
, boundByPos_(false)
, hasVectorIntoElements_(false)
, rowsAffectedBulk_(-1LL)
{
}
Expand Down Expand Up @@ -600,7 +599,6 @@ sqlite3_standard_use_type_backend * sqlite3_statement_backend::make_use_type_bac
sqlite3_vector_into_type_backend *
sqlite3_statement_backend::make_vector_into_type_backend()
{
hasVectorIntoElements_ = true;
return new sqlite3_vector_into_type_backend(*this);
}

Expand Down
8 changes: 8 additions & 0 deletions src/core/statement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -867,24 +867,32 @@ void statement_impl::dec_ref()
standard_into_type_backend *
statement_impl::make_into_type_backend()
{
backEnd_->hasIntoElements_ = true;

return backEnd_->make_into_type_backend();
}

standard_use_type_backend *
statement_impl::make_use_type_backend()
{
backEnd_->hasUseElements_ = true;

return backEnd_->make_use_type_backend();
}

vector_into_type_backend *
statement_impl::make_vector_into_type_backend()
{
backEnd_->hasVectorIntoElements_ = true;

return backEnd_->make_vector_into_type_backend();
}

vector_use_type_backend *
statement_impl::make_vector_use_type_backend()
{
backEnd_->hasVectorUseElements_ = true;

return backEnd_->make_vector_use_type_backend();
}

Expand Down

0 comments on commit b13f5aa

Please sign in to comment.