]> granicus.if.org Git - postgresql/commitdiff
Remove use of byte-masking macros in record_image_cmp
authorPeter Eisentraut <peter_e@gmx.net>
Tue, 23 Jan 2018 15:55:40 +0000 (10:55 -0500)
committerPeter Eisentraut <peter_e@gmx.net>
Thu, 25 Jan 2018 14:41:19 +0000 (09:41 -0500)
These were introduced in 4cbb646334b3b998a29abef0d57608d42097e6c9, but
after further analysis and testing, they should not be necessary and
probably weren't the part of that commit that fixed anything.

Reviewed-by: Michael Paquier <michael.paquier@gmail.com>
src/backend/utils/adt/rowtypes.c

index a5fabfcc9e2c698c4243a4abc6ab2a93a1db5ac6..5f729342f8d028ae04b60c305fa1abd89002198d 100644 (file)
@@ -1467,45 +1467,8 @@ record_image_cmp(FunctionCallInfo fcinfo)
                        }
                        else if (att1->attbyval)
                        {
-                               switch (att1->attlen)
-                               {
-                                       case 1:
-                                               if (GET_1_BYTE(values1[i1]) !=
-                                                       GET_1_BYTE(values2[i2]))
-                                               {
-                                                       cmpresult = (GET_1_BYTE(values1[i1]) <
-                                                                                GET_1_BYTE(values2[i2])) ? -1 : 1;
-                                               }
-                                               break;
-                                       case 2:
-                                               if (GET_2_BYTES(values1[i1]) !=
-                                                       GET_2_BYTES(values2[i2]))
-                                               {
-                                                       cmpresult = (GET_2_BYTES(values1[i1]) <
-                                                                                GET_2_BYTES(values2[i2])) ? -1 : 1;
-                                               }
-                                               break;
-                                       case 4:
-                                               if (GET_4_BYTES(values1[i1]) !=
-                                                       GET_4_BYTES(values2[i2]))
-                                               {
-                                                       cmpresult = (GET_4_BYTES(values1[i1]) <
-                                                                                GET_4_BYTES(values2[i2])) ? -1 : 1;
-                                               }
-                                               break;
-#if SIZEOF_DATUM == 8
-                                       case 8:
-                                               if (GET_8_BYTES(values1[i1]) !=
-                                                       GET_8_BYTES(values2[i2]))
-                                               {
-                                                       cmpresult = (GET_8_BYTES(values1[i1]) <
-                                                                                GET_8_BYTES(values2[i2])) ? -1 : 1;
-                                               }
-                                               break;
-#endif
-                                       default:
-                                               Assert(false);  /* cannot happen */
-                               }
+                               if (values1[i1] != values2[i2])
+                                       cmpresult = (values1[i1] < values2[i2]) ? -1 : 1;
                        }
                        else
                        {
@@ -1739,29 +1702,7 @@ record_image_eq(PG_FUNCTION_ARGS)
                        }
                        else if (att1->attbyval)
                        {
-                               switch (att1->attlen)
-                               {
-                                       case 1:
-                                               result = (GET_1_BYTE(values1[i1]) ==
-                                                                 GET_1_BYTE(values2[i2]));
-                                               break;
-                                       case 2:
-                                               result = (GET_2_BYTES(values1[i1]) ==
-                                                                 GET_2_BYTES(values2[i2]));
-                                               break;
-                                       case 4:
-                                               result = (GET_4_BYTES(values1[i1]) ==
-                                                                 GET_4_BYTES(values2[i2]));
-                                               break;
-#if SIZEOF_DATUM == 8
-                                       case 8:
-                                               result = (GET_8_BYTES(values1[i1]) ==
-                                                                 GET_8_BYTES(values2[i2]));
-                                               break;
-#endif
-                                       default:
-                                               Assert(false);  /* cannot happen */
-                               }
+                               result = (values1[i1] == values2[i2]);
                        }
                        else
                        {