pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
pgsql: postgres_fdw: Fix assertion in estimate_path_cost_size().
5+ messages / 3 participants
[nested] [flat]

* pgsql: postgres_fdw: Fix assertion in estimate_path_cost_size().
@ 2021-02-05 06:35 Etsuro Fujita <efujita@postgresql.org>
  0 siblings, 0 replies; 5+ messages in thread

From: Etsuro Fujita @ 2021-02-05 06:35 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

postgres_fdw: Fix assertion in estimate_path_cost_size().

Commit 08d2d58a2 added an assertion assuming that the retrieved_rows
estimate for a foreign relation, which is re-used to cost pre-sorted
foreign paths with local stats, is set to at least one row in
estimate_path_cost_size(), which isn't correct because if the relation
is a foreign table with tuples=0, the estimate would be set to 0 there
when not using remote estimates.

Per bug #16807 from Alexander Lakhin.  Back-patch to v13 where the
aforementioned commit went in.

Author: Etsuro Fujita
Reviewed-by: Kyotaro Horiguchi
Discussion: https://postgr.es/m/16807-9fe4e08fbaa5c7ce%40postgresql.org

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/5e7fa189ee92d5ecf42a295c336625d71bfe876d

Modified Files
--------------
contrib/postgres_fdw/expected/postgres_fdw.out | 18 ++++++++++++++++++
contrib/postgres_fdw/postgres_fdw.c            |  2 +-
contrib/postgres_fdw/sql/postgres_fdw.sql      | 12 ++++++++++++
3 files changed, 31 insertions(+), 1 deletion(-)



^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* pgsql: postgres_fdw: Fix assertion in estimate_path_cost_size().
@ 2021-02-05 06:35 Etsuro Fujita <efujita@postgresql.org>
  2022-12-12 12:28 ` Re: pgsql: postgres_fdw: Fix assertion in estimate_path_cost_size(). Robins Tharakan <tharakan@gmail.com>
  0 siblings, 1 reply; 5+ messages in thread

From: Etsuro Fujita @ 2021-02-05 06:35 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

postgres_fdw: Fix assertion in estimate_path_cost_size().

Commit 08d2d58a2 added an assertion assuming that the retrieved_rows
estimate for a foreign relation, which is re-used to cost pre-sorted
foreign paths with local stats, is set to at least one row in
estimate_path_cost_size(), which isn't correct because if the relation
is a foreign table with tuples=0, the estimate would be set to 0 there
when not using remote estimates.

Per bug #16807 from Alexander Lakhin.  Back-patch to v13 where the
aforementioned commit went in.

Author: Etsuro Fujita
Reviewed-by: Kyotaro Horiguchi
Discussion: https://postgr.es/m/16807-9fe4e08fbaa5c7ce%40postgresql.org

Branch
------
REL_13_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/984384129bb8a92481d4f7ddd5dede2d781b191f

Modified Files
--------------
contrib/postgres_fdw/expected/postgres_fdw.out | 18 ++++++++++++++++++
contrib/postgres_fdw/postgres_fdw.c            |  2 +-
contrib/postgres_fdw/sql/postgres_fdw.sql      | 12 ++++++++++++
3 files changed, 31 insertions(+), 1 deletion(-)



^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: pgsql: postgres_fdw: Fix assertion in estimate_path_cost_size().
  2021-02-05 06:35 pgsql: postgres_fdw: Fix assertion in estimate_path_cost_size(). Etsuro Fujita <efujita@postgresql.org>
@ 2022-12-12 12:28 ` Robins Tharakan <tharakan@gmail.com>
  2022-12-14 09:53   ` Re: pgsql: postgres_fdw: Fix assertion in estimate_path_cost_size(). Etsuro Fujita <etsuro.fujita@gmail.com>
  0 siblings, 1 reply; 5+ messages in thread

From: Robins Tharakan @ 2022-12-12 12:28 UTC (permalink / raw)
  To: Etsuro Fujita <efujita@postgresql.org>; +Cc: pgsql-committers@lists.postgresql.org

Hi,

I think this bugfix needs to be backpatched to v12 too.

See backtrace / repro SQL here -
https://www.postgresql.org/message-id/17713-92cce66de7e81c04%40postgresql.org

-
Robins Tharakan
Amazon Web Services

On Fri, 5 Feb 2021 at 17:05, Etsuro Fujita <efujita@postgresql.org> wrote:
>
> postgres_fdw: Fix assertion in estimate_path_cost_size().
>
> Commit 08d2d58a2 added an assertion assuming that the retrieved_rows
> estimate for a foreign relation, which is re-used to cost pre-sorted
> foreign paths with local stats, is set to at least one row in
> estimate_path_cost_size(), which isn't correct because if the relation
> is a foreign table with tuples=0, the estimate would be set to 0 there
> when not using remote estimates.
>
> Per bug #16807 from Alexander Lakhin.  Back-patch to v13 where the
> aforementioned commit went in.
>
> Author: Etsuro Fujita
> Reviewed-by: Kyotaro Horiguchi
> Discussion: https://postgr.es/m/16807-9fe4e08fbaa5c7ce%40postgresql.org
>
> Branch
> ------
> REL_13_STABLE
>
> Details
> -------
> https://git.postgresql.org/pg/commitdiff/984384129bb8a92481d4f7ddd5dede2d781b191f
>
> Modified Files
> --------------
> contrib/postgres_fdw/expected/postgres_fdw.out | 18 ++++++++++++++++++
> contrib/postgres_fdw/postgres_fdw.c            |  2 +-
> contrib/postgres_fdw/sql/postgres_fdw.sql      | 12 ++++++++++++
> 3 files changed, 31 insertions(+), 1 deletion(-)
>





^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: pgsql: postgres_fdw: Fix assertion in estimate_path_cost_size().
  2021-02-05 06:35 pgsql: postgres_fdw: Fix assertion in estimate_path_cost_size(). Etsuro Fujita <efujita@postgresql.org>
  2022-12-12 12:28 ` Re: pgsql: postgres_fdw: Fix assertion in estimate_path_cost_size(). Robins Tharakan <tharakan@gmail.com>
