bdr: Don't use send/recv protocol for array/composite types.
authorAndres Freund <andres@anarazel.de>
Wed, 14 May 2014 11:17:31 +0000 (13:17 +0200)
committerAndres Freund <andres@anarazel.de>
Thu, 3 Jul 2014 15:55:36 +0000 (17:55 +0200)
contrib/bdr/bdr_output.c

index 38c23d4a9ea88367dde3a482e3b1909c608b87b0..eaeebf5b374fd0f450776c190cd234e650ce6db7 100644 (file)
@@ -647,7 +647,7 @@ decide_datum_transfer(BdrOutputData *data,
                      Form_pg_attribute att, Form_pg_type typclass,
                      bool *use_binary, bool *use_sendrecv)
 {
-   /* builtin type */
+   /* always disallow fancyness if there's type representation mismatches */
    if (data->int_datetime_mismatch &&
        (att->atttypid == TIMESTAMPOID || att->atttypid == TIMESTAMPTZOID ||
         att->atttypid == TIMEOID))
@@ -655,6 +655,9 @@ decide_datum_transfer(BdrOutputData *data,
        *use_binary = false;
        *use_sendrecv = false;
    }
+   /*
+    * Use the binary protocol, if allowed, for builtin & plain datatypes.
+    */
    else if (data->allow_binary_protocol &&
        typclass->typtype == 'b' &&
        att->atttypid < FirstNormalObjectId &&
@@ -662,8 +665,16 @@ decide_datum_transfer(BdrOutputData *data,
    {
        *use_binary = true;
    }
+   /*
+    * Use send/recv, if allowed, if the type is plain or builtin.
+    *
+    * XXX: we can't use send/recv for array or composite types for now due to
+    * the embedded oids.
+    */
    else if (data->allow_sendrecv_protocol &&
-            OidIsValid(typclass->typreceive))
+            OidIsValid(typclass->typreceive) &&
+            (att->atttypid < FirstNormalObjectId || typclass->typtype != 'c') &&
+            (att->atttypid < FirstNormalObjectId || typclass->typelem == InvalidOid))
    {
        *use_sendrecv = true;
    }