Use -Werror

merge-cstore-pykello
Jeff Davis 2020-10-31 13:34:26 -07:00
parent d455ef6785
commit 653dbc615a
4 changed files with 24 additions and 16 deletions

View File

@ -25,7 +25,7 @@ else
$(error version $(VER) is not supported) $(error version $(VER) is not supported)
endif endif
PG_CFLAGS = -std=c11 -Wshadow PG_CFLAGS = -std=c11 -Wshadow -Werror
OBJS = cstore.o cstore_writer.o cstore_reader.o \ OBJS = cstore.o cstore_writer.o cstore_reader.o \
cstore_compression.o mod.o cstore_metadata_tables.o cstore_compression.o mod.o cstore_metadata_tables.o
@ -40,7 +40,7 @@ EXTRA_CLEAN = sql/fdw_block_filtering.sql sql/fdw_create.sql sql/fdw_data_types.
sql/fdw_copyto.sql expected/fdw_block_filtering.out expected/fdw_create.out \ sql/fdw_copyto.sql expected/fdw_block_filtering.out expected/fdw_create.out \
expected/fdw_data_types.out expected/fdw_load.out expected/fdw_copyto.out \ expected/fdw_data_types.out expected/fdw_load.out expected/fdw_copyto.out \
sql/am_block_filtering.sql sql/am_create.sql sql/am_data_types.sql sql/am_load.sql \ sql/am_block_filtering.sql sql/am_create.sql sql/am_data_types.sql sql/am_load.sql \
sql/am_copyto.sql expected/am_block_filtering.out expected/am_create.out \ sql/am_copyto.sql expected/am_block_filtering.out \
expected/am_data_types.out expected/am_load.out expected/am_copyto.out expected/am_data_types.out expected/am_load.out expected/am_copyto.out
ifeq ($(USE_FDW),yes) ifeq ($(USE_FDW),yes)

View File

