Skip to content

Commit

Permalink
Add hook in ConstraintAwareAppend as well
Browse files Browse the repository at this point in the history
  • Loading branch information
konskov committed Mar 6, 2024
1 parent 6dc244b commit b8c9702
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions src/nodes/constraint_aware_append/constraint_aware_append.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
#include "nodes/chunk_append/transform.h"
#include "guc.h"
#include "utils.h"
#include "osm_callbacks.h"
#include "chunk.h"

/*
* Exclude child relations (chunks) at execution time based on constraints.
Expand Down Expand Up @@ -255,7 +257,37 @@ ca_append_begin(CustomScanState *node, EState *estate, int eflags)
restrictinfos = lappend(restrictinfos, ri);
}
restrictinfos = constify_restrictinfos(&root, restrictinfos);
#if PG14_GE
chunk_startup_exclusion_hook_type osm_chunk_exclusion_hook =
ts_get_osm_chunk_startup_exclusion_hook();

if (osm_chunk_exclusion_hook)
{
Index rt_index = scanrelid;
RangeTblEntry *rte = rt_fetch(rt_index, estate->es_range_table);
Oid relid = rte->relid;
Chunk *chunk = ts_chunk_get_by_relid(relid, false);
Hypertable *ht = ts_hypertable_get_by_id(chunk->fd.hypertable_id);
int tiered_chunks_match = 0;

Check warning on line 271 in src/nodes/constraint_aware_append/constraint_aware_append.c

View check run for this annotation

Codecov / codecov/patch

src/nodes/constraint_aware_append/constraint_aware_append.c#L266-L271

Added lines #L266 - L271 were not covered by tests
// Index varno = rt_index;
if (chunk && IS_OSM_CHUNK(chunk))
{
tiered_chunks_match = osm_chunk_exclusion_hook(NameStr(ht->fd.schema_name),
NameStr(ht->fd.table_name),

Check warning on line 276 in src/nodes/constraint_aware_append/constraint_aware_append.c

View check run for this annotation

Codecov / codecov/patch

src/nodes/constraint_aware_append/constraint_aware_append.c#L275-L276

Added lines #L275 - L276 were not covered by tests
relid,
(ForeignScan *) plan,
restrictinfos,
rt_index);
if (tiered_chunks_match == 0)
{
// the OSM chunk can be skipped entirely
continue;

Check warning on line 284 in src/nodes/constraint_aware_append/constraint_aware_append.c

View check run for this annotation

Codecov / codecov/patch

src/nodes/constraint_aware_append/constraint_aware_append.c#L284

Added line #L284 was not covered by tests
}
}
}
#endif
// this expects the chunk to already have check constraints, which are used in
// can_exclude_chunk -> calling relation_excluded_by_constraints
if (can_exclude_chunk(&root, estate, scanrelid, restrictinfos))
continue;

Expand Down

0 comments on commit b8c9702

Please sign in to comment.