Fixed kexi FTBFS caused by new libpqxx 6.4 version.

Signed-off-by: Michele Calgaro <michele.calgaro@yahoo.it>
pull/7/head
Michele Calgaro 5 years ago
parent e13b3ca773
commit 03f1e52d15
Signed by: MicheleC
GPG Key ID: 2A75B7CA8ADED5CF

@ -523,43 +523,40 @@ tristate PqxxMigrate::drv_fetchRecordFromSQL(const TQString& sqlStatement,
bool PqxxMigrate::drv_copyTable(const TQString& srcTable, KexiDB::Connection *destConn, bool PqxxMigrate::drv_copyTable(const TQString& srcTable, KexiDB::Connection *destConn,
KexiDB::TableSchema* dstTable) KexiDB::TableSchema* dstTable)
{ {
std::vector<std::string> R; if (query(TQString("SELECT * FROM ") + srcTable.latin1()))
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)
{ {
TQValueList<TQVariant> vals; pqxx::work T(*m_conn, "PqxxMigrate::drv_copyTable");
std::vector<std::string>::const_iterator i, end( R.end() );
int index = 0; //Loop round each row, reading into a vector of strings
for ( i = R.begin(); i != end; ++i, index++) { const KexiDB::QueryColumnInfo::Vector fieldsExpanded( dstTable->query()->fieldsExpanded() );
if (fieldsExpanded.at(index)->field->type()==KexiDB::Field::BLOB || fieldsExpanded.at(index)->field->type()==KexiDB::Field::LongText) for (pqxx::result::const_iterator rowIt = m_res->begin(); rowIt != m_res->end(); ++rowIt)
{ {
vals.append( KexiDB::pgsqlByteaToByteArray((*i).c_str(), (*i).size()) ); TQValueList<TQVariant> vals;
} int index = 0;
else if (fieldsExpanded.at(index)->field->type()==KexiDB::Field::Boolean ) for (int i = 0; i < rowIt.size(); ++i, index++)
{ {
vals.append(QString((*i).c_str()).lower() == "t" ? TQVariant(true) : TQVariant(false)); if (fieldsExpanded.at(index)->field->type()==KexiDB::Field::BLOB ||
} fieldsExpanded.at(index)->field->type()==KexiDB::Field::LongText)
else {
{ vals.append(KexiDB::pgsqlByteaToByteArray(rowIt.at(i).c_str(), rowIt.at(i).size()));
vals.append( KexiDB::cstringToVariant((*i).c_str(), }
fieldsExpanded.at(index)->field, (*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)) m_res->clear();
return false;
updateProgress();
R.clear();
} }
//This does not work in <libpqxx 2.2
//stream.complete();
return true; return true;
} }

Loading…
Cancel
Save