Add a hypopg_reset_index() SQL wrapper.

This commit is contained in:
Julien Rouhaud 2018-03-03 11:40:32 +01:00
parent 054235ebd2
commit 2a7e30619e
3 changed files with 17 additions and 0 deletions

View file

@ -8,6 +8,11 @@
SET client_encoding = 'UTF8';
CREATE FUNCTION hypopg_reset_index()
RETURNS void
LANGUAGE C VOLATILE COST 100
AS '$libdir/hypopg', 'hypopg_reset_index';
CREATE FUNCTION hypopg_reset()
RETURNS void
LANGUAGE C VOLATILE COST 100

View file

@ -79,6 +79,7 @@ PG_FUNCTION_INFO_V1(hypopg_create_index);
PG_FUNCTION_INFO_V1(hypopg_drop_index);
PG_FUNCTION_INFO_V1(hypopg_relation_size);
PG_FUNCTION_INFO_V1(hypopg_get_indexdef);
PG_FUNCTION_INFO_V1(hypopg_reset_index);
static void hypo_addIndex(hypoIndex *entry);
@ -1338,6 +1339,16 @@ hypopg_get_indexdef(PG_FUNCTION_ARGS)
PG_RETURN_TEXT_P(cstring_to_text(buf.data));
}
/*
* SQL wrapper to remove all declared hypothetical indexes.
*/
Datum
hypopg_reset_index(PG_FUNCTION_ARGS)
{
hypo_index_reset();
PG_RETURN_VOID();
}
/* Simple function to set the indexname, dealing with max name length, and the
* ending \0

View file

@ -112,6 +112,7 @@ Datum hypopg_create_index(PG_FUNCTION_ARGS);
Datum hypopg_drop_index(PG_FUNCTION_ARGS);
Datum hypopg_relation_size(PG_FUNCTION_ARGS);
Datum hypopg_get_indexdef(PG_FUNCTION_ARGS);
Datum hypopg_reset_index(PG_FUNCTION_ARGS);
extern explain_get_index_name_hook_type prev_explain_get_index_name_hook;
const char *hypo_explain_get_index_name_hook(Oid indexId);