public inbox for [email protected]
help / color / mirror / Atom feedFrom: Tom Lane <[email protected]>
To: Adrian Klaver <[email protected]>
Cc: Marcos Pegoraro <[email protected]>
Cc: pgsql-general <[email protected]>
Subject: Re: Trying to understand pg_get_expr()
Date: Tue, 17 Mar 2026 17:04:50 -0400
Message-ID: <[email protected]> (raw)
In-Reply-To: <[email protected]>
References: <[email protected]>
<CAB-JLwZdyUfnC047MzV9woskWH2dToNJEudR34AD8WprEn8Cig@mail.gmail.com>
<[email protected]>
<CAB-JLwbwKi6q_fG7ByGRJe-L+m9Nx+WHiTP0qhEw7qKzv37QQA@mail.gmail.com>
<[email protected]>
Adrian Klaver <[email protected]> writes:
> adrelid | pg_typeof | pg_get_expr
> --------------+-----------+---------------------------
> default_test | text | 'test'::character varying
> default_test | text | 0
> Why is the second case not?:
> '0'::integer
PG's parser automatically attributes type integer to an unadorned
integer literal, so no cast is necessary there, and pg_get_expr
doesn't add one. But an unadorned string like 'test' does not
have a determinate type (well, it has type "unknown", but that
is an implementation artifact). We emit a cast construct to show
what type the constant was resolved as.
The bigger picture here is that pg_get_expr relies on the same
code that is used for purposes like dumping views. We want the
output to be such that subexpressions of a view will certainly
be parsed as the same type they were interpreted as before.
regards, tom lane
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 using the --to and --cc options:
reply via email
To: [email protected]
Cc: [email protected], [email protected], [email protected]
Subject: Re: Trying to understand pg_get_expr()
In-Reply-To: <[email protected]>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox