Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1Xhn1b-00043y-3E for pgsql-bugs@arkaria.postgresql.org; Fri, 24 Oct 2014 22:07:59 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1Xhn1a-0000yW-20 for pgsql-bugs@arkaria.postgresql.org; Fri, 24 Oct 2014 22:07:58 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1Xhn1Y-0000yP-Uq for pgsql-bugs@postgresql.org; Fri, 24 Oct 2014 22:07:57 +0000 Received: from smtp-outbound-2.vmware.com ([208.91.2.13]) by makus.postgresql.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.80) (envelope-from ) id 1Xhn1T-0005Lk-Re for pgsql-bugs@postgresql.org; Fri, 24 Oct 2014 22:07:53 +0000 Received: from sc9-mailhost3.vmware.com (sc9-mailhost3.vmware.com [10.113.161.73]) by smtp-outbound-2.vmware.com (Postfix) with ESMTP id ED0632821F; Fri, 24 Oct 2014 15:07:48 -0700 (PDT) Received: from EX13-CAS-012.vmware.com (EX13-CAS-012.vmware.com [10.113.191.64]) by sc9-mailhost3.vmware.com (Postfix) with ESMTP id E7ED941646; Fri, 24 Oct 2014 15:07:48 -0700 (PDT) Received: from EX13-MBX-024.vmware.com (10.113.191.44) by EX13-MBX-008.vmware.com (10.113.191.28) with Microsoft SMTP Server (TLS) id 15.0.775.38; Fri, 24 Oct 2014 15:07:43 -0700 Received: from [192.168.1.90] (10.113.160.246) by EX13-MBX-024.vmware.com (10.113.191.44) with Microsoft SMTP Server (TLS) id 15.0.775.38; Fri, 24 Oct 2014 15:07:43 -0700 Message-ID: <544ACDAB.7060904@vmware.com> Date: Sat, 25 Oct 2014 01:07:39 +0300 From: Heikki Linnakangas Organization: VMware User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Icedove/31.1.2 MIME-Version: 1.0 To: , Subject: Re: BUG #11617: issue with dump/restore involving view with hstore data type embedded in where condition References: <20141009200031.25464.53769@wrigleys.postgresql.org> In-Reply-To: <20141009200031.25464.53769@wrigleys.postgresql.org> Content-Type: text/plain; charset="utf-8"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [10.113.160.246] X-ClientProxiedBy: EX13-CAS-013.vmware.com (10.113.191.65) To EX13-MBX-024.vmware.com (10.113.191.44) X-Pg-Spam-Score: -9.0 (---------) 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 10/09/2014 11:00 PM, support@maerix.com wrote: > in restoring a dump followed by a restore, the restore partially work's but > does not restore a specific view with a hstore component > > The error message is: > > pg_restore: [archiver (db)] could not execute query: ERROR: operator does > not exist: public.hstore = public.hstore > LINE 30: ...me <> 'fk_formation_id'::text)) AND (h1.old_value IS DISTINC... > ^ > HINT: No operator matches the given name and argument type(s). You might > need to add explicit type casts. > > > The condition in the WHERE clause looks like this: > > "WHERE (h1.old_value IS DISTINCT FROM h1.new_value)" > > Where the columns old_value and new_value are of the HSTORE datatype, and > are optionnal. > > That is why we called upon "IS DISTINCT FROM " to manage possible NULL > values. > > AS a workaround, we used instead COALESCE with a fake hstore value for NULL > cases > > Something along the line of: > > where COALESCE( h1.old_value,'"e"=>"1", "f"=>"2"'::hstore) <> > COALESCE(h2.new_value,'"e"=>"1", "f"=>"2"'::hstore); > > And it resolved the issue when restoring. Everything goes through normally. > > Now, either it is a bug similar to the NULLIF issue (see attached > http://stackoverflow.com/q/23599926/398670) > This bug was listed on the 12th of May by Craig Ringer. > > Or the use of "IS DISTINCT FROM" clause is irreconcilable with hstore > datatypes. > If that is the case, we will take note of this. Yeah, this is essentially the same bug as with NULLIF. In the catalogs, we store the OID of the equality operator used in a NULLIF or IS DISTINCT FROM expression. But when you try to deparse that back to an SQL statement, it's impossible to construct an equivalent SQL statement that would refer to the same operator, when that operator is not in search_path. In essence, it's not possible to schema-qualify the equality operator used. There are a whole bunch of expressions that have the same problem: a IS DISTINCT FROM b a IS NOT DISTINCT FROM b a IN (...) a NOT IN (...) CASE a WHEN b ... ELSE d END NULLIF(a, b) I don't think this can be solved without some additional syntax, for specifying the equality operator explicitly. I propose that we add an optional USING after the problematic expressions: a IS DISTINCT FROM b USING myschema.= NULLIF(a, b) USING myschema.= ... I gave that a quick try, but got a shift/reduce conflict. I don't have the time to dig deeper right now, but it might be that that particular syntax might not work out. But something like that. (NULLIF, IS DISTINCT FROM and CASE are specified by the SQL standard, so there's a small risk that the standard committee might extend the syntax in a way that conflicts with this. But it seems highly unlikely.) - Heikki -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs