Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TsHmF-0001W6-QU for pgsql-bugs@arkaria.postgresql.org; Mon, 07 Jan 2013 18:50:28 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.72) (envelope-from ) id 1TsHmF-0006II-B6 for pgsql-bugs@arkaria.postgresql.org; Mon, 07 Jan 2013 18:50:27 +0000 Received: from magus.postgresql.org ([87.238.57.229]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TsHmE-0006ID-Mq for pgsql-bugs@postgresql.org; Mon, 07 Jan 2013 18:50:26 +0000 Received: from mail-ia0-f179.google.com ([209.85.210.179]) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TsHmA-0002Ma-Mu for pgsql-bugs@postgresql.org; Mon, 07 Jan 2013 18:50:26 +0000 Received: by mail-ia0-f179.google.com with SMTP id o25so16827338iad.10 for ; Mon, 07 Jan 2013 10:50:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:message-id:date:from:user-agent:mime-version:to:subject :content-type; bh=eSfhqd8u4+OIhJLcEXwrzNisy6zUwIAhP/sIkehKCc4=; b=NbWHAiNvXCbsp6IA4A26XgaON1SfIEphwKS9GCOOYnwsq0FWCGYU4lPjAQefCkoB68 cNfHOL9+zB1LTWdfkmc6veYk46SCm21sWDI6xyNnpdgnNEpMQChDIPhjuJedVKkjv5ej 1X341xeng2527GVorH5D6UoFNrI4sRu5aAHNDoSQp4WNiCEMVQHbfiGAnEVTb5JqNRtW dtPrgsInFruSfeT2W9wQK4K2SU4NPD0u/zeyw6mSSdTpjZbZFWXMGSQ8Z09uSTSiXBGA 3LjX1MHQQOrTUDQR4VDsNv71QSYwEqTaZ5afFDt6n5jFiJQbbsK4IITK7PqVCjPjWNzu Hsgw== X-Received: by 10.50.242.73 with SMTP id wo9mr6304822igc.36.1357584621313; Mon, 07 Jan 2013 10:50:21 -0800 (PST) Received: from [187.64.164.181] ([187.64.164.181]) by mx.google.com with ESMTPS id lu10sm7565003igc.15.2013.01.07.10.50.18 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 07 Jan 2013 10:50:20 -0800 (PST) Message-ID: <50EB18E9.8020202@gmail.com> Date: Mon, 07 Jan 2013 16:50:17 -0200 From: Rodrigo Rosenfeld Rosas User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:10.0.11) Gecko/20121122 Icedove/10.0.11 MIME-Version: 1.0 To: pgsql-bugs@postgresql.org Subject: wrong search_path being used Content-Type: multipart/alternative; boundary="------------030403050005080701070909" X-Pg-Spam-Score: -2.7 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org This is a multi-part message in MIME format. --------------030403050005080701070909 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit I didn't want to report the bug using the form before confirming it here. Here is a gist of what I'm trying: https://gist.github.com/49fcc8c4a5a810f66833#file-cleanup-sql The relevant part being this: old_path := pg_catalog.current_setting('search_path'); raise notice 'setting search_path from % to %', old_path, templ; perform pg_catalog.set_config('search_path', templ, true); ... select count(distinct transaction_id) from public.transaction_condition into temp_count; raise notice '% remaining transactions in public!', temp_count; select count(distinct transaction_id) from transaction_condition into temp_count; raise notice '% remaining transactions', temp_count; For which I get this result (NOTA is Portuguese word for NOTE or NOTICE, not sure...): NOTA: setting search_path from "$user",public to public NOTA: 1030 remaining transactions in public! NOTA: 66 remaining transactions Why do I get different results for both count() queries? The only difference between them is that I made the schema explicit in the first call but since current_path is set to "public" there shouldn't be any difference, right? By the way, 66 is the record count for stock.transaction_condition after calling that function the first time for the stock schema. I've tested the above using PG 9.2.2. Any ideas on what is happening? Thanks in advance, Rodrigo. --------------030403050005080701070909 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit I didn't want to report the bug using the form before confirming it here.

Here is a gist of what I'm trying:

https://gist.github.com/49fcc8c4a5a810f66833#file-cleanup-sql

The relevant part being this:

old_path := pg_catalog.current_setting('search_path');
raise notice 'setting search_path from % to %', old_path, templ;
perform pg_catalog.set_config('search_path', templ, true);
    ...

select count(distinct transaction_id) from public.transaction_condition into temp_count;
raise notice '% remaining transactions in public!', temp_count;
 
select count(distinct transaction_id) from transaction_condition into temp_count;
raise notice '% remaining transactions', temp_count;


For which I get this result (NOTA is Portuguese word for NOTE or NOTICE, not sure...):

NOTA:  setting search_path from "$user",public to public
NOTA:  1030 remaining transactions in public!
NOTA:  66 remaining transactions

Why do I get different results for both count() queries? The only difference between them is that I made the schema explicit in the first call but since current_path is set to "public" there shouldn't be any difference, right?

By the way, 66 is the record count for stock.transaction_condition after calling that function the first time for the stock schema.

I've tested the above using PG 9.2.2. Any ideas on what is happening?

Thanks in advance,
Rodrigo.

--------------030403050005080701070909--