From 653dbc615a493d8da7f004b83533d450327fa596 Mon Sep 17 00:00:00 2001 From: Jeff Davis Date: Sat, 31 Oct 2020 13:34:26 -0700 Subject: [PATCH] Use -Werror --- Makefile | 4 ++-- cstore_customscan.c | 33 ++++++++++++++++++++------------- cstore_tableam.c | 2 +- cstore_writer.c | 1 + 4 files changed, 24 insertions(+), 16 deletions(-) diff --git a/Makefile b/Makefile index 5b65a08bb..04b9c12b2 100644 --- a/Makefile +++ b/Makefile @@ -25,7 +25,7 @@ else $(error version $(VER) is not supported) endif -PG_CFLAGS = -std=c11 -Wshadow +PG_CFLAGS = -std=c11 -Wshadow -Werror OBJS = cstore.o cstore_writer.o cstore_reader.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 \ 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_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 ifeq ($(USE_FDW),yes) diff --git a/cstore_customscan.c b/cstore_customscan.c index d7e6eb667..7c163e5c9 100644 --- a/cstore_customscan.c +++ b/cstore_customscan.c @@ -133,6 +133,8 @@ static void CStoreSetRelPathlistHook(PlannerInfo *root, RelOptInfo *rel, Index rti, RangeTblEntry *rte) { + Relation relation; + /* call into previous hook if assigned */ 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 * 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()) { + Path *customPath = CreateCStoreScanPath(rel, rte); + ereport(DEBUG1, (errmsg("pathlist hook for cstore table am"))); /* we propose a new path that will be the only path for scanning this relation */ - Path *customPath = CreateCStoreScanPath(rel, rte); clear_paths(rel); add_path(rel, customPath); } @@ -175,17 +178,19 @@ CreateCStoreScanPath(RelOptInfo *rel, RangeTblEntry *rte) { CStoreScanPath *cspath = (CStoreScanPath *) newNode(sizeof(CStoreScanPath), T_CustomPath); + CustomPath *cpath; + Path *path; /* * popuate custom path information */ - CustomPath *cpath = &cspath->custom_path; + cpath = &cspath->custom_path; cpath->methods = &CStoreScanPathMethods; /* * populate generic path information */ - Path *path = &cpath->path; + path = &cpath->path; path->pathtype = T_CustomScan; path->parent = rel; path->pathtarget = rel->reltarget; @@ -212,12 +217,13 @@ CStoreScanCost(RangeTblEntry *rte) { Relation rel = RelationIdGetRelation(rte->relid); DataFileMetadata *metadata = ReadDataFileMetadata(rel->rd_node.relNode, false); - RelationClose(rel); - rel = NULL; - uint32 maxColumnCount = 0; uint64 totalStripeSize = 0; ListCell *stripeMetadataCell = NULL; + + RelationClose(rel); + rel = NULL; + foreach(stripeMetadataCell, metadata->stripeMetadataList) { StripeMetadata *stripeMetadata = (StripeMetadata *) lfirst(stripeMetadataCell); @@ -225,12 +231,13 @@ CStoreScanCost(RangeTblEntry *rte) maxColumnCount = Max(maxColumnCount, stripeMetadata->columnCount); } - Bitmapset *attr_needed = rte->selectedCols; - double numberOfColumnsRead = bms_num_members(attr_needed); - double selectionRatio = numberOfColumnsRead / (double) maxColumnCount; - Cost scanCost = (double) totalStripeSize / BLCKSZ * selectionRatio; - - return scanCost; + { + Bitmapset *attr_needed = rte->selectedCols; + double numberOfColumnsRead = bms_num_members(attr_needed); + double selectionRatio = numberOfColumnsRead / (double) maxColumnCount; + Cost scanCost = (double) totalStripeSize / BLCKSZ * selectionRatio; + return scanCost; + } } diff --git a/cstore_tableam.c b/cstore_tableam.c index c22ab7baf..b1624f59f 100644 --- a/cstore_tableam.c +++ b/cstore_tableam.c @@ -244,6 +244,7 @@ cstore_beginscan_extended(Relation relation, Snapshot snapshot, List *columnList = NIL; List *neededColumnList = NIL; MemoryContext oldContext = MemoryContextSwitchTo(GetCStoreMemoryContext()); + ListCell *columnCell = NULL; scan->cs_base.rs_rd = relation; scan->cs_base.rs_snapshot = snapshot; @@ -255,7 +256,6 @@ cstore_beginscan_extended(Relation relation, Snapshot snapshot, columnList = RelationColumnList(relation); /* only collect columns that we need for the scan */ - ListCell *columnCell = NULL; foreach(columnCell, columnList) { Var *var = castNode(Var, lfirst(columnCell)); diff --git a/cstore_writer.c b/cstore_writer.c index 3be14994b..9ca8c806e 100644 --- a/cstore_writer.c +++ b/cstore_writer.c @@ -336,6 +336,7 @@ WriteToSmgr(Relation rel, uint64 logicalOffset, char *data, uint32 dataLength) RelationOpenSmgr(rel); nblocks = smgrnblocks(rel->rd_smgr, MAIN_FORKNUM); Assert(addr.blockno < nblocks); + (void) nblocks; /* keep compiler quiet */ RelationCloseSmgr(rel); buffer = ReadBuffer(rel, addr.blockno);