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,
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)
for (pqxx::result::const_iterator rowIt = m_res->begin(); rowIt != m_res->end(); ++rowIt)
{
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)
for (int i = 0; i < rowIt.size(); ++i, index++)
{
vals.append( KexiDB::pgsqlByteaToByteArray((*i).c_str(), (*i).size()) );
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 )
else if (fieldsExpanded.at(index)->field->type()==KexiDB::Field::Boolean)
{
vals.append(QString((*i).c_str()).lower() == "t" ? TQVariant(true) : TQVariant(false));
vals.append(TQString(rowIt.at(i).c_str()).lower() == "t" ? TQVariant(true) : TQVariant(false));
}
else
{
vals.append( KexiDB::cstringToVariant((*i).c_str(),
fieldsExpanded.at(index)->field, (*i).size()) );
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();
R.clear();
}
//This does not work in <libpqxx 2.2
//stream.complete();
m_res->clear();
}
return true;
}

Loading…
Cancel
Save