Re: search_path reset on error (making it not reset)

From: Craig Ringer <ringerc(at)ringerc(dot)id(dot)au>
To: "imagenesis(at)gmail(dot)com" <imagenesis(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: search_path reset on error (making it not reset)
Date: 2012-07-21 08:07:38
Message-ID: 500A634A.20306@ringerc.id.au
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 07/21/2012 12:42 PM, imagenesis(at)gmail(dot)com wrote:
> The search_path set for the connection is being reset if a query
> errors. Is there a setting to maintain the search_path despite errors.

Are you setting `search_path` within a transaction? Set it outside an
explicit transaction if you want it to persist after statement errors.

By the way, when asking questions like this you really should provide
some basic info - at absolute minimum the version of PostgreSQL in use,
and preferably a sample of SQL showing your problem and the exact text
of any error messges.

Here's what happens when I test your problem:

$ psql regress
psql (9.1.4)
Type "help" for help.

regress=# select version();
version
-------------------------------------------------------------------------------------------------------------
PostgreSQL 9.1.4 on x86_64-redhat-linux-gnu, compiled by gcc (GCC)
4.7.0 20120507 (Red Hat 4.7.0-5), 64-bit
(1 row)

regress=# SHOW search_path;
search_path
-----------------
"$user", public
(1 row)

regress=# BEGIN;
BEGIN
regress=# SET search_path = 'public';
SET
regress=# SHOW search_path;
search_path
-------------
public
(1 row)

regress=# BAD QUERY;
ERROR: syntax error at or near "BAD"
LINE 1: BAD QUERY;
^
regress=# SHOW search_path;
ERROR: current transaction is aborted, commands ignored until end of
transaction block
regress=# ROLLBACK;
ROLLBACK
regress=# SHOW search_path;
search_path
-----------------
"$user", public
(1 row)

regress=# SET search_path = 'public';
SET
regress=# SHOW search_path;
search_path
-------------
public
(1 row)

regress=# BAD QUERY;
ERROR: syntax error at or near "BAD"
LINE 1: BAD QUERY;
^
regress=# SHOW search_path;
search_path
-------------
public
(1 row)

--
Craig Ringer

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Herouth Maoz 2012-07-21 08:59:49 Why is an ISO-8859-8 database allowing values not within that set?
Previous Message Adam Crews 2012-07-21 05:24:11 postgres 9 bind address for replication