Commit 8d4b311d authored by Tomas Vondra's avatar Tomas Vondra

Make pg_get_statisticsobjdef_expressions return NULL

The usual behavior for functions in ruleutils.c is to return NULL when
the object does not exist. pg_get_statisticsobjdef_expressions raised an
error instead, so correct that.

Reported-by: Justin Pryzby
Discussion: https://postgr.es/m/20210505210947.GA27406%40telsasoft.com
parent b65431ca
...@@ -1759,9 +1759,9 @@ pg_get_statisticsobjdef_expressions(PG_FUNCTION_ARGS) ...@@ -1759,9 +1759,9 @@ pg_get_statisticsobjdef_expressions(PG_FUNCTION_ARGS)
statexttup = SearchSysCache1(STATEXTOID, ObjectIdGetDatum(statextid)); statexttup = SearchSysCache1(STATEXTOID, ObjectIdGetDatum(statextid));
if (!HeapTupleIsValid(statexttup)) if (!HeapTupleIsValid(statexttup))
elog(ERROR, "cache lookup failed for statistics object %u", statextid); PG_RETURN_NULL();
/* has the statistics expressions? */ /* Does the stats object have expressions? */
has_exprs = !heap_attisnull(statexttup, Anum_pg_statistic_ext_stxexprs, NULL); has_exprs = !heap_attisnull(statexttup, Anum_pg_statistic_ext_stxexprs, NULL);
/* no expressions? we're done */ /* no expressions? we're done */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment