Re: Trying to understand pg_get_expr()

From: Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com>
To: Marcos Pegoraro <marcos(at)f10(dot)com(dot)br>
Cc: pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: Trying to understand pg_get_expr()
Date: 2026-03-17 20:36:34
Message-ID: 5179b412-2eaa-4c96-89f3-53c2fb10dd31@aklaver.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 3/17/26 1:26 PM, Marcos Pegoraro wrote:
> Em ter., 17 de mar. de 2026 às 17:19, Adrian Klaver
> <adrian(dot)klaver(at)aklaver(dot)com <mailto:adrian(dot)klaver(at)aklaver(dot)com>> escreveu:
>
> I also tried other combinations of casting both sides of "=" and it
> still did not work.
>
>
> "'test'::character varying" is the result of that function, not type of test
> This should work
> AND pg_get_expr(adbin, adrelid) = $$'test'::character varying$$;

Yeah that worked.

It begs the question then, in:

SELECT
adrelid::regclass,
pg_typeof(pg_get_expr(adbin, adrelid)),
pg_get_expr(adbin, adrelid)
FROM
pg_attrdef
WHERE
adrelid = 'default_test'::regclass;

adrelid | pg_typeof | pg_get_expr
--------------+-----------+---------------------------
default_test | text | 'test'::character varying
default_test | text | 0

Why is the second case not?:

'0'::integer

>
> regards
> Marcos
>

--
Adrian Klaver
adrian(dot)klaver(at)aklaver(dot)com

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Marcos Pegoraro 2026-03-17 20:54:45 Re: Trying to understand pg_get_expr()
Previous Message Marcos Pegoraro 2026-03-17 20:26:52 Re: Trying to understand pg_get_expr()