Re: Record comparison compiler warning - Mailing list pgsql-hackers

From Kevin Grittner
Subject Re: Record comparison compiler warning
Date
Msg-id 1381949353.78943.YahooMailNeo@web162902.mail.bf1.yahoo.com
Whole thread Raw
In response to Record comparison compiler warning  (Bruce Momjian <bruce@momjian.us>)
Responses Re: Record comparison compiler warning  (Bruce Momjian <bruce@momjian.us>)
List pgsql-hackers
Bruce Momjian <bruce@momjian.us> wrote:

> I am seeing this compiler warning in git head:
>
>     rowtypes.c: In function 'record_image_cmp':
>     rowtypes.c:1433: warning: 'cmpresult' may be used
>     uninitialized in this function rowtypes.c:1433: note: 'cmpresult' was declared here

I had not gotten a warning under either gcc or clang, but that was
probably because I was doing assert-enabled builds, and the
Assert(false) saved me.  That seemed a little marginal anyway, so
how about this?:

diff --git a/src/backend/utils/adt/rowtypes.c b/src/backend/utils/adt/rowtypes.c
index ae007cf..0332593 100644
--- a/src/backend/utils/adt/rowtypes.c
+++ b/src/backend/utils/adt/rowtypes.c
@@ -1508,7 +1508,11 @@ record_image_cmp(FunctionCallInfo fcinfo)
                        break;
 #endif
                    default:
-                       Assert(false);  /* cannot happen */
+                       /* cannot happen */
+                       elog(ERROR,
+                            "unexpected length of %i found comparing columns of type %s",
+                            (int) tupdesc1->attrs[i1]->attlen,
+                            format_type_be(tupdesc1->attrs[i1]->atttypid));
                }
            }
            else

Does that fix the warning for you?

--
Kevin Grittner
EDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company



pgsql-hackers by date:

Previous
From: Robert Haas
Date:
Subject: Re: [PATCH] pg_sleep(interval)
Next
From: Andres Freund
Date:
Subject: Re: removing old ports and architectures