mirror of
https://github.com/postgres/postgres.git
synced 2025-07-28 23:42:10 +03:00
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
This commit is contained in:
@ -3978,13 +3978,13 @@ adjust_rowcompare_for_index(RowCompareExpr *clause,
|
||||
expr_op = get_opfamily_member(opfam, lefttype, righttype,
|
||||
op_strategy);
|
||||
if (!OidIsValid(expr_op)) /* 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",
|
||||
op_strategy, lefttype, righttype, opfam);
|
||||
if (!var_on_left)
|
||||
{
|
||||
expr_op = get_commutator(expr_op);
|
||||
if (!OidIsValid(expr_op)) /* should not happen */
|
||||
elog(ERROR, "could not find commutator of member %d(%u,%u) of opfamily %u",
|
||||
elog(ERROR, "could not find commutator of operator %d(%u,%u) of opfamily %u",
|
||||
op_strategy, lefttype, righttype, opfam);
|
||||
}
|
||||
new_ops = lappend_oid(new_ops, expr_op);
|
||||
|
@ -197,8 +197,8 @@ make_pathkey_from_sortinfo(PlannerInfo *root,
|
||||
opcintype,
|
||||
BTEqualStrategyNumber);
|
||||
if (!OidIsValid(equality_op)) /* shouldn't happen */
|
||||
elog(ERROR, "could not find equality operator for opfamily %u",
|
||||
opfamily);
|
||||
elog(ERROR, "missing operator %d(%u,%u) in opfamily %u",
|
||||
BTEqualStrategyNumber, opcintype, opcintype, opfamily);
|
||||
opfamilies = get_mergejoin_opfamilies(equality_op);
|
||||
if (!opfamilies) /* certainly should find some */
|
||||
elog(ERROR, "could not find opfamilies for equality operator %u",
|
||||
|
@ -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);
|
||||
|
||||
|
Reference in New Issue
Block a user