Improve Assert output

From: Peter Eisentraut <peter(dot)eisentraut(at)2ndquadrant(dot)com>
To: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Improve Assert output
Date: 2019-08-14 20:28:55
Message-ID: 6c68efe3-117a-dcc1-73d4-18ba1ec532e2@2ndquadrant.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

This kind of output is usually not helpful:

TRAP: BadArgument("((context) != ((void *)0) && (((((const
Node*)((context)))->type) == T_AllocSetContext) || ((((const
Node*)((context)))->type) == T_SlabContext) || ((((const
Node*)((context)))->type) == T_GenerationContext)))", File:
"../../../../src/include/utils/memutils.h", Line: 129)

What we probably want is something like:

TRAP: BadArgument("MemoryContextIsValid(context)", File:
"../../../../src/include/utils/memutils.h", Line: 129)

The problem is that the way the Assert macros are written they
macro-expand the arguments before stringifying them. The attached patch
fixes that. This requires both replacing CppAsString by plain "#" and
not redirecting Assert() to Trap().

--
Peter Eisentraut http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services

Attachment Content-Type Size
0001-Improve-Assert-output.patch text/plain 2.1 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2019-08-14 20:36:40 Re: Improve Assert output
Previous Message Tom Lane 2019-08-14 19:15:42 Re: [PATCH] Stop ALTER SYSTEM from making bad assumptions