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 1kw7fk-00017H-F1 for pgsql-general@arkaria.postgresql.org; Sun, 03 Jan 2021 18:00:09 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1kw7fj-0001LY-4S for pgsql-general@arkaria.postgresql.org; Sun, 03 Jan 2021 18:00:07 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kw7fh-0001LR-Bi for pgsql-general@lists.postgresql.org; Sun, 03 Jan 2021 18:00:06 +0000 Received: from wout2-smtp.messagingengine.com ([64.147.123.25]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kw7fe-0000z1-MZ for pgsql-general@lists.postgresql.org; Sun, 03 Jan 2021 18:00:04 +0000 Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.west.internal (Postfix) with ESMTP id 572ECC8B; Sun, 3 Jan 2021 13:00:00 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute3.internal (MEProxy); Sun, 03 Jan 2021 13:00:00 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aklaver.com; h= subject:to:references:from:message-id:date:mime-version :in-reply-to:content-type:content-transfer-encoding; s=fm1; bh=H kt5R0xJQ1zUcu3trRmCLFV3tM61tv3TOs1eYr7NlLI=; b=iLJw7lkMxp/jYfkWI 6mfM1S2G/OuVpR4yzlE78SXhamZDMB0SQLTX0WXyduVoSQ9FornDSyuGzdYZetgZ zwN+P5brbpmvlmP8DWq2H5HfcZciKNpudPQ1KRXoEXWOtkzdkkRBFsVZRB+Xbnhj lF5ASRJzhIPzxYlNkzjBlFnEmhVmkEOLKILqGWp5CHRZOpstVyrk1TO72bEnmRBc Jl6+Yrq2Dw8SbzLl/plGALGq0zuwTG8/Xchh9c1OJ7RcELSTUQOvMEAicb7saGnS mYB6XU1hlXhQsCp6IVATd96QyOWmlXZrqGPKUNeMvpnMLcQuNMPqbcdMV/YeLm5X +M1eg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm1; bh=Hkt5R0xJQ1zUcu3trRmCLFV3tM61tv3TOs1eYr7Nl LI=; b=BLhm4FFv+bwfXWhzyAwoNGcuRjTyg8pmevyaR/tfRQhog2eTIdD+qo68U dAjET7J0GBb85siQ9809GwhbYdXAWZIvES/uciUfKL7w9yLqmKw1+wq+ERqrXrUz vf3WJJ3iopTbYXiamNR11CIscPv4bd8dYUkPyc+DDrGZqBLi6x+UtRMz3lvZ0pKl OGaXGR8bcWXawOp4H3gl8Ye6LAfsHnrPpkDXtQBkKXyY0ROdLiWrvqbBnJq1t+sD 54VGBLgFPyDlF4bwfWVeet2sSsqr7RbRRZ4JN//cqLn3Z/YvszUHhqTnwfPhtS8I LKt+KM3c68F0sP8+MXAC0BcbANH7A== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedujedrvdefuddguddtkecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpefuvfhfhffkffgfgggjtgfgsehtkeertddtfeejnecuhfhrohhmpeetughr ihgrnhcumfhlrghvvghruceorggurhhirghnrdhklhgrvhgvrhesrghklhgrvhgvrhdrtg homheqnecuggftrfgrthhtvghrnhepveevfeevfeeugeffkeekhfegieeufffgteeujedv gffhueejjefhkeejleegtdegnecukfhppeejhedrudejvddrudegrddujeenucevlhhush htvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpegrughrihgrnhdrkhhl rghvvghrsegrkhhlrghvvghrrdgtohhm X-ME-Proxy: Received: from [192.168.1.4] (75-172-14-17.tukw.qwest.net [75.172.14.17]) by mail.messagingengine.com (Postfix) with ESMTPA id 1DA8D24005C; Sun, 3 Jan 2021 12:59:58 -0500 (EST) Subject: Re: Possible trigger bug? function call argument literalised To: Thiemo Kellner , PostgreSQL General References: <20210103180840.Horde.Fe4qNP3Uviz_9c6aPfxBTS2@webmail.gelassene-pferde.biz> <2692292.1609695452@sss.pgh.pa.us> <20210103184529.Horde.LO8-skyriHu3oMxD4rNG2WV@webmail.gelassene-pferde.biz> From: Adrian Klaver Message-ID: Date: Sun, 3 Jan 2021 09:59:57 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.6.0 MIME-Version: 1.0 In-Reply-To: <20210103184529.Horde.LO8-skyriHu3oMxD4rNG2WV@webmail.gelassene-pferde.biz> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 1/3/21 9:45 AM, Thiemo Kellner wrote: > > Quoting Tom Lane : > >> 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. >> > > Oh, thanks! I did not read careful enough. I could not imagine such a > behaviour to be intentional. > > Well, I guess, I can put the correct schema at installation, but would > have liked to have a more general approach. Furthermore, I think this > also implies that installation can only be done by psql. :-s Why not grab the CURRENT_SCHEMA in the function?: DECLARE V_COUNT smallint; C_SCHEMA varchar := CURRENT_SCHEMA; > -- Adrian Klaver adrian.klaver@aklaver.com