Ensure read-only transactions

Closes #2142
This commit is contained in:
Sandro Santilli 2014-07-16 10:59:11 +02:00
parent 0b1ad62cf5
commit 25c237fdd9

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()