Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1wXGVl-003A6H-09 for pgsql-hackers@arkaria.postgresql.org; Wed, 10 Jun 2026 10:50:17 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wXGVj-00Anay-2r for pgsql-hackers@arkaria.postgresql.org; Wed, 10 Jun 2026 10:50:15 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1wXGUE-00AkUI-1P for pgsql-hackers@lists.postgresql.org; Wed, 10 Jun 2026 10:48:42 +0000 Received: from mail-vs1-xe30.google.com ([2607:f8b0:4864:20::e30]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1wXGUB-00000001zkU-1pa5 for pgsql-hackers@postgresql.org; Wed, 10 Jun 2026 10:48:41 +0000 Received: by mail-vs1-xe30.google.com with SMTP id ada2fe7eead31-6c28e1511adso3902001137.0 for ; Wed, 10 Jun 2026 03:48:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1781088519; cv=none; d=google.com; s=arc-20240605; b=HBqwMsg6SWYIS+1owDA7UP4Fnyd/kn5CsiunH1MUYfuUWf96/lgZKw3NAqRgaYPvZY uT/BshLTblnY2mti/9uduVpkF5LBWdSFME7QAC4K17JYToGy7zCu1dq/7kv2GObrGs9z ZJbzIshoXBu56bIRWJM4ZB/Rd68NNYiTsEdLp1b7d2r7JSwD++Iv+1VXrs54KphhLvZZ Karp9wbFQ5O1cc7xiJLKy+Du40ui0U97QosPleZikylgHkL25HpoSMKyU6kDfFyxqk3L 8QetJzW7AtUzZQn9c6am0r4WeLCqMheWFtuWhL3/NnKGDews9RzCmdr78Dk9Lz1Pc/c2 rMCA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=7KynMvF/6lM2SPK1lGuARfVQbZUISRwwwhIqssEEqEw=; fh=ABqr/gj36lxoDOZQdS+EQmJWBAcsMHu9sfFNC28o9NA=; b=gVQ+2QkrjmKyDGM60bNI5P/dp0duYA/t1zgGfO1+V3YA+XjaX1JNFpgYjP/ISyBGbU i+jdEhVIuncTFLcWG5bD+z5j9YwL43BttRCT4wOgPn9OCxx2HTSH+QYfexlFaDqoxo5f xz/qIWqoSTdyRn+GZ5HnoZZN686ISfW3yTORig9cSRMN7ExoYpBuRUFZVTsck3cL95vt qfDafa5goEOcbsM/vx2QgsD0zmG0RzDpHKf7N570sO7k4tyGe3VHa8ng/hQ1KDUFPDTL RR2v6kM2PumQbDTPZxpAxeQy5W0A4jptJuUCm/wFWgfk3vV0KuNCxe/wN3nXC+HAYupP 3qXQ==; darn=postgresql.org ARC-Authentication-Results: i=1; mx.google.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1781088519; x=1781693319; darn=postgresql.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=7KynMvF/6lM2SPK1lGuARfVQbZUISRwwwhIqssEEqEw=; b=mhu8veul+g9Itii/uch5jaG8oDWBeqrvgcJZjh96tqdFt0UUk3ZnCVGvMAIzpW6M/0 GGyVdI+US3YplhHphYuagUsOL1wPojhUmAyeEpa9O6s00BMJyzpNBX80U7yZUDGZ2gM6 GjC5WeqRaTCzMZHooC3QIiHNyCVm1oo77doXN3J5I7CY7fgIyUdzcWE6nxSrd4ipyZ5W YK9Ji4duaLJJCmtG8vMAvErovWLUbHeUVUC8nNkSeyDJlZD/xLg7iUh6rgYmszLgwRMy gswfN33ftBLisYle73QMALO3JOzi2n8embS6u+So76QBcjwLX9ECZ79IYjI/XlD5bnIF HcjA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1781088519; x=1781693319; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=7KynMvF/6lM2SPK1lGuARfVQbZUISRwwwhIqssEEqEw=; b=nvVDsTUP434oTLrjMNTx4j21Ss0FGGXvAmQ404ypDNiciiC8n7Em2TNqOFrgBK2dLm gOZ0o4t7O8z0LNB28c2nGY0YAoRjMPsqKszXl5XtHTwK3i4y4HnI7Ao8Vk8e9U44bPHf w8nDPTFZCvsb6nwr2Dsk3VrO91b+0WILXym96zIQ2rrl8S46ZZsRu5GhbZdmhJotx2/X XuN2GIrqNV04imYrlQuknLFnG6S/tK2tsEbulv3o1k7xPhJWREhvX16zJBzlL9KILkLZ Liu70wev2e6LehhmHTpZomJFzB4Fk2Fi3CSSTHl9hh33CGHsRe1zHFqsiJt4edKV5oVZ PIVg== X-Forwarded-Encrypted: i=1; AFNElJ9I70CXwX3cNx0/Q+Wej/oR9Q50jE4v0RWoIL6nyVQqhm7M8RPQ7qMpKeUM7FX+vtVHmtUA2h0Tw6iN55Aw@postgresql.org X-Gm-Message-State: AOJu0YxUtfL2gdbXj6Z8K/47GK7YGakkJwCnve0w8GsPsXQ35yUYDKOP oTuwiLStghw/m3ZRrmXilJsFq7S/1Bo3+q6Ge6a1qYRL25k6djZGzbcs12Aj+e0acOHvNp1kP4Y u7Tspai10UbqHj05I7X9lK3qRQww6Sko= X-Gm-Gg: Acq92OFGCIY11cK8oy/ey7jy+BGegOTtpvRSjdTmTEbZi5byydLqsDSjqkCFGjwi/a8 VYwXeu3Smd0kVAHUn8cXy7tUQVhkC+8USSVgHWjExeamYMigDSoa7MThMEt/bdtaEZaSrlq/IFW AkSwG+JNJKbOXoAkKLgXzL2M5A/uRkIBnhCtmhVMNVvZZZ6MdRc/uqocNudkqX5IWr3LdAj8PfD rNI06WFbZqnD7HGNAC8w3/4DMutV+D6P+b4UWFx1s7LiJtynGNUV1JU+RqaRN2MwoG8/ndLoG5I QK1+y3RZat1WqHYW8MvPDj6HWQ733B9BK5/nUgWSOZuDJp5IOllivkOGiwmfvEnVdnQruWWIvRc ugXWcDUuhQEHLUvOhrIF/DHwW9WYEluskZAgI9MZv8HlJVKK5f9g2QpRw5HhRObH1v0yYWHP+nG soXXm8gDt6E2j0Xst3Dd94oz+ib8ivmAlnPh4= X-Received: by 2002:a05:6102:2c01:b0:643:80f1:33d1 with SMTP id ada2fe7eead31-6fef1848cdcmr15249188137.13.1781088518355; Wed, 10 Jun 2026 03:48:38 -0700 (PDT) MIME-Version: 1.0 References: <20260604.132108.405136284364833955.ishii@postgresql.org> <20260609.171307.1883356507067957349.ishii@postgresql.org> In-Reply-To: From: jian he Date: Wed, 10 Jun 2026 18:48:01 +0800 X-Gm-Features: AVVi8CcZd-lNmUCAyJPd8G4TGNl_ZIDgAvzhsXd2b6OFB8rpvRAoWzcRBtztn0I Message-ID: Subject: Re: Row pattern recognition To: assam258@gmail.com Cc: Tatsuo Ishii , zsolt.parragi@percona.com, sjjang112233@gmail.com, vik@postgresfriends.org, er@xs4all.nl, jacob.champion@enterprisedb.com, david.g.johnston@gmail.com, peter@eisentraut.org, li.evan.chao@gmail.com, pgsql-hackers@postgresql.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Wed, Jun 10, 2026 at 2:10=E2=80=AFPM Henson Choi wr= ote: > > Hi Tatsuo, Jian, > > > =3D=3D 2. PREV/NEXT/FIRST/LAST placeholders collide with user functions = =3D=3D > > The nav operations are polymorphic pg_catalog functions (anyelement, OIDs > 8126-8133) recognized by funcid in parse_func.c, which collides with > same-name user functions. > > Outside DEFINE, a same-name function masks or clashes with the placeholde= r: > with public.last(anyelement), SELECT last(123) fails "cannot use last > outside a DEFINE clause"; with public.next(numeric), SELECT next(10) fail= s > "function next(integer) is not unique"; and even with no user function, > last(123) errors instead of "function last(integer) does not exist". > > Inside DEFINE, a same-name function with an exact-type match beats the > anyelement placeholder, so PREV(price) silently becomes a plain FuncExpr > instead of an RPRNavExpr -- a wrong match result with no error (reproduce= d > for numeric, text and int). And ruleutils deparses a bare PREV(, so > reparsing a view under a search_path with public.prev rebinds it (pg_dump > is safe via search_path =3D ''). > > This is original v47 design, not a regression. Per the standard, > PREV/NEXT/FIRST/LAST are navigation operations with dedicated syntax, not > general-namespace functions -- the collision comes from mapping them onto > catalog functions plus search-path resolution. > > I haven't found a clean approach yet. Inside DEFINE these names have to = be > the navigation operation (per the standard), yet outside DEFINE they > shouldn't shadow or break same-name user functions the way the catalog > placeholders do -- and since the deparse output is unqualified (a bare > PREV(...)), whatever we choose also has to round-trip cleanly. I'm not > sure how best to reconcile those. > > My rough leaning is to not add catalog functions for these at all: leave > resolution outside DEFINE exactly as it is today, and only inside DEFINE > adjust the function-resolution path itself to recognize the navigation > operations. But that is still quite abstract. > > Question: how would you approach this? > SELECT first_value(1); ERROR: window function first_value requires an OVER clause LINE 1: SELECT first_value(1); ^ select prosrc, prokind, proname from pg_proc where proname =3D 'prev' or proname =3D 'first' or proname =3D 'last' or proname =3D 'next'; I am wondering, why the above query result functions not makred as window function in catalog?