@ 2022-12-14 09:53   ` Etsuro Fujita <etsuro.fujita@gmail.com>
  0 siblings, 0 replies; 5+ messages in thread

From: Etsuro Fujita @ 2022-12-14 09:53 UTC (permalink / raw)
  To: Robins Tharakan <tharakan@gmail.com>; +Cc: Etsuro Fujita <efujita@postgresql.org>; pgsql-committers@lists.postgresql.org

Hi Robins,

On Mon, Dec 12, 2022 at 9:29 PM Robins Tharakan <tharakan@gmail.com> wrote:
> I think this bugfix needs to be backpatched to v12 too.
>
> See backtrace / repro SQL here -
> https://www.postgresql.org/message-id/17713-92cce66de7e81c04%40postgresql.org

I misunderstood that the mentioned commit was added in v13.  :-(  Will
back-patch to v12 as well.  Thanks for the report!

Best regards,
Etsuro Fujita





^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* pgsql: postgres_fdw: Fix assertion in estimate_path_cost_size().
@ 2022-12-15 12:21 Etsuro Fujita <efujita@postgresql.org>
  0 siblings, 0 replies; 5+ messages in thread

From: Etsuro Fujita @ 2022-12-15 12:21 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

postgres_fdw: Fix assertion in estimate_path_cost_size().

Commit 08d2d58a2 added this assertion assuming that the retrieved_rows
estimate for a foreign relation is set to at least one row in
estimate_path_cost_size(), but the assumption isn't correct because if
the relation is a foreign table with tuples=0, the estimate would be set
to 0 in there when using local stats, and if the query's WHERE clause
has a NULL condition, the estimate could be set to 0 in there when using
remote estimates.  (Note: even in the latter case the assertion could be
reachable when costing foreign final paths.)  Repair.

Per bug #17713 from Robins Tharakan.  This patch was already applied to
v13 or later; apply it to v12 as well where the aforementioned commit
was added.  Thanks to Richard Guo for investigation.

Discussion: http://postgr.es/m/17713-92cce66de7e81c04%40postgresql.org
Discussion: http://postgr.es/m/CAEP4nAza%2B0fTCLkgkKYux3JDo3tUBTQORehP%2BaCxSNURpSFpHw%40mail.gmail.com

Branch
------
REL_12_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/69f75bf825f83dc506e73cf88f0adde541c39004

Modified Files
--------------
contrib/postgres_fdw/expected/postgres_fdw.out | 18 ++++++++++++++++++
contrib/postgres_fdw/postgres_fdw.c            |  2 +-
contrib/postgres_fdw/sql/postgres_fdw.sql      | 12 ++++++++++++
3 files changed, 31 insertions(+), 1 deletion(-)



^ permalink  raw  reply  [nested|flat] 5+ messages in thread


end of thread, other threads:[~2022-12-15 12:21 UTC | newest]

Thread overview: 5+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2021-02-05 06:35 pgsql: postgres_fdw: Fix assertion in estimate_path_cost_size(). Etsuro Fujita <efujita@postgresql.org>
2021-02-05 06:35 pgsql: postgres_fdw: Fix assertion in estimate_path_cost_size(). Etsuro Fujita <efujita@postgresql.org>
2022-12-12 12:28 ` Robins Tharakan <tharakan@gmail.com>
2022-12-14 09:53   ` Etsuro Fujita <etsuro.fujita@gmail.com>
2022-12-15 12:21 pgsql: postgres_fdw: Fix assertion in estimate_path_cost_size(). Etsuro Fujita <efujita@postgresql.org>

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