Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kw7K5-0000bs-V6 for pgsql-general@arkaria.postgresql.org; Sun, 03 Jan 2021 17:37:45 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1kw7K4-0000Mn-Nq for pgsql-general@arkaria.postgresql.org; Sun, 03 Jan 2021 17:37:44 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kw7K4-0000MR-GZ for pgsql-general@lists.postgresql.org; Sun, 03 Jan 2021 17:37:44 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kw7Jx-0002SC-Tk for pgsql-general@lists.postgresql.org; Sun, 03 Jan 2021 17:37:44 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 103HbWnx2692293; Sun, 3 Jan 2021 12:37:32 -0500 From: Tom Lane To: Thiemo Kellner cc: PostgreSQL General Subject: Re: Possible trigger bug? function call argument literalised In-reply-to: <20210103180840.Horde.Fe4qNP3Uviz_9c6aPfxBTS2@webmail.gelassene-pferde.biz> References: <20210103180840.Horde.Fe4qNP3Uviz_9c6aPfxBTS2@webmail.gelassene-pferde.biz> Comments: In-reply-to Thiemo Kellner message dated "Sun, 03 Jan 2021 18:08:40 +0100" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <2692291.1609695452.1@sss.pgh.pa.us> Date: Sun, 03 Jan 2021 12:37:32 -0500 Message-ID: <2692292.1609695452@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Thiemo Kellner writes: > create trigger CALCULATION_METHOD_BR_IU > before insert on CALCULATION_METHOD > for each row > execute function METHOD_CHECK(current_schema); > Executing such, the string "current_schema" gets literalised, i.e. > single quoted: Yup, per the CREATE TRIGGER documentation [1]: arguments An optional comma-separated list of arguments to be provided to the function when the trigger is executed. The arguments are literal string constants. Simple names and numeric constants can be written here, too, but they will all be converted to strings. Please check the description of the implementation language of the trigger function to find out how these arguments can be accessed within the function; it might be different from normal function arguments. > I strongly feel this is a bug, It's operating as designed. There might be scope for a feature improvement here, but it'd be a far-from-trivial task, with probably a lot of ensuing compatibility breakage. regards, tom lane [1] https://www.postgresql.org/docs/current/sql-createtrigger.html