From 92e160344321e2ac26ea782ff3ccfc37eaf0703f Mon Sep 17 00:00:00 2001 From: Hadi Moshayedi Date: Thu, 8 Oct 2020 11:03:07 -0700 Subject: [PATCH 1/2] Remove shadowed variables --- Makefile | 2 +- cstore_reader.c | 7 +++---- cstore_writer.c | 3 +-- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/Makefile b/Makefile index ac7e15037..461c33280 100644 --- a/Makefile +++ b/Makefile @@ -25,7 +25,7 @@ else $(error version $(VER) is not supported) endif -PG_CPPFLAGS = -std=c11 +PG_CPPFLAGS = -std=c11 -Wshadow OBJS = cstore.o cstore_writer.o cstore_reader.o \ cstore_compression.o mod.o cstore_metadata_tables.o diff --git a/cstore_reader.c b/cstore_reader.c index 499c990d4..69a115ed9 100644 --- a/cstore_reader.c +++ b/cstore_reader.c @@ -179,7 +179,6 @@ CStoreReadNextRow(TableReadState *readState, Datum *columnValues, bool *columnNu uint32 lastBlockIndex = 0; uint32 blockRowCount = 0; uint32 stripeRowCount = 0; - StripeMetadata *stripeMetadata = readState->currentStripeMetadata; stripeRowCount = stripeMetadata->rowCount; lastBlockIndex = stripeRowCount / stripeMetadata->blockRowCount; @@ -995,10 +994,10 @@ ColumnDefaultValue(TupleConstr *tupleConstraints, Form_pg_attribute attributeFor for (defValIndex = 0; defValIndex < tupleConstraints->num_defval; defValIndex++) { - AttrDefault defaultValue = tupleConstraints->defval[defValIndex]; - if (defaultValue.adnum == attributeForm->attnum) + AttrDefault attrDefault = tupleConstraints->defval[defValIndex]; + if (attrDefault.adnum == attributeForm->attnum) { - defaultValueNode = stringToNode(defaultValue.adbin); + defaultValueNode = stringToNode(attrDefault.adbin); break; } } diff --git a/cstore_writer.c b/cstore_writer.c index 8069f4aba..9d57ec275 100644 --- a/cstore_writer.c +++ b/cstore_writer.c @@ -386,7 +386,7 @@ WriteToSmgr(TableWriteState *writeState, char *data, uint32 dataLength) while (addr.blockno >= nblocks) { - Buffer buffer = ReadBuffer(rel, P_NEW); + buffer = ReadBuffer(rel, P_NEW); ReleaseBuffer(buffer); nblocks = smgrnblocks(rel->rd_smgr, MAIN_FORKNUM); } @@ -534,7 +534,6 @@ FlushStripe(TableWriteState *writeState) for (columnIndex = 0; columnIndex < columnCount; columnIndex++) { ColumnBuffers *columnBuffers = stripeBuffers->columnBuffersArray[columnIndex]; - uint32 blockIndex = 0; for (blockIndex = 0; blockIndex < stripeSkipList->blockCount; blockIndex++) { From d1c7d9f09d6a5eb8405c3807f4a6b02b86019227 Mon Sep 17 00:00:00 2001 From: Hadi Moshayedi Date: Thu, 8 Oct 2020 11:29:27 -0700 Subject: [PATCH 2/2] address feedback --- Makefile | 2 +- cstore_reader.c | 5 +---- cstore_writer.c | 4 ++-- 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/Makefile b/Makefile index 461c33280..6ef8431c8 100644 --- a/Makefile +++ b/Makefile @@ -25,7 +25,7 @@ else $(error version $(VER) is not supported) endif -PG_CPPFLAGS = -std=c11 -Wshadow +PG_CFLAGS = -std=c11 -Wshadow OBJS = cstore.o cstore_writer.o cstore_reader.o \ cstore_compression.o mod.o cstore_metadata_tables.o diff --git a/cstore_reader.c b/cstore_reader.c index 69a115ed9..cf2d0b171 100644 --- a/cstore_reader.c +++ b/cstore_reader.c @@ -988,7 +988,6 @@ DeserializeBlockData(StripeBuffers *stripeBuffers, uint64 blockIndex, static Datum ColumnDefaultValue(TupleConstr *tupleConstraints, Form_pg_attribute attributeForm) { - Datum defaultValue = 0; Node *defaultValueNode = NULL; int defValIndex = 0; @@ -1009,7 +1008,7 @@ ColumnDefaultValue(TupleConstr *tupleConstraints, Form_pg_attribute attributeFor if (IsA(defaultValueNode, Const)) { Const *constNode = (Const *) defaultValueNode; - defaultValue = constNode->constvalue; + return constNode->constvalue; } else { @@ -1018,8 +1017,6 @@ ColumnDefaultValue(TupleConstr *tupleConstraints, Form_pg_attribute attributeFor errhint("Expression is either mutable or " "does not evaluate to constant value"))); } - - return defaultValue; } diff --git a/cstore_writer.c b/cstore_writer.c index 9d57ec275..2c0ca541e 100644 --- a/cstore_writer.c +++ b/cstore_writer.c @@ -386,8 +386,8 @@ WriteToSmgr(TableWriteState *writeState, char *data, uint32 dataLength) while (addr.blockno >= nblocks) { - buffer = ReadBuffer(rel, P_NEW); - ReleaseBuffer(buffer); + Buffer newBuffer = ReadBuffer(rel, P_NEW); + ReleaseBuffer(newBuffer); nblocks = smgrnblocks(rel->rd_smgr, MAIN_FORKNUM); }