From 278cb4341103e967189997985b09981a73e23a34 Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Mon, 24 Jul 2017 11:23:27 -0400 Subject: Be more consistent about errors for opfamily member lookup failures. Add error checks in some places that were calling get_opfamily_member or get_opfamily_proc and just assuming that the call could never fail. Also, standardize the wording for such errors in some other places. None of these errors are expected in normal use, hence they're just elog not ereport. But they may be handy for diagnosing omissions in custom opclasses. Rushabh Lathia found the oversight in RelationBuildPartitionKey(); I found the others by grepping for all callers of these functions. Discussion: https://postgr.es/m/CAGPqQf2R9Nk8htpv0FFi+FP776EwMyGuORpc9zYkZKC8sFQE3g@mail.gmail.com --- src/backend/optimizer/plan/createplan.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src/backend/optimizer/plan/createplan.c') diff --git a/src/backend/optimizer/plan/createplan.c b/src/backend/optimizer/plan/createplan.c index e589d92c805..9d838e4f39a 100644 --- a/src/backend/optimizer/plan/createplan.c +++ b/src/backend/optimizer/plan/createplan.c @@ -2634,7 +2634,8 @@ create_indexscan_plan(PlannerInfo *root, exprtype, pathkey->pk_strategy); if (!OidIsValid(sortop)) - elog(ERROR, "failed to find sort operator for ORDER BY expression"); + elog(ERROR, "missing operator %d(%u,%u) in opfamily %u", + pathkey->pk_strategy, exprtype, exprtype, pathkey->pk_opfamily); indexorderbyops = lappend_oid(indexorderbyops, sortop); } } @@ -5738,7 +5739,7 @@ prepare_sort_from_pathkeys(Plan *lefttree, List *pathkeys, pk_datatype, pathkey->pk_strategy); if (!OidIsValid(sortop)) /* should not happen */ - elog(ERROR, "could not find member %d(%u,%u) of opfamily %u", + elog(ERROR, "missing operator %d(%u,%u) in opfamily %u", pathkey->pk_strategy, pk_datatype, pk_datatype, pathkey->pk_opfamily); @@ -6216,7 +6217,7 @@ make_unique_from_pathkeys(Plan *lefttree, List *pathkeys, int numCols) pk_datatype, BTEqualStrategyNumber); if (!OidIsValid(eqop)) /* should not happen */ - elog(ERROR, "could not find member %d(%u,%u) of opfamily %u", + elog(ERROR, "missing operator %d(%u,%u) in opfamily %u", BTEqualStrategyNumber, pk_datatype, pk_datatype, pathkey->pk_opfamily); -- cgit v1.2.3