Re: Record comparison compiler warning

From: Kevin Grittner <kgrittn(at)ymail(dot)com>
To: Bruce Momjian <bruce(at)momjian(dot)us>, PostgreSQL-development <pgsql-hackers(at)postgreSQL(dot)org>
Subject: Re: Record comparison compiler warning
Date: 2013-10-16 18:49:13
Message-ID: 1381949353.78943.YahooMailNeo@web162902.mail.bf1.yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Bruce Momjian <bruce(at)momjian(dot)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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Andres Freund 2013-10-16 19:26:37 Re: removing old ports and architectures
Previous Message Robert Haas 2013-10-16 18:40:07 Re: [PATCH] pg_sleep(interval)