@ -133,6 +133,8 @@ static void
CStoreSetRelPathlistHook(PlannerInfo *root, RelOptInfo *rel, Index rti, CStoreSetRelPathlistHook(PlannerInfo *root, RelOptInfo *rel, Index rti,
RangeTblEntry *rte) RangeTblEntry *rte)
{ {
Relation relation;
/* call into previous hook if assigned */ /* call into previous hook if assigned */
if (PreviousSetRelPathlistHook) if (PreviousSetRelPathlistHook)
{ {
@ -156,13 +158,14 @@ CStoreSetRelPathlistHook(PlannerInfo *root, RelOptInfo *rel, Index rti,
* If that is the case we want to insert an extra path that pushes down the projection * If that is the case we want to insert an extra path that pushes down the projection
* into the scan of the table to minimize the data read. * into the scan of the table to minimize the data read.
*/ */
Relation relation = RelationIdGetRelation(rte->relid); relation = RelationIdGetRelation(rte->relid);
if (relation->rd_tableam == GetCstoreTableAmRoutine()) if (relation->rd_tableam == GetCstoreTableAmRoutine())
{ {
Path *customPath = CreateCStoreScanPath(rel, rte);
ereport(DEBUG1, (errmsg("pathlist hook for cstore table am"))); ereport(DEBUG1, (errmsg("pathlist hook for cstore table am")));
/* we propose a new path that will be the only path for scanning this relation */ /* we propose a new path that will be the only path for scanning this relation */
Path *customPath = CreateCStoreScanPath(rel, rte);
clear_paths(rel); clear_paths(rel);
add_path(rel, customPath); add_path(rel, customPath);
} }
@ -175,17 +178,19 @@ CreateCStoreScanPath(RelOptInfo *rel, RangeTblEntry *rte)
{ {
CStoreScanPath *cspath = (CStoreScanPath *) newNode(sizeof(CStoreScanPath), CStoreScanPath *cspath = (CStoreScanPath *) newNode(sizeof(CStoreScanPath),
T_CustomPath); T_CustomPath);
CustomPath *cpath;
Path *path;
/* /*
* popuate custom path information * popuate custom path information
*/ */
CustomPath *cpath = &cspath->custom_path; cpath = &cspath->custom_path;
cpath->methods = &CStoreScanPathMethods; cpath->methods = &CStoreScanPathMethods;
/* /*
* populate generic path information * populate generic path information
*/ */
Path *path = &cpath->path; path = &cpath->path;
path->pathtype = T_CustomScan; path->pathtype = T_CustomScan;
path->parent = rel; path->parent = rel;
path->pathtarget = rel->reltarget; path->pathtarget = rel->reltarget;
@ -212,12 +217,13 @@ CStoreScanCost(RangeTblEntry *rte)
{ {
Relation rel = RelationIdGetRelation(rte->relid); Relation rel = RelationIdGetRelation(rte->relid);
DataFileMetadata *metadata = ReadDataFileMetadata(rel->rd_node.relNode, false); DataFileMetadata *metadata = ReadDataFileMetadata(rel->rd_node.relNode, false);
RelationClose(rel);
rel = NULL;
uint32 maxColumnCount = 0; uint32 maxColumnCount = 0;
uint64 totalStripeSize = 0; uint64 totalStripeSize = 0;
ListCell *stripeMetadataCell = NULL; ListCell *stripeMetadataCell = NULL;
RelationClose(rel);
rel = NULL;
foreach(stripeMetadataCell, metadata->stripeMetadataList) foreach(stripeMetadataCell, metadata->stripeMetadataList)
{ {
StripeMetadata *stripeMetadata = (StripeMetadata *) lfirst(stripeMetadataCell); StripeMetadata *stripeMetadata = (StripeMetadata *) lfirst(stripeMetadataCell);
@ -225,12 +231,13 @@ CStoreScanCost(RangeTblEntry *rte)
maxColumnCount = Max(maxColumnCount, stripeMetadata->columnCount); maxColumnCount = Max(maxColumnCount, stripeMetadata->columnCount);
} }
Bitmapset *attr_needed = rte->selectedCols; {
double numberOfColumnsRead = bms_num_members(attr_needed); Bitmapset *attr_needed = rte->selectedCols;
double selectionRatio = numberOfColumnsRead / (double) maxColumnCount; double numberOfColumnsRead = bms_num_members(attr_needed);
Cost scanCost = (double) totalStripeSize / BLCKSZ * selectionRatio; double selectionRatio = numberOfColumnsRead / (double) maxColumnCount;
Cost scanCost = (double) totalStripeSize / BLCKSZ * selectionRatio;
return scanCost; return scanCost;
}
} }

View File

@ -244,6 +244,7 @@ cstore_beginscan_extended(Relation relation, Snapshot snapshot,
List *columnList = NIL; List *columnList = NIL;
List *neededColumnList = NIL; List *neededColumnList = NIL;
MemoryContext oldContext = MemoryContextSwitchTo(GetCStoreMemoryContext()); MemoryContext oldContext = MemoryContextSwitchTo(GetCStoreMemoryContext());
ListCell *columnCell = NULL;
scan->cs_base.rs_rd = relation; scan->cs_base.rs_rd = relation;
scan->cs_base.rs_snapshot = snapshot; scan->cs_base.rs_snapshot = snapshot;
@ -255,7 +256,6 @@ cstore_beginscan_extended(Relation relation, Snapshot snapshot,
columnList = RelationColumnList(relation); columnList = RelationColumnList(relation);
/* only collect columns that we need for the scan */ /* only collect columns that we need for the scan */
ListCell *columnCell = NULL;
foreach(columnCell, columnList) foreach(columnCell, columnList)
{ {
Var *var = castNode(Var, lfirst(columnCell)); Var *var = castNode(Var, lfirst(columnCell));

View File

@ -336,6 +336,7 @@ WriteToSmgr(Relation rel, uint64 logicalOffset, char *data, uint32 dataLength)
RelationOpenSmgr(rel); RelationOpenSmgr(rel);
nblocks = smgrnblocks(rel->rd_smgr, MAIN_FORKNUM); nblocks = smgrnblocks(rel->rd_smgr, MAIN_FORKNUM);
Assert(addr.blockno < nblocks); Assert(addr.blockno < nblocks);
(void) nblocks; /* keep compiler quiet */
RelationCloseSmgr(rel); RelationCloseSmgr(rel);
buffer = ReadBuffer(rel, addr.blockno); buffer = ReadBuffer(rel, addr.blockno);