summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichele Calgaro <michele.calgaro@yahoo.it>2019-12-15 23:16:35 +0900
committerSlávek Banko <slavek.banko@axis.cz>2019-12-16 16:36:39 +0100
commitc057c561c407bf7728027e4f3dcefeef3644e294 (patch)
tree327ef6dd5840d05e572a5a35d4b91b248d2314e1
parent7a59257164040d9cf3e18aef684c729b1f2793fe (diff)
downloadkoffice-c057c561c407bf7728027e4f3dcefeef3644e294.tar.gz
koffice-c057c561c407bf7728027e4f3dcefeef3644e294.zip
Fixed kexi FTBFS caused by new libpqxx 6.4 version.r14.0.7
Signed-off-by: Michele Calgaro <michele.calgaro@yahoo.it> (cherry picked from commit 03f1e52d15ba7a77afb457b25616465c41478ba9)
-rw-r--r--kexi/migration/pqxx/pqxxmigrate.cpp65
1 files changed, 31 insertions, 34 deletions
diff --git a/kexi/migration/pqxx/pqxxmigrate.cpp b/kexi/migration/pqxx/pqxxmigrate.cpp
index 9460462c..119f2f65 100644
--- a/kexi/migration/pqxx/pqxxmigrate.cpp
+++ b/kexi/migration/pqxx/pqxxmigrate.cpp
@@ -523,43 +523,40 @@ tristate PqxxMigrate::drv_fetchRecordFromSQL(const TQString& sqlStatement,
bool PqxxMigrate::drv_copyTable(const TQString& srcTable, KexiDB::Connection *destConn,
KexiDB::TableSchema* dstTable)
{
- std::vector<std::string> R;
-
- pqxx::work T(*m_conn, "PqxxMigrate::drv_copyTable");
-
- pqxx::tablereader stream(T, (srcTable.latin1()));
-
- //Loop round each row, reading into a vector of strings
- const KexiDB::QueryColumnInfo::Vector fieldsExpanded( dstTable->query()->fieldsExpanded() );
- for (int n=0; (stream >> R); ++n)
+ if (query(TQString("SELECT * FROM ") + srcTable.latin1()))
{
- TQValueList<TQVariant> vals;
- std::vector<std::string>::const_iterator i, end( R.end() );
- int index = 0;
- for ( i = R.begin(); i != end; ++i, index++) {
- if (fieldsExpanded.at(index)->field->type()==KexiDB::Field::BLOB || fieldsExpanded.at(index)->field->type()==KexiDB::Field::LongText)
- {
- vals.append( KexiDB::pgsqlByteaToByteArray((*i).c_str(), (*i).size()) );
- }
- else if (fieldsExpanded.at(index)->field->type()==KexiDB::Field::Boolean )
- {
- vals.append(QString((*i).c_str()).lower() == "t" ? TQVariant(true, 1) : TQVariant(false, 1));
- }
- else
- {
- vals.append( KexiDB::cstringToVariant((*i).c_str(),
- fieldsExpanded.at(index)->field, (*i).size()) );
- }
+ pqxx::work T(*m_conn, "PqxxMigrate::drv_copyTable");
+
+ //Loop round each row, reading into a vector of strings
+ const KexiDB::QueryColumnInfo::Vector fieldsExpanded( dstTable->query()->fieldsExpanded() );
+ for (pqxx::result::const_iterator rowIt = m_res->begin(); rowIt != m_res->end(); ++rowIt)
+ {
+ TQValueList<TQVariant> vals;
+ int index = 0;
+ for (int i = 0; i < rowIt.size(); ++i, index++)
+ {
+ if (fieldsExpanded.at(index)->field->type()==KexiDB::Field::BLOB ||
+ fieldsExpanded.at(index)->field->type()==KexiDB::Field::LongText)
+ {
+ vals.append(KexiDB::pgsqlByteaToByteArray(rowIt.at(i).c_str(), rowIt.at(i).size()));
+ }
+ else if (fieldsExpanded.at(index)->field->type()==KexiDB::Field::Boolean)
+ {
+ vals.append(TQString(rowIt.at(i).c_str()).lower() == "t" ? TQVariant(true, 1) : TQVariant(false, 1));
+ }
+ else
+ {
+ vals.append(KexiDB::cstringToVariant(rowIt.at(i).c_str(), fieldsExpanded.at(index)->field, rowIt.at(i).size()));
+ }
+ }
+ if (!destConn->insertRecord(*dstTable, vals))
+ {
+ return false;
+ }
+ updateProgress();
}
- if (!destConn->insertRecord(*dstTable, vals))
- return false;
- updateProgress();
- R.clear();
+ m_res->clear();
}
-
- //This does not work in <libpqxx 2.2
- //stream.complete();
-
return true;
}