diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2014-04-14 11:10:32 -0400 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2014-04-14 11:18:47 -0400 |
commit | 4dfb065b3ab662dcc96d07ee7fc9dadf6975a0cb (patch) | |
tree | 928e0bbc28f649ed28a7dfc3a816f449247dc119 /src/backend/access/gist/gistproc.c | |
parent | f0aa6c06d4e114ecb7ed81a2168238bbcfd54878 (diff) | |
download | postgresql-4dfb065b3ab662dcc96d07ee7fc9dadf6975a0cb.tar.gz |
Fix bogus handling of bad strategy number in GIST consistent() functions.
Make sure we throw an error instead of silently doing the wrong thing when
fed a strategy number we don't recognize. Also, in the places that did
already throw an error, spell the error message in a way more consistent
with our message style guidelines.
Per report from Paul Jones. Although this is a bug, it won't occur unless
a superuser tries to do something he shouldn't, so it doesn't seem worth
back-patching.
Diffstat (limited to 'src/backend/access/gist/gistproc.c')
-rw-r--r-- | src/backend/access/gist/gistproc.c | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/src/backend/access/gist/gistproc.c b/src/backend/access/gist/gistproc.c index 6e1e204769..db0bec6e3e 100644 --- a/src/backend/access/gist/gistproc.c +++ b/src/backend/access/gist/gistproc.c @@ -926,7 +926,9 @@ gist_box_leaf_consistent(BOX *key, BOX *query, StrategyNumber strategy) PointerGetDatum(query))); break; default: - retval = FALSE; + elog(ERROR, "unrecognized strategy number: %d", strategy); + retval = false; /* keep compiler quiet */ + break; } return retval; } @@ -1015,7 +1017,9 @@ rtree_internal_consistent(BOX *key, BOX *query, StrategyNumber strategy) PointerGetDatum(query))); break; default: - retval = FALSE; + elog(ERROR, "unrecognized strategy number: %d", strategy); + retval = false; /* keep compiler quiet */ + break; } return retval; } @@ -1306,7 +1310,9 @@ gist_point_consistent_internal(StrategyNumber strategy, } break; default: - elog(ERROR, "unknown strategy number: %d", strategy); + elog(ERROR, "unrecognized strategy number: %d", strategy); + result = false; /* keep compiler quiet */ + break; } return result; @@ -1422,8 +1428,9 @@ gist_point_consistent(PG_FUNCTION_ARGS) } break; default: - elog(ERROR, "unknown strategy number: %d", strategy); + elog(ERROR, "unrecognized strategy number: %d", strategy); result = false; /* keep compiler quiet */ + break; } PG_RETURN_BOOL(result); @@ -1445,8 +1452,9 @@ gist_point_distance(PG_FUNCTION_ARGS) PG_GETARG_POINT_P(1)); break; default: - elog(ERROR, "unknown strategy number: %d", strategy); + elog(ERROR, "unrecognized strategy number: %d", strategy); distance = 0.0; /* keep compiler quiet */ + break; } PG_RETURN_FLOAT8(distance); |