Re: Record comparison compiler warning

Поиск
Список
Период
Сортировка
От Kevin Grittner
Тема Re: Record comparison compiler warning
Дата
Msg-id 1381949353.78943.YahooMailNeo@web162902.mail.bf1.yahoo.com
обсуждение исходный текст
Ответ на Record comparison compiler warning  (Bruce Momjian <bruce@momjian.us>)
Ответы Re: Record comparison compiler warning  (Bruce Momjian <bruce@momjian.us>)
Список 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 по дате отправления:

Предыдущее
От: Robert Haas
Дата:
Сообщение: Re: [PATCH] pg_sleep(interval)
Следующее
От: Andres Freund
Дата:
Сообщение: Re: removing old ports and architectures