diff options
author | Michele Calgaro <michele.calgaro@yahoo.it> | 2019-12-15 23:16:35 +0900 |
---|---|---|
committer | Michele Calgaro <michele.calgaro@yahoo.it> | 2019-12-16 23:55:26 +0900 |
commit | 03f1e52d15ba7a77afb457b25616465c41478ba9 (patch) | |
tree | 23218491d2a584ba3f01d053b5517535c1b4569c /kexi/migration/pqxx | |
parent | e13b3ca7731f416b6ec6e80e665a400a8df1068c (diff) | |
download | koffice-03f1e52d15ba7a77afb457b25616465c41478ba9.tar.gz koffice-03f1e52d15ba7a77afb457b25616465c41478ba9.zip |
Fixed kexi FTBFS caused by new libpqxx 6.4 version.
Signed-off-by: Michele Calgaro <michele.calgaro@yahoo.it>
Diffstat (limited to 'kexi/migration/pqxx')
-rw-r--r-- | kexi/migration/pqxx/pqxxmigrate.cpp | 65 |
1 files changed, 31 insertions, 34 deletions
diff --git a/kexi/migration/pqxx/pqxxmigrate.cpp b/kexi/migration/pqxx/pqxxmigrate.cpp index 1511bbe0..257e4f0e 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) : TQVariant(false)); - } - 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) : TQVariant(false)); + } + 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; } |