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 1nLjYo-0005Kj-LQ for pgsql-general@arkaria.postgresql.org; Sun, 20 Feb 2022 10:35:22 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1nLjYn-0006VG-1V for pgsql-general@arkaria.postgresql.org; Sun, 20 Feb 2022 10:35:21 +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 1nLjYm-0006Uh-Ni for pgsql-general@lists.postgresql.org; Sun, 20 Feb 2022 10:35:20 +0000 Received: from mail-pj1-x1029.google.com ([2607:f8b0:4864:20::1029]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1nLjYk-0008Gh-10 for pgsql-general@lists.postgresql.org; Sun, 20 Feb 2022 10:35:19 +0000 Received: by mail-pj1-x1029.google.com with SMTP id q8-20020a17090a178800b001bc299b8de1so885760pja.1 for ; Sun, 20 Feb 2022 02:35:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:content-transfer-encoding:in-reply-to; bh=F2FAHeMKDGt7uM9uGqQN6j9vFCxpTrTevKcu9fXJa2M=; b=pjmDKghHLHcOMb4V2hDui4M0eo4ltmrn3ryIR0eH515OloJ3MLTA9uKFzIpn0FbCRX 2bFw7/KhxkPQ7+fz8UuF77a7vikueBx1RASlQnAAni4z8N1uaZMumjyZLYem/s2b0ukQ FOcUGRAjUFeDXM06VFeyXM7NmjQg2IVMCCH4G1/eXsSAbUYfz6x0i2+lty0A7ElJl40W kRobi4N4Bp8snqSYxRGszONe/4h54AKOEG47Dtma1pebANuWAE5+Eaq+0n48xiR/o1t+ B+HkdIdwSOIljYQF8ITswCe89x4K7PnQ6+jeccYW7kjbqIT66yK929tQ5OH4OU6hVDYv ODrw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to; bh=F2FAHeMKDGt7uM9uGqQN6j9vFCxpTrTevKcu9fXJa2M=; b=xsoZw3Cnxr/DnBu4OihoYQO8JoINOY3vFzLypgfzvmmZyUyFVHqvYIo6tG6UJuWi7h ZIj7X4oVjbU2OyWP7yeS2MyzrcF/ckq54MbCLLqdvRnWbD337YyW+/ogGGoiy3hjA5cA UKf2RtuPvTx8rmR3GJGYKKnFh58lb9CLDnB6Lpqq13Z5NVcQqgEITOS6FDupCOmMAekI 63BNNXxuYbF0k0wKCuebHEc8fOaqGSG0FgDs06RelDjLxpHZGw+eOzmqBcpu+15v0JX1 OUseLukhPridG2DgobS9hP2XmtsYK6UMVw5c/pJ3CAnhGfLAyY/Cup7co4wZwJnCbqix Cpcw== X-Gm-Message-State: AOAM533hP1lnPMt+QMtl5xKNFZW/KWZqyoqAd9G4cXWYnFOn2+PJ9Y7r b4Vs/8t2O29tf3bFzRq8hWTWLgC+bQo= X-Google-Smtp-Source: ABdhPJx2YlD9QHGW/jUJ0pDc+97DnoZj42/+jfAq7g4a/FIgBFEoH8DJNq8DEKdsYa5r2o11LkFyzQ== X-Received: by 2002:a17:902:9045:b0:14d:6829:f460 with SMTP id w5-20020a170902904500b0014d6829f460mr14674854plz.89.1645353316720; Sun, 20 Feb 2022 02:35:16 -0800 (PST) Received: from jrouhaud (2001-b011-1005-9e2f-255b-9d5f-9316-d485.dynamic-ip6.hinet.net. [2001:b011:1005:9e2f:255b:9d5f:9316:d485]) by smtp.gmail.com with ESMTPSA id i17sm14607946pgn.82.2022.02.20.02.35.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 20 Feb 2022 02:35:16 -0800 (PST) Date: Sun, 20 Feb 2022 18:35:08 +0800 From: Julien Rouhaud To: Markur Sens Cc: pgsql-general Subject: Re: Additional accessors via the Extension API ? Message-ID: <20220220103508.il2a3fpaeeys3mt3@jrouhaud> References: <6D4DE1F2-70C9-4BC4-92FD-0699BE0F8952@gmail.com> <20220220101257.dchizxpkang7vvq4@jrouhaud> <2C9AEE7B-89A0-49F6-AB28-F81AEC9B6078@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <2C9AEE7B-89A0-49F6-AB28-F81AEC9B6078@gmail.com> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Sun, Feb 20, 2022 at 12:31:22PM +0200, Markur Sens wrote: > > > > Maybe you could rely on some old grammar hack to have something a bit similar, > > as (expr).funcname is an alias for funcname(expr). For instance: > > Is this documented & expected behavior or it’s just happens to work? I don't think it's documented but it's an expected behavior, see https://github.com/postgres/postgres/blob/master/src/backend/parser/parse_func.c#L57-L88 /* * Parse a function call * * For historical reasons, Postgres tries to treat the notations tab.col * and col(tab) as equivalent: if a single-argument function call has an * argument of complex type and the (unqualified) function name matches * any attribute of the type, we can interpret it as a column projection. * Conversely a function of a single complex-type argument can be written * like a column reference, allowing functions to act like computed columns. * * If both interpretations are possible, we prefer the one matching the * syntactic form, but otherwise the form does not matter. * * Hence, both cases come through here. If fn is null, we're dealing with * column syntax not function syntax. In the function-syntax case, * the FuncCall struct is needed to carry various decoration that applies * to aggregate and window functions. [...]