mirror of
https://github.com/HypoPG/hypopg
synced 2026-05-24 01:28:51 +00:00
Check that hypopg_relation_size was given a hypothetical index oid.
And error out instead of returning 0 if that's not the case. While at it, some iterating over the list of hypothetical indexes once we found the wanted one.
This commit is contained in:
parent
e7d1fea516
commit
1a5766274d
3 changed files with 12 additions and 0 deletions
|
|
@ -105,6 +105,9 @@ ORDER BY indexrelid;
|
|||
f
|
||||
(3 rows)
|
||||
|
||||
-- Should detect invalid argument
|
||||
SELECT hypopg_relation_size(1);
|
||||
ERROR: oid 1 is not a hypothetical index
|
||||
-- locally disable hypoopg
|
||||
SET hypopg.enabled to false;
|
||||
-- no hypothetical index should be used
|
||||
|
|
|
|||
|
|
@ -1388,6 +1388,7 @@ hypopg_relation_size(PG_FUNCTION_ARGS)
|
|||
double tuples;
|
||||
Oid indexid = PG_GETARG_OID(0);
|
||||
ListCell *lc;
|
||||
bool found = false;
|
||||
|
||||
pages = 0;
|
||||
tuples = 0;
|
||||
|
|
@ -1398,9 +1399,14 @@ hypopg_relation_size(PG_FUNCTION_ARGS)
|
|||
if (entry->oid == indexid)
|
||||
{
|
||||
hypo_estimate_index_simple(entry, &pages, &tuples);
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!found)
|
||||
elog(ERROR, "oid %u is not a hypothetical index", indexid);
|
||||
|
||||
PG_RETURN_INT64(pages * 1.0L * BLCKSZ);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -70,6 +70,9 @@ SELECT hypopg_relation_size(indexrelid) = current_setting('block_size')::bigint
|
|||
FROM hypopg()
|
||||
ORDER BY indexrelid;
|
||||
|
||||
-- Should detect invalid argument
|
||||
SELECT hypopg_relation_size(1);
|
||||
|
||||
-- locally disable hypoopg
|
||||
SET hypopg.enabled to false;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue