Re: postgres_fdw: Handle boolean comparison predicates - Mailing list pgsql-hackers

From Ashutosh Bapat
Subject Re: postgres_fdw: Handle boolean comparison predicates
Date
Msg-id CAExHW5tFOphpmHebhGjPxKh3JNyspBwfmK9p=ovrC3D0TPFu2A@mail.gmail.com
Whole thread Raw
In response to postgres_fdw: Handle boolean comparison predicates  (Emre Hasegeli <emre@hasegeli.com>)
Responses Re: postgres_fdw: Handle boolean comparison predicates  (Emre Hasegeli <emre@hasegeli.com>)
List pgsql-hackers
Hi Emre,
This looks like a good improvement.

Please add this patch to the commitfest so that it's not forgotten. It
will be considered as a new feature so will be considered for commit
after the next commitfest.

Mean time here are some comments.
+/*
+ * Deparse IS [NOT] TRUE/FALSE/UNKNOWN expression.
+ */
+static void
+deparseBooleanTest(BooleanTest *node, deparse_expr_cxt *context)
+{
+    StringInfo    buf = context->buf;
+
+    switch (node->booltesttype)
+    {

+        case IS_NOT_TRUE:
+            appendStringInfoString(buf, "(NOT ");
+            deparseExpr(node->arg, context);
+            appendStringInfoString(buf, " OR ");
+            deparseExpr(node->arg, context);
+            appendStringInfoString(buf, " IS NULL)");
+            break;

+}

I don't understand why we need to complicate the expressions when
sending those to the foreign nodes. Why do we want to send (xyz IS
FALSE) (NOT (xyz) OR (xyz IS NULL)) and not as just (xyz IS FALSE).
The latter is much more readable and less error-prone. That true for
all the BooleanTest deparsing.

+EXPLAIN (VERBOSE, COSTS OFF) SELECT * FROM ft1 t1 WHERE (c1 = 100) IS
TRUE;            -- BooleanTest

Also test a boolean column?

On Mon, May 31, 2021 at 1:33 PM Emre Hasegeli <emre@hasegeli.com> wrote:
>
> The comparison predicates IS [NOT] TRUE/FALSE/UNKNOWN were not
> recognised by postgres_fdw, so they were not pushed down to the remote
> server.  The attached patch adds support for them.
>
> I am adding this to the commitfest 2021-07.



-- 
Best Wishes,
Ashutosh Bapat



pgsql-hackers by date:

Previous
From: Amit Kapila
Date:
Subject: Re: Skipping logical replication transactions on subscriber side
Next
From: Michael Paquier
Date:
Subject: Re: Incorrect snapshots while promoting hot standby node when 2PC is used