Fix hint when dropping chunks with dependencies

When dropping chunks that have dependent objects, like a continuous
aggregate view, a dependent object error is raised. The hint message
is overridden to produce a more useful hint for the drop chunks use
case. However, the hint is overriden without checking the error code,
which means the hint is replaced for any error raised. This can
produce confusing log output.

The issue is fixed by first examining the error code before overriding
the hint.
This commit is contained in:
Erik Nordström 2020-09-08 08:48:56 +02:00 committed by Erik Nordström
parent caf64357f4
commit e6a61c065c

View File

@ -3456,10 +3456,14 @@ ts_chunk_drop_chunks(PG_FUNCTION_ARGS)
* CASCADE (we don't support it), so we replace the hint with a more
* accurate hint for our situation. */
ErrorData *edata;
MemoryContextSwitchTo(oldcontext);
edata = CopyErrorData();
FlushErrorState();
if (edata->sqlerrcode == ERRCODE_DEPENDENT_OBJECTS_STILL_EXIST)
edata->hint = pstrdup("Use DROP ... to drop the dependent objects.");
ts_cache_release(hcache);
ReThrowError(edata);
}