From 81ced1e037f5fede768549e56e7ec8a5c48b7844 Mon Sep 17 00:00:00 2001 From: Tom Lane <tgl@sss.pgh.pa.us> Date: Mon, 31 May 1999 19:32:47 +0000 Subject: [PATCH] Generate a more specific error message when an operator used in an index doesn't have a restriction selectivity estimator. --- src/backend/utils/adt/selfuncs.c | 66 +++++++++++++++++++++++++++++--- 1 file changed, 61 insertions(+), 5 deletions(-) diff --git a/src/backend/utils/adt/selfuncs.c b/src/backend/utils/adt/selfuncs.c index fc65ddc3f97..eb6bf557033 100644 --- a/src/backend/utils/adt/selfuncs.c +++ b/src/backend/utils/adt/selfuncs.c @@ -12,7 +12,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/adt/selfuncs.c,v 1.28 1999/05/25 16:12:20 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/selfuncs.c,v 1.29 1999/05/31 19:32:47 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -404,7 +404,21 @@ btreesel(Oid operatorObjectId, } else { - result = (float64) fmgr(get_oprrest(operatorObjectId), + RegProcedure oprrest = get_oprrest(operatorObjectId); + + /* + * Operators used for indexes should have selectivity estimators. + * (An alternative is to default to 0.5, as the optimizer does in + * dealing with operators occurring in WHERE clauses, but if you + * are going to the trouble of making index support you probably + * don't want to miss the benefits of a good selectivity estimate.) + */ + if (!oprrest) + elog(ERROR, + "Operator %u must have a restriction selectivity estimator to be used in a btree index", + operatorObjectId); + + result = (float64) fmgr(oprrest, (char *) operatorObjectId, (char *) indrelid, (char *) (int) attributeNumber, @@ -449,7 +463,21 @@ btreenpage(Oid operatorObjectId, } else { - temp = (float64) fmgr(get_oprrest(operatorObjectId), + RegProcedure oprrest = get_oprrest(operatorObjectId); + + /* + * Operators used for indexes should have selectivity estimators. + * (An alternative is to default to 0.5, as the optimizer does in + * dealing with operators occurring in WHERE clauses, but if you + * are going to the trouble of making index support you probably + * don't want to miss the benefits of a good selectivity estimate.) + */ + if (!oprrest) + elog(ERROR, + "Operator %u must have a restriction selectivity estimator to be used in a btree index", + operatorObjectId); + + temp = (float64) fmgr(oprrest, (char *) operatorObjectId, (char *) indrelid, (char *) (int) attributeNumber, @@ -514,7 +542,21 @@ hashsel(Oid operatorObjectId, } else { - result = (float64) fmgr(get_oprrest(operatorObjectId), + RegProcedure oprrest = get_oprrest(operatorObjectId); + + /* + * Operators used for indexes should have selectivity estimators. + * (An alternative is to default to 0.5, as the optimizer does in + * dealing with operators occurring in WHERE clauses, but if you + * are going to the trouble of making index support you probably + * don't want to miss the benefits of a good selectivity estimate.) + */ + if (!oprrest) + elog(ERROR, + "Operator %u must have a restriction selectivity estimator to be used in a hash index", + operatorObjectId); + + result = (float64) fmgr(oprrest, (char *) operatorObjectId, (char *) indrelid, (char *) (int) attributeNumber, @@ -578,7 +620,21 @@ hashnpage(Oid operatorObjectId, } else { - temp = (float64) fmgr(get_oprrest(operatorObjectId), + RegProcedure oprrest = get_oprrest(operatorObjectId); + + /* + * Operators used for indexes should have selectivity estimators. + * (An alternative is to default to 0.5, as the optimizer does in + * dealing with operators occurring in WHERE clauses, but if you + * are going to the trouble of making index support you probably + * don't want to miss the benefits of a good selectivity estimate.) + */ + if (!oprrest) + elog(ERROR, + "Operator %u must have a restriction selectivity estimator to be used in a hash index", + operatorObjectId); + + temp = (float64) fmgr(oprrest, (char *) operatorObjectId, (char *) indrelid, (char *) (int) attributeNumber, -- GitLab