From: | Rajan Pandey <rajanpandey2508(at)gmail(dot)com> |
---|---|
To: | pgsql-hackers(at)postgresql(dot)org |
Subject: | Why is 'use_alias' hardcoded to true in deparseFromExprForRel() for some cases |
Date: | 2024-07-16 10:49:44 |
Message-ID: | CAPr50M=FyGU2ayWFi7103O94irT_BQYEW3=Z+6dzFjnFpzgC+Q@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Hi everyone,
In the postgrs_fdw deparser code, deparseFromExprForRel() appends an alias
to the remote query based on the 'use_alias' boolean flag.
For a simple query, 'use_alias' is determined by
`bms_membership(scanrel->relids) == BMS_MULTIPLE` condition. Example:
https://github.com/postgres/postgres/blob/master/contrib/postgres_fdw/deparse.c#L1385C2-L1388
But for JOINs, 'use_alias' is always hardcoded to true. Examples:
1.
https://github.com/postgres/postgres/blob/master/contrib/postgres_fdw/deparse.c#L2067-L2069
2.
https://github.com/postgres/postgres/blob/master/contrib/postgres_fdw/deparse.c#L2336-L2337
3.
https://github.com/postgres/postgres/blob/master/contrib/postgres_fdw/deparse.c#L2419-L2420
This seems like an extra-protection in case of joins. But it could happen
that the join is across 2 different foreign postgres-servers (means each
foreign server will do SCAN only, and the JOIN will happen at the upper
layer). In that case, using aliases in the remote queries seem redundant to
me.
Please correct me if I am missing something. Can we note pass
`bms_membership(foreignrel->relids) == BMS_MULTIPLE` instead?
--
Regards
Rajan Pandey
Software Developer, AWS
From | Date | Subject | |
---|---|---|---|
Next Message | Alexander Lakhin | 2024-07-16 11:00:00 | Re: [EXTERNAL] Re: Add non-blocking version of PQcancel |
Previous Message | Yasir | 2024-07-16 10:47:18 | Re: errors building on windows using meson |