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 1go50p-0001um-U1 for pgsql-general@arkaria.postgresql.org; Mon, 28 Jan 2019 11:23:36 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1go50n-00065U-VI for pgsql-general@arkaria.postgresql.org; Mon, 28 Jan 2019 11:23:33 +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 1go50n-00065N-NP for pgsql-general@lists.postgresql.org; Mon, 28 Jan 2019 11:23:33 +0000 Received: from mout.gmx.net ([212.227.17.22]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1go50l-0000z6-4j for pgsql-general@postgresql.org; Mon, 28 Jan 2019 11:23:33 +0000 Received: from hermes ([77.13.139.187]) by mail.gmx.com (mrgmx102 [212.227.17.168]) with ESMTPSA (Nemesis) id 0MQdAP-1gc9qs1KPN-00Tzq7 for ; Mon, 28 Jan 2019 12:23:27 +0100 Received: from ncq by hermes with local (Exim 4.92-RC4) (envelope-from ) id 1go50g-0004pq-Ej for pgsql-general@postgresql.org; Mon, 28 Jan 2019 12:23:26 +0100 Date: Mon, 28 Jan 2019 12:23:26 +0100 From: Karsten Hilbert To: pgsql-general Subject: multi-SQL command string aborts despite IF EXISTS Message-ID: <20190128112326.GB2141@hermes.hilbert.loc> Mail-Followup-To: pgsql-general MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit Ma_X_il-Followup-to: d Re_X_turn-receipt-to: Karsten.Hilbert@gmx.net Di_X_sposition-Notification-To: Karsten.Hilbert@gmx.net X-Confi_X_rm-Reading-To: Karsten.Hilbert@gmx.net X-Pri_X_ority: 2 (High) User-Agent: Mutt/1.10.1 (2018-07-13) Sender: X-Provags-ID: V03:K1:D+hxpWwk+fJ5l+mMxe88XRxiAuF6lpWI+XqnXE/oLAl92IFSb/g gBj5nQTHExODI5yDC04k9sLL3CT33F3fuExF6FaGZnTRYXGpKuwF0lk9AFNYJcspLvy8vm3 upLZKWljwd66/eQs1QshrNHeJN2aRYSwazUBNORYNWf1K9zHBl3Z44W9mCwwXwkkwkqQUop cDGzvIyQMxxmY+x+nkoqw== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1;V03:K0:GN3F6uII/rE=:g1QsjX/k4j58fBDnEnzCmN j4eY4EN/NpCpulfY6OPVPSR2DLubiIwyr2oFB1viecSzIywcmGxzC0msKbISwdfjs/yHox+g/ r5SiVwsKfYQAY3oA3EC/1JrbbTT4Llc3LTHjk/97MFb8fqemc0l58uiL+lYqAERbjkiP62C5P j6ZDOcvciP2x0Xlv40jAR0lCbMQnvR6GsYYqsdUFZ43CwA/o3F/O0qRx0GGftjejEl0w5IKIk PfaqAyJw+O0oiCp2V1+WKSq5/KkKJOPK2qQMpnhidalFZGRb4xNDEuaq6DNOq9MzpvAKY/TVq GGiHPgyOISaNmzWJ6ygG+S7Xq1CxXqIuDRc/bOKN0+wK+3RdskHHQ4M+2QTUrjPVvcqFt1/H1 mPNmsC0r7gr11x2W6OREJSIUviUa9/3DbuGyZjJ+n9vEt9wTBgJb8XSbripqgWka5e78/Jtvc dr2aORpE2LxvjtMawrMK5K0PX9iokLy9msvK4u6Er2nfnmdBgROJ9lPO/n8f72HSZAfEoaDu1 y70GBlAgaxsjOmo9WIjS0f8IHCgd6WOcECUGLaXDjbaBMXzLtcrlx9va37aA2oW/4XbAblVHF Q0y16G6Sh4KRcM66cz3FbDWbFjvFw/9joDc7IR1w45fkkP73/WKNzTLzaM1AWolkK54/hezE1 1tnVh8Y7EdS9EbBmob72ju1QnzrTnXZWGNUXu7Nk61HYmDhB9hQZYNtK/dCxDbkkG/rKm3KRH 0UzIKkgQK238MJlwptNy5KFGuDUupJ0r0Hv25gK6djnMJ6leJUfWsw5FelYEzpV4LC1Fd6OAR IFWXPC/6hnrWxzc8penZqLxR5QQpdkoCGcBosizKqhR0Ff5kCdAVH9W7dNdBB3z0FcJ13lD7J Yvz8w4OxkVm1zs9m4N/KQ/mlQLZGSUQXRx0V/rVODz1dn5LbjPLTRFEFu2COMO List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Hello all, 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 ? Will aborts inside a multi-SQL string prevent from being executed any SQL commands later in that same string ? (Mind you, the code above does not abort the *transaction* but does not execute the second SQL command.) Many thanks for insights, Karsten -- GPG 40BE 5B0E C98E 1713 AFA6 5BC0 3BEA AC80 7D4F C89B