Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Reduce the time taken to populate the sample list. Technique to do this
suggested in ticket #364.
Improve the error message in the dialog if the sample query fails


git-svn-id: http://svn.osgeo.org/qgis/trunk@6032 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
g_j_m committed Oct 29, 2006
1 parent 21062e0 commit 6ec5fc0
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/gui/qgspgquerybuilder.cpp
Expand Up @@ -155,9 +155,12 @@ void QgsPgQueryBuilder::populateFields()

void QgsPgQueryBuilder::on_btnSampleValues_clicked()
{
QString sql = "select distinct \"" + lstFields->currentText()
+ "\" from \"" + mUri->schema + "\".\"" + mUri->table + "\" order by \"" + lstFields->currentText()
+ "\" limit 25";
QString sql = "SELECT DISTINCT \"" + lstFields->currentText() + "\" " +
"FROM (SELECT \"" + lstFields->currentText() + "\" " +
"FROM \"" + mUri->schema + "\".\"" + mUri->table + "\" " +
"LIMIT 5000) AS foo " +
"ORDER BY \"" + lstFields->currentText() + "\" "+
"LIMIT 25";
// clear the values list
lstValues->clear();
// determine the field type
Expand All @@ -183,7 +186,7 @@ void QgsPgQueryBuilder::on_btnSampleValues_clicked()

}else
{
QMessageBox::warning(this, tr("Database error"), tr("Failed to get sample of field values") + QString(PQerrorMessage(mPgConnection)) );
QMessageBox::warning(this, tr("Database error"), tr("<p>Failed to get sample of field values using SQL:</p><p>") + sql + "</p><p>Error message was: "+ QString(PQerrorMessage(mPgConnection)) + "</p>");
}
// free the result set
PQclear(result);
Expand Down

0 comments on commit 6ec5fc0

Please sign in to comment.