Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1Wjfpd-0007YT-Lw for pgsql-bugs@arkaria.postgresql.org; Mon, 12 May 2014 02:19:09 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1Wjfpd-0006wa-0Z for pgsql-bugs@arkaria.postgresql.org; Mon, 12 May 2014 02:19:09 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1Wjfpc-0006wT-2U for pgsql-bugs@postgresql.org; Mon, 12 May 2014 02:19:08 +0000 Received: from mout.kundenserver.de ([212.227.17.10]) by magus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1WjfpY-0002rj-Mj for pgsql-bugs@postgresql.org; Mon, 12 May 2014 02:19:07 +0000 Received: from ayaki.localdomain (106-69-109-175.dyn.iinet.net.au [106.69.109.175]) by mrelayeu.kundenserver.de (node=mreue104) with ESMTP (Nemesis) id 0M9GoA-1WeftZ0A4E-00CjUU; Mon, 12 May 2014 04:19:04 +0200 Message-ID: <53702F92.50404@2ndquadrant.com> Date: Mon, 12 May 2014 10:18:58 +0800 From: Craig Ringer Organization: 2nd Quadrant User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.4.0 MIME-Version: 1.0 To: pgsql-bugs Subject: Re: hstore dump/restore bug in 9.3 References: <53702D20.4070505@2ndquadrant.com> In-Reply-To: <53702D20.4070505@2ndquadrant.com> X-Enigmail-Version: 1.6 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Provags-ID: V02:K0:SadpU3oIWeobbOhKtCL3mtMuZyECZXLKIH+im/2/AKy MCj3Kj7tkdG1ukO2TXPV+9Da5bUc6X2h/kA3LdnNxTDgudF7uC 5nFCZswA8IIF1nZFjHZEj98LZrjLgPL+dzCRAOKFiBbqaQ7VFH sNokI1rirEgWEIO/BYC6eFfJRpQ7jp46BYsFimnLGawnWEJIju EcnWTVxFtvVXwuLQlbrnzgSZ4I090fD7EbfXGpRSXWn/iF/CKo ZlYl0iaTe8DGVz8SS5mEtnIptQsetctDs1CxTvAMGEnT2EyBw6 0EXbRl8wxdor7g1JT63s+3Sfb9AKn2JBBXfEiTPgm/K/YxW2Be ff304WxAEMy8tNU8gJTyUIDh6hdNCBe0QJwP7tWhP X-Pg-Spam-Score: -1.9 (-) 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 On 05/12/2014 10:08 AM, Craig Ringer wrote: > Hi all > > A user has reported a bug where a simple view using hstore does not dump > and restore correctly. I've reproduced the detailed test case they > supplied below. > > The original report is by Stack Overflow user 'aidan', here: > http://stackoverflow.com/q/23599926/398670 > > > The error is: > > pg_restore: [archiver (db)] could not execute query: ERROR: operator > does not exist: public.hstore = public.hstore > LINE 2: SELECT NULLIF(hstore_test_table.column1, hstore_test_table.... When running pg_restore without a DB to get an SQL dump, it's clear why this happens - the dump sets the search_path to exclude the public schema, which contains the hstore operators required. CREATE EXTENSION IF NOT EXISTS hstore WITH SCHEMA public; ... SET search_path = hstore_test_schema, pg_catalog; ... CREATE VIEW hstore_test_view AS SELECT NULLIF(hstore_test_table.column1, hstore_test_table.column2) AS comparison FROM hstore_test_table; Using a different view definition makes this go away, as the original reporter noted: CREATE VIEW hstore_test_schema.hstore_test_view AS SELECT column1 = column2 AS comparison FROM hstore_test_schema.hstore_test_table; because the view is dumped with an explicit operator schema: CREATE VIEW hstore_test_view AS SELECT (hstore_test_table.column1 OPERATOR(public.=) hstore_test_table.column2) AS comparison FROM hstore_test_table; It looks like pg_dump expects to be able to explicitly qualify operators so it doesn't worry about setting the search_path to include them, but it doesn't cope with operators that're used indirectly by the nullif pseudofunction. Do we need a way to schema-qualify the operator used in NULLIF, or to provide an operator alias that it gets dumped as? -- Craig Ringer http://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Training & Services -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs