Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bUxFf-0001z0-3f for pgsql-admin@arkaria.postgresql.org; Wed, 03 Aug 2016 14:34:31 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1bUxFe-0003LF-Mn for pgsql-admin@arkaria.postgresql.org; Wed, 03 Aug 2016 14:34:30 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1bUxFe-0003KD-4p for pgsql-admin@postgresql.org; Wed, 03 Aug 2016 14:34:30 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1bUxFb-0004mf-B0 for pgsql-admin@postgresql.org; Wed, 03 Aug 2016 14:34:29 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id u73EYOhK022860; Wed, 3 Aug 2016 10:34:24 -0400 From: Tom Lane To: John Scalia cc: "pgsql-admin@postgresql.org" Subject: Re: Proper syntax to update an hstore key-value pair In-reply-to: References: Comments: In-reply-to John Scalia message dated "Wed, 03 Aug 2016 08:34:46 -0500" Date: Wed, 03 Aug 2016 10:34:24 -0400 Message-ID: <22859.1470234864@sss.pgh.pa.us> X-Pg-Spam-Score: -3.1 (---) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-admin Precedence: bulk Sender: pgsql-admin-owner@postgresql.org John Scalia writes: > I've got something strange going on in one of my databases. I need to > update key-value pair to fix one of our configurations. The table is named > "configuration" and the hstore attribute is called "parameters". The update > I've been attempting looks like: > update configuration set parameters = parameters || '"CONNECTOR_TIME_OUT" > => "-1"'::hstore; That doesn't look right, because || and => have the same precedence. You'd need to write update configuration set parameters = parameters || ('"CONNECTOR_TIME_OUT" => "-1"'::hstore); But you'd be better off moving to use the hstore() function as Richard suggested, because the => operator is gone as of PG 9.2 or so. > This update works properly from the psql command line on one of my sandbox > databases, but this particular test database reports: ERROR: type "hstore" > does not exist. Probably a search path problem, but you've not provided enough details to diagnose. > Now \dx shows that hstore is an installed extension. I've had issues before > where I've had to qualify hstore using ::public.hstore, but in this case > that gives me different error stating that no operator matches the given > name and argument type. I'm betting this is hstore 1.1 or later, which hasn't got the => hstore operator, because we deprecated it some time before that and needed to get rid of it altogether to make room for the SQL-standard meaning of =>. Use the function. > [ later ] > Tried that, but received "ERROR: column "parameters" is of type > public.hstore but expression is of type text" I'm still betting on a search path problem, causing || to resolve as text||text not hstore||hstore. regards, tom lane -- Sent via pgsql-admin mailing list (pgsql-admin@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-admin