Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1go7jb-00031b-S4 for pgsql-general@arkaria.postgresql.org; Mon, 28 Jan 2019 14:18:00 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1go7jZ-0000Ze-Ru for pgsql-general@arkaria.postgresql.org; Mon, 28 Jan 2019 14:17:57 +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_SHA1:256) (Exim 4.89) (envelope-from ) id 1go7jZ-0000ZX-Jc for pgsql-general@lists.postgresql.org; Mon, 28 Jan 2019 14:17:57 +0000 Received: from mx2.mailbox.org ([80.241.60.215]) by magus.postgresql.org with esmtps (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1go7jS-0004yu-VL for pgsql-general@postgresql.org; Mon, 28 Jan 2019 14:17:57 +0000 Received: from smtp1.mailbox.org (smtp1.mailbox.org [IPv6:2001:67c:2050:105:465:1:1:0]) (using TLSv1.2 with cipher ECDHE-RSA-CHACHA20-POLY1305 (256/256 bits)) (No client certificate requested) by mx2.mailbox.org (Postfix) with ESMTPS id 81382A16FF; Mon, 28 Jan 2019 15:17:49 +0100 (CET) X-Virus-Scanned: amavisd-new at heinlein-support.de Received: from smtp1.mailbox.org ([80.241.60.240]) by spamfilter05.heinlein-hosting.de (spamfilter05.heinlein-hosting.de [80.241.56.123]) (amavisd-new, port 10030) with ESMTP id kb-VT9Gf9vFF; Mon, 28 Jan 2019 15:17:48 +0100 (CET) Message-ID: Subject: Re: multi-SQL command string aborts despite IF EXISTS From: Laurenz Albe To: Karsten Hilbert , pgsql-general Date: Mon, 28 Jan 2019 15:17:47 +0100 In-Reply-To: <20190128112326.GB2141@hermes.hilbert.loc> References: <20190128112326.GB2141@hermes.hilbert.loc> Organization: Cybertec Content-Type: text/plain; charset="UTF-8" Mime-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Karsten Hilbert wrote: > the Orthanc DICOM server tries to create a trigram index using this code: > > db->Execute( > "CREATE EXTENSION IF NOT EXISTS pg_trgm; " > "CREATE INDEX DicomIdentifiersIndexValues2 ON DicomIdentifiers USING gin(value gin_trgm_ops);"); > > which results in this sequence of events inside PG11: > > 2019-01-28 08:52:50 GMT ORT: exec_execute_message, postgres.c:2011 > 2019-01-28 08:52:50 GMT LOG: 00000: Anweisung: CREATE EXTENSION IF NOT EXISTS pg_trgm; CREATE INDEX DicomIdentifiersIndexValues2 ON DicomIdentifiers USING gin(value gin_2019-01-28 08:52:50 GMT ORT: exec_simple_query, postgres.c:975 > 2019-01-28 08:52:50 GMT FEHLER: 42501: keine Berechtigung, um Erweiterung »pg_trgm« zu erzeugen > 2019-01-28 08:52:50 GMT TIPP: Nur Superuser können diese Erweiterung anlegen. > 2019-01-28 08:52:50 GMT ORT: execute_extension_script, extension.c:809 > 2019-01-28 08:52:50 GMT ANWEISUNG: CREATE EXTENSION IF NOT EXISTS pg_trgm; CREATE INDEX DicomIdentifiersIndexValues2 ON DicomIdentifiers USING gin(value gin_trgm_ops); > 2019-01-28 08:52:50 GMT LOG: 00000: Anweisung: ABORT > > Apparently, the two SQL commands are being sent as one > command string. > > It is quite reasonable that the CREATE EXTENSION part fails > because the connected user, indeed, does not have sufficient > permissions, as it should be. However, the pg_trgm extension > is pre-installed by the database superuser such that index > creation should succeed. > > Now, I would have thought that the "IF NOT EXISTS" part of > the CREATE EXTENSION would have allowed the subsequent CREATE > INDEX to succeed. > > I am wrong ? No, you are right. The "pg_trgm" extension does *not* exist in the database, and that is your problem. Perhaps you preinstalled the extension in the wrong database (postgres?). Yours, Laurenz Albe -- Cybertec | https://www.cybertec-postgresql.com