pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Julien Rouhaud <rjuju123@gmail.com>
To: Markur Sens <markursens@gmail.com>
Cc: pgsql-general <pgsql-general@lists.postgresql.org>
Subject: Re: Additional accessors via the Extension API ?
Date: Sun, 20 Feb 2022 18:35:08 +0800
Message-ID: <20220220103508.il2a3fpaeeys3mt3@jrouhaud> (raw)
In-Reply-To: <2C9AEE7B-89A0-49F6-AB28-F81AEC9B6078@gmail.com>
References: <6D4DE1F2-70C9-4BC4-92FD-0699BE0F8952@gmail.com>
	<20220220101257.dchizxpkang7vvq4@jrouhaud>
	<2C9AEE7B-89A0-49F6-AB28-F81AEC9B6078@gmail.com>

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.
[...]





view thread (6+ messages)  latest in thread

Message-ID: <20220220103508.il2a3fpaeeys3mt3@jrouhaud>
Permalink:  ../20220220103508.il2a3fpaeeys3mt3@jrouhaud/
Also on:    postgresql.org/message-id/20220220103508.il2a3fpaeeys3mt3@jrouhaud

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: rjuju123@gmail.com, markursens@gmail.com
  Subject: Re: Additional accessors via the Extension API ?
  In-Reply-To: <20220220103508.il2a3fpaeeys3mt3@jrouhaud>
  References: <6D4DE1F2-70C9-4BC4-92FD-0699BE0F8952@gmail.com> <20220220101257.dchizxpkang7vvq4@jrouhaud> <2C9AEE7B-89A0-49F6-AB28-F81AEC9B6078@gmail.com> <20220220103508.il2a3fpaeeys3mt3@jrouhaud>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox