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 1jOt9u-00039B-P0 for pgsql-bugs@arkaria.postgresql.org; Thu, 16 Apr 2020 01:17:38 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1jOt9t-0002iW-8n for pgsql-bugs@arkaria.postgresql.org; Thu, 16 Apr 2020 01:17:37 +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 1jOt9t-0002iO-0J for pgsql-bugs@lists.postgresql.org; Thu, 16 Apr 2020 01:17:37 +0000 Received: from mail-pl1-x642.google.com ([2607:f8b0:4864:20::642]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1jOt9q-0000E6-6k for pgsql-bugs@lists.postgresql.org; Thu, 16 Apr 2020 01:17:36 +0000 Received: by mail-pl1-x642.google.com with SMTP id k18so732883pll.6 for ; Wed, 15 Apr 2020 18:17:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=IsKCDmqQVIXhsHrXQ6AZ/6N/MZmRG2EcEpNbVnoP9Pk=; b=cGP43VKEu47OrpubAipp1DZxSVjKwl5vhByk3BJ7fvVH3hlS6PnkloIfG8JF2E2q/k gJ4yt0XyWqQJ/+4iKOogwdA1LvKPMgQj0OCzJumhgbSeLip2A6H7sN6pDHfuPWhLJr70 +IZ3ZxLP5HOqEeKg+Hxyf0g+RHdoge8MebMUPFvUv0EDz4zc/wZU17U8+2ACgWQVvzK9 k/MGvMbmjdcrw2JIcVJ8BUHITqrnOvYJvOPX//F3rszTTWDXrRjWrNNzuOhpDaKZ4aOn bOcn+aWs+qzL/LikakoE0hc/QAazEeEJIEXh3jUmn7uvYftaeQpJ4+jlqoVDrJOXwDzT Z8RA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=IsKCDmqQVIXhsHrXQ6AZ/6N/MZmRG2EcEpNbVnoP9Pk=; b=rIwX02mBtOIIbXfzO66yNEsfRDqQ55GnrKPtBYu1a6Ju2Bow5pwp7YtD1UT8m4L1GH TCM98YrxkTsFZ+VQiUVPVAAJcC8M0jI7cFIugt/82oz9AKQ+9E+gX8egcbUYqbz/jsxN GdKvII0krlh3xgp5U/tRDGJmjcgvit8YZc/10pqos0ErjhQDqYq2EsBTpkWsB8vHPZAh 8qD9Nu58Ao4P2V3STEyIN0t4qO9i3JDFKAlg5hb+RZA3D5bqDFR/IK/bbh8ZLhWct3az 6oae2QKr/SECmOCeWRTKWr3ieHhW7GNi0h93qPYMnGTRlmJ9gNoGKnJE55fynyHWDZGm TKHA== X-Gm-Message-State: AGi0PuZw3a2Pv0Bt1YHxAl6X/hhWykIQdTsO9XzCybbXRBbevAKA2lfA vQE/fqrVHzijgbcm4vv4Q++tcG8LHEy7gg== X-Google-Smtp-Source: APiQypLZ9tf7uWj3w01Zx8+0BbFL0MmsmA40B1ufYhioLSknEpXzYXAxEyerB31E65zQRAuYClstFA== X-Received: by 2002:a17:90a:e515:: with SMTP id t21mr2094537pjy.123.1586999851767; Wed, 15 Apr 2020 18:17:31 -0700 (PDT) Received: from hammer.magicstack.net ([52.119.126.69]) by smtp.gmail.com with ESMTPSA id 140sm4763312pfx.180.2020.04.15.18.17.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Apr 2020 18:17:31 -0700 (PDT) From: Elvis Pranskevichus To: "David G. Johnston" , Tom Lane Cc: PostgreSQL mailing lists Subject: Re: BUG #16368: Incorrect function inlining in the presence of a window function Date: Wed, 15 Apr 2020 18:17:30 -0700 Message-ID: <7058335.0AJ8ntve86@hammer.magicstack.net> In-Reply-To: <2039.1586996045@sss.pgh.pa.us> References: <16368-0dd1d5ab02a3cbc0@postgresql.org> <2039.1586996045@sss.pgh.pa.us> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On Wednesday, April 15, 2020 5:14:05 P.M. PDT Tom Lane wrote: > In point of fact, there are many ways in which CASE and related > constructs fail to guarantee evaluation order, as noted in > https://www.postgresql.org/docs/current/sql-expressions.html#SYNTAX-EX > PRESS-EVAL > > The particular case mentioned there seems to be about the same as > here: constant-folding happens even in CASE arms that will never be > reached at runtime. Yes, but function arguments aren't constants are they? At least the documentation makes no effort to mention that. > would be quite unhappy with the performance impact of de-optimizing > CASE that way. I'm not arguing for the general de-optimization for CASE, just for not treating arguments of inlined functions as constants in the CASE statement. For arguments of a prepared statement this optimization makes even less sense. Elvis