For a long time, PostgreSQL has had a get_relation_info_hook which
plugins can use to editorialize on the information that
get_relation_info obtains from the catalogs. However, this hook is
only called for baserels of type RTE_RELATION, and there is
potential utility in a similar call back for other types of
RTEs. This might have had utility even before commit
4020b370f214315b8c10430301898ac21658143f added pgs_mask to
RelOptInfo, but it certainly has utility now.
So, move the callback up one level, deleting get_relation_info_hook and
adding build_simple_rel_hook instead. The new callback is called just
slightly later than before and with slightly different arguments, but it
should be fairly straightforward to adjust existing code that currently
uses get_relation_info_hook: the values previously available as
relationObjectId and inhparent are now available via rte->relid and
rte->inh, and calls where rte->rtekind != RTE_RELATION can be ignored if
desired.
Reviewed-by: Alexandra Wang <alexandra.wang.oss@gmail.com>
Discussion: http://postgr.es/m/CA%2BTgmoYg8uUWyco7Pb3HYLMBRQoO6Zh9hwgm27V39Pb6Pdf%3Dug%40mail.gmail.com
/* GUC parameter */
int constraint_exclusion = CONSTRAINT_EXCLUSION_PARTITION;
-/* Hook for plugins to get control in get_relation_info() */
-get_relation_info_hook_type get_relation_info_hook = NULL;
-
typedef struct NotnullHashEntry
{
Oid relid; /* OID of the relation */
set_relation_partition_info(root, rel, relation);
table_close(relation, NoLock);
-
- /*
- * Allow a plugin to editorialize on the info we obtained from the
- * catalogs. Actions might include altering the assumed relation size,
- * removing an index, or adding a hypothetical index to the indexlist.
- *
- * An extension can also modify rel->pgs_mask here to control path
- * generation.
- */
- if (get_relation_info_hook)
- (*get_relation_info_hook) (root, relationObjectId, inhparent, rel);
}
/*
RelOptInfo *join_rel;
} JoinHashEntry;
+/* Hook for plugins to get control in build_simple_rel() */
+build_simple_rel_hook_type build_simple_rel_hook = NULL;
+
/* Hook for plugins to get control during joinrel setup */
joinrel_setup_hook_type joinrel_setup_hook = NULL;
break;
}
+ /*
+ * Allow a plugin to editorialize on the new RelOptInfo. This could
+ * involve editorializing on the information which get_relation_info
+ * obtained from the catalogs, such as altering the assumed relation size,
+ * removing an index, or adding a hypothetical index to the indexlist.
+ *
+ * An extension can also modify rel->pgs_mask here to control path
+ * generation.
+ */
+ if (build_simple_rel_hook)
+ (*build_simple_rel_hook) (root, rel, rte);
+
/*
* Apply the parent's quals to the child, with appropriate substitution of
* variables. If any resulting clause is reduced to constant FALSE or
#include "nodes/bitmapset.h"
#include "nodes/pathnodes.h"
+/* Hook for plugins to get control in build_simple_rel() */
+typedef void (*build_simple_rel_hook_type) (PlannerInfo *root,
+ RelOptInfo *rel,
+ RangeTblEntry *rte);
+extern PGDLLIMPORT build_simple_rel_hook_type build_simple_rel_hook;
+
/*
* Everything in subpaths or partial_subpaths will become part of the
* Append node's subpaths list. Partial and non-partial subpaths can be
#include "nodes/pathnodes.h"
#include "utils/relcache.h"
-/* Hook for plugins to get control in get_relation_info() */
-typedef void (*get_relation_info_hook_type) (PlannerInfo *root,
- Oid relationObjectId,
- bool inhparent,
- RelOptInfo *rel);
-extern PGDLLIMPORT get_relation_info_hook_type get_relation_info_hook;
-
-
extern void get_relation_info(PlannerInfo *root, Oid relationObjectId,
bool inhparent, RelOptInfo *rel);