Skip to content

Commit

Permalink
Remove some debug messages. Change some error messages..
Browse files Browse the repository at this point in the history
Remove some useless debug messages, e.g. because they just print an SQL
string which you can see in the SQL log window anyway.

Change some "critical" errors messages to just warning. No sense in
printing a critical error message when the program can handle the
problem by itself.
  • Loading branch information
MKleusberg committed May 8, 2013
1 parent cf72bfb commit 5b9d5cc
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 34 deletions.
3 changes: 0 additions & 3 deletions src/EditTableDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@

#include "sqlitedb.h"

#include <QDebug>

EditTableDialog::EditTableDialog(DBBrowserDB* db, const QString& tableName, QWidget* parent)
: QDialog(parent),
ui(new Ui::EditTableDialog),
Expand All @@ -30,7 +28,6 @@ EditTableDialog::EditTableDialog(DBBrowserDB* db, const QString& tableName, QWid

// Existing table, so load and set the current layout
QString sTablesql = pdb->getTableSQL(curTable);
//qDebug() << sTablesql;
m_table = sqlb::Table::parseSQL(sTablesql);
populateFields();
}
Expand Down
3 changes: 0 additions & 3 deletions src/MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -612,10 +612,7 @@ void MainWindow::editText(const QModelIndex& index)
void MainWindow::doubleClickTable(const QModelIndex& index)
{
if(!index.isValid())
{
qDebug("no cell selected");
return;
}

// Don't allow editing of other objects than tables
if(db.getObjectByName(ui->comboBrowseTable->currentText()).gettype() != "table")
Expand Down
45 changes: 19 additions & 26 deletions src/sqlitedb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -368,15 +368,15 @@ bool DBBrowserDB::executeMultiSQL(const QString& statement, bool dirty, bool log
sqlite3_finalize(vm);
lastErrorMessage = QObject::tr("Error in statement #%1: %2.\n"
"Aborting execution.").arg(line).arg(sqlite3_errmsg(_db));
qDebug(lastErrorMessage.toStdString().c_str());
qWarning() << lastErrorMessage;
return false;
} else {
sqlite3_finalize(vm);
}
} else {
lastErrorMessage = QObject::tr("Error in statement #%1: %2.\n"
"Aborting execution.").arg(line).arg(sqlite3_errmsg(_db));
qDebug(lastErrorMessage.toStdString().c_str());
qWarning() << lastErrorMessage;
return false;
}
} while(tail && *tail != 0 && (res == SQLITE_OK || res == SQLITE_DONE));
Expand All @@ -399,15 +399,14 @@ int DBBrowserDB::addRecord(const QString& sTableName)
// we should cache the parsed tables somewhere
sqlb::Table table = sqlb::Table::parseSQL(getTableSQL(sTableName));
QString sInsertstmt = table.emptyInsertStmt();
qDebug() << sInsertstmt;
lastErrorMessage = "";
logSQL(sInsertstmt, kLogMsg_App);
setRestorePoint();

if (SQLITE_OK != sqlite3_exec(_db, sInsertstmt.toUtf8(), NULL, NULL, &errmsg))
{
lastErrorMessage = QString::fromUtf8(errmsg);
qCritical() << "addRecord: " << lastErrorMessage;
qWarning() << "addRecord: " << lastErrorMessage;
return -1;
} else {
return sqlite3_last_insert_rowid(_db);
Expand All @@ -431,7 +430,7 @@ bool DBBrowserDB::deleteRecord(const QString& table, int rowid)
ok=true;
} else {
lastErrorMessage = QString::fromUtf8(errmsg);
qCritical() << "deleteRecord: " << lastErrorMessage;
qWarning() << "deleteRecord: " << lastErrorMessage;
}
}
return ok;
Expand Down Expand Up @@ -464,7 +463,7 @@ bool DBBrowserDB::updateRecord(const QString& table, const QString& column, int
return true;
} else {
lastErrorMessage = sqlite3_errmsg(_db);
qCritical() << "updateRecord: " << lastErrorMessage;
qWarning() << "updateRecord: " << lastErrorMessage;
return false;
}
}
Expand Down Expand Up @@ -501,15 +500,15 @@ bool DBBrowserDB::renameColumn(const QString& tablename, const QString& from, co
if(table.getname() == "" || table.getField(from).getname() == "")
{
lastErrorMessage = QObject::tr("renameColumn: cannot find table %1 with column %2").arg(tablename).arg(from);
qDebug(lastErrorMessage.toStdString().c_str());
qWarning() << lastErrorMessage;
return false;
}

// Create savepoint to be able to go back to it in case of any error
if(!executeSQL("SAVEPOINT sqlitebrowser_rename_column"))
{
lastErrorMessage = QObject::tr("renameColumn: creating savepoint failed. DB says: %1").arg(lastErrorMessage);
qDebug(lastErrorMessage.toStdString().c_str());
qWarning() << lastErrorMessage;
return false;
}

Expand All @@ -530,7 +529,7 @@ bool DBBrowserDB::renameColumn(const QString& tablename, const QString& from, co
if(!createTable("sqlitebrowser_rename_column_new_table", new_table_structure))
{
lastErrorMessage = QObject::tr("renameColumn: creating new table failed. DB says: %1").arg(lastErrorMessage);
qDebug(lastErrorMessage.toStdString().c_str());
qWarning() << lastErrorMessage;
executeSQL("ROLLBACK TO SAVEPOINT sqlitebrowser_rename_column;");
return false;
}
Expand All @@ -540,7 +539,7 @@ bool DBBrowserDB::renameColumn(const QString& tablename, const QString& from, co
{
lastErrorMessage = QObject::tr("renameColumn: copying data to new table failed. DB says:\n"
"%1").arg(lastErrorMessage);
qDebug(lastErrorMessage.toStdString().c_str());
qWarning() << lastErrorMessage;
executeSQL("ROLLBACK TO SAVEPOINT sqlitebrowser_rename_column;");
return false;
}
Expand All @@ -549,7 +548,7 @@ bool DBBrowserDB::renameColumn(const QString& tablename, const QString& from, co
if(!executeSQL(QString("DROP TABLE `%1`;").arg(tablename)))
{
lastErrorMessage = QObject::tr("renameColumn: deleting old table failed. DB says: %1").arg(lastErrorMessage);
qDebug(lastErrorMessage.toStdString().c_str());
qWarning() << lastErrorMessage;
executeSQL("ROLLBACK TO SAVEPOINT sqlitebrowser_rename_column;");
return false;
}
Expand All @@ -565,7 +564,7 @@ bool DBBrowserDB::renameColumn(const QString& tablename, const QString& from, co
if(!executeSQL("RELEASE SAVEPOINT sqlitebrowser_rename_column;"))
{
lastErrorMessage = QObject::tr("renameColumn: releasing savepoint failed. DB says: %1").arg(lastErrorMessage);
qDebug(lastErrorMessage.toStdString().c_str());
qWarning() << lastErrorMessage;
return false;
}

Expand Down Expand Up @@ -679,7 +678,7 @@ bool DBBrowserDB::renameTable(const QString& from_table, const QString& to_table
QString error = QObject::tr("Error renaming table '%1' to '%2'."
"Message from database engine:\n%3").arg(from_table).arg(to_table).arg(lastErrorMessage);
lastErrorMessage = error;
qDebug(error.toStdString().c_str());
qWarning() << lastErrorMessage;
return false;
} else {
return true;
Expand Down Expand Up @@ -816,12 +815,11 @@ void DBBrowserDB::updateSchema( )
if(val1 == "table" || val1 == "index" || val1 == "view" || val1 == "trigger")
objMap.insert(val1, DBBrowserObject(val2, val3, val1));
else
qDebug(QObject::tr("unknown object type %1").arg(val1).toStdString().c_str());
qWarning() << QObject::tr("unknown object type %1").arg(val1);
}
sqlite3_finalize(vm);
}else{
qDebug(QObject::tr("could not get list of db objects: %1, %2").
arg(err).arg(sqlite3_errmsg(_db)).toStdString().c_str());
qWarning() << QObject::tr("could not get list of db objects: %1, %2").arg(err).arg(sqlite3_errmsg(_db));
}

//now get the field list for each table
Expand Down Expand Up @@ -956,16 +954,13 @@ QString DBBrowserDB::getPragma(const QString& pragma)
if(err == SQLITE_OK){
logSQL(sql, kLogMsg_App);
if(sqlite3_step(vm) == SQLITE_ROW)
{
retval = QString::fromUtf8((const char *) sqlite3_column_text(vm, 0));
//qDebug((pragma + ": " + retval).toStdString().c_str());
} else {
qDebug(QObject::tr("didn't receive any output from pragma %1").arg(pragma).toStdString().c_str());
}
else
qWarning() << QObject::tr("didn't receive any output from pragma %1").arg(pragma);

sqlite3_finalize(vm);
} else {
qDebug(QObject::tr("could not execute pragma command: %1, %2").
arg(err).arg(sqlite3_errmsg(_db)).toStdString().c_str());
qWarning() << QObject::tr("could not execute pragma command: %1, %2").arg(err).arg(sqlite3_errmsg(_db));
}

// Return it
Expand All @@ -976,13 +971,11 @@ bool DBBrowserDB::setPragma(const QString& pragma, const QString& value)
{
// Set the pragma value
QString sql = QString("PRAGMA %1 = \"%2\";").arg(pragma).arg(value);
//qDebug(sql.toStdString().c_str());

save();
bool res = executeSQL(sql, false, true); // PRAGMA statements are usually not transaction bound, so we can't revert
if( !res )
qDebug(QObject::tr("Error setting pragma %1 to %2: %3").
arg(pragma).arg(value).arg(lastErrorMessage).toStdString().c_str());
qWarning() << QObject::tr("Error setting pragma %1 to %2: %3").arg(pragma).arg(value).arg(lastErrorMessage);
return res;
}

Expand Down
1 change: 0 additions & 1 deletion src/sqlitetypes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,6 @@ Table CreateTableWalker::table()
if( m_root ) //CREATE TABLE
{
antlr::RefAST s = m_root->getFirstChild();
//qDebug() << m_root->toStringTree().cd;
//skip to tablename
while(s->getType() != Sqlite3Lexer::ID && s->getType() != Sqlite3Lexer::QUOTEDID) s = s->getNextSibling();
tab.setName(identifier(s));
Expand Down
2 changes: 1 addition & 1 deletion src/sqltextedit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ void SqlTextEdit::keyPressEvent(QKeyEvent *e)
table = identifier.left(dotpos);
field = identifier.mid(dotpos + 1);
}
// qDebug() << identifier << ":" << table << ":" << field;

if( dotpos > 0 )
{
// swap model to field completion
Expand Down

0 comments on commit 5b9d5cc

Please sign in to comment.