Merge pull request #2305 from strk/master-readonly

Ensure read-only transactions
This commit is contained in:
Dane Springmeyer 2014-07-28 18:00:59 -07:00
commit 14d9127bb7

View file

@ -65,6 +65,17 @@ public:
close();
throw mapnik::datasource_exception(err_msg);
}
PGresult *result = PQexec(conn_, "SET DEFAULT_TRANSACTION_READ_ONLY = TRUE;");
bool ok = (result && (PQresultStatus(result) == PGRES_COMMAND_OK));
if ( result ) PQclear(result);
if ( ! ok ) {
std::string err_msg = "Postgis Plugin: ";
err_msg += status();
err_msg += "\nConnection string: '";
err_msg += connection_str;
err_msg += "'\n";
throw mapnik::datasource_exception(err_msg);
}
}
~Connection()