Merge pull request #3 from citusdata/add_reindent

Add 'make reindent'
merge-cstore-pykello
Hadi Moshayedi 2020-09-07 15:51:09 -07:00 committed by GitHub
commit 85a51fb2ef
13 changed files with 143 additions and 112 deletions

26
.gitattributes vendored Normal file
View File

@ -0,0 +1,26 @@
* whitespace=space-before-tab,trailing-space
*.[chly] whitespace=space-before-tab,trailing-space,indent-with-non-tab,tabwidth=4
*.dsl whitespace=space-before-tab,trailing-space,tab-in-indent
*.patch -whitespace
*.pl whitespace=space-before-tab,trailing-space,tabwidth=4
*.po whitespace=space-before-tab,trailing-space,tab-in-indent,-blank-at-eof
*.sgml whitespace=space-before-tab,trailing-space,tab-in-indent,-blank-at-eol
*.x[ms]l whitespace=space-before-tab,trailing-space,tab-in-indent
# Avoid confusing ASCII underlines with leftover merge conflict markers
README conflict-marker-size=32
README.* conflict-marker-size=32
# Certain data files that contain special whitespace, and other special cases
*.data -whitespace
# Test output files that contain extra whitespace
*.out -whitespace
src/test/regress/output/*.source -whitespace
# These files are maintained or generated elsewhere. We take them as is.
configure -whitespace
# all C files (implementation and header) use our style...
*.[ch] citus-style

View File

@ -58,3 +58,6 @@ installcheck: remove_cstore_files
remove_cstore_files:
rm -f data/*.cstore data/*.cstore.footer
reindent:
citus_indent .

View File

@ -43,6 +43,7 @@ ParseCompressionType(const char *compressionTypeString)
return compressionType;
}
/* CreateDirectory creates a new directory with the given directory name. */
static void
CreateDirectory(StringInfo directoryName)
@ -56,6 +57,7 @@ CreateDirectory(StringInfo directoryName)
}
}
/* DirectoryExists checks if a directory exists for the given directory name. */
static bool
DirectoryExists(StringInfo directoryName)
@ -91,6 +93,7 @@ DirectoryExists(StringInfo directoryName)
return directoryExists;
}
/*
* RemoveCStoreDatabaseDirectory removes CStore directory previously
* created for this database.
@ -132,8 +135,9 @@ InitializeCStoreTableFile(Oid relationId, Relation relation, CStoreOptions *csto
* empty data file and a valid footer file for the table.
*/
writeState = CStoreBeginWrite(relationId, cstoreOptions->filename,
cstoreOptions->compressionType, cstoreOptions->stripeRowCount,
cstoreOptions->blockRowCount, tupleDescriptor);
cstoreOptions->compressionType,
cstoreOptions->stripeRowCount,
cstoreOptions->blockRowCount, tupleDescriptor);
CStoreEndWrite(writeState);
}

View File

@ -60,7 +60,6 @@ typedef enum
COMPRESSION_PG_LZ = 1,
COMPRESSION_COUNT
} CompressionType;
@ -75,7 +74,6 @@ typedef struct CStoreOptions
CompressionType compressionType;
uint64 stripeRowCount;
uint32 blockRowCount;
} CStoreOptions;
@ -90,7 +88,6 @@ typedef struct StripeMetadata
uint64 dataLength;
uint64 footerLength;
uint64 id;
} StripeMetadata;
@ -99,7 +96,6 @@ typedef struct TableFooter
{
List *stripeMetadataList;
uint64 blockRowCount;
} TableFooter;
@ -123,7 +119,6 @@ typedef struct ColumnBlockSkipNode
uint64 existsLength;
CompressionType valueCompressionType;
} ColumnBlockSkipNode;
@ -137,7 +132,6 @@ typedef struct StripeSkipList
ColumnBlockSkipNode **blockSkipNodeArray;
uint32 columnCount;
uint32 blockCount;
} StripeSkipList;
@ -155,7 +149,6 @@ typedef struct ColumnBlockData
/* valueBuffer keeps actual data for type-by-reference datums from valueArray. */
StringInfo valueBuffer;
} ColumnBlockData;
@ -171,7 +164,6 @@ typedef struct ColumnBlockBuffers
StringInfo existsBuffer;
StringInfo valueBuffer;
CompressionType valueCompressionType;
} ColumnBlockBuffers;
@ -182,7 +174,6 @@ typedef struct ColumnBlockBuffers
typedef struct ColumnBuffers
{
ColumnBlockBuffers **blockBuffersArray;
} ColumnBuffers;
@ -192,7 +183,6 @@ typedef struct StripeBuffers
uint32 columnCount;
uint32 rowCount;
ColumnBuffers **columnBuffersArray;
} StripeBuffers;
@ -207,7 +197,6 @@ typedef struct StripeFooter
uint64 *skipListSizeArray;
uint64 *existsSizeArray;
uint64 *valueSizeArray;
} StripeFooter;
@ -234,7 +223,6 @@ typedef struct TableReadState
uint64 stripeReadRowCount;
ColumnBlockData **blockDataArray;
int32 deserializedBlockIndex;
} TableReadState;
@ -257,6 +245,7 @@ typedef struct TableWriteState
StripeSkipList *stripeSkipList;
uint32 stripeMaxRowCount;
ColumnBlockData **blockDataArray;
/*
* compressionBuffer buffer is used as temporary storage during
* data value compression operation. It is kept here to minimize
@ -264,7 +253,6 @@ typedef struct TableWriteState
* deallocated when memory context is reset.
*/
StringInfo compressionBuffer;
} TableWriteState;
extern CompressionType ParseCompressionType(const char *compressionTypeString);
@ -283,7 +271,7 @@ extern TableWriteState * CStoreBeginWrite(Oid relationId,
TupleDesc tupleDescriptor);
extern void CStoreWriteRow(TableWriteState *state, Datum *columnValues,
bool *columnNulls);
extern void CStoreEndWrite(TableWriteState * state);
extern void CStoreEndWrite(TableWriteState *state);
/* Function declarations for reading from a cstore file */
extern TableReadState * CStoreBeginRead(Oid relationId, const char *filename,

View File

@ -22,38 +22,39 @@
#include "cstore.h"
#if PG_VERSION_NUM >= 90500
/*
* The information at the start of the compressed data. This decription is taken
* from pg_lzcompress in pre-9.5 version of PostgreSQL.
*/
typedef struct CStoreCompressHeader
{
int32 vl_len_; /* varlena header (do not touch directly!) */
int32 rawsize;
int32 vl_len_; /* varlena header (do not touch directly!) */
int32 rawsize;
} CStoreCompressHeader;
/*
* Utilities for manipulation of header information for compressed data
*/
#define CSTORE_COMPRESS_HDRSZ ((int32) sizeof(CStoreCompressHeader))
#define CSTORE_COMPRESS_HDRSZ ((int32) sizeof(CStoreCompressHeader))
#define CSTORE_COMPRESS_RAWSIZE(ptr) (((CStoreCompressHeader *) (ptr))->rawsize)
#define CSTORE_COMPRESS_RAWDATA(ptr) (((char *) (ptr)) + CSTORE_COMPRESS_HDRSZ)
#define CSTORE_COMPRESS_SET_RAWSIZE(ptr, len) (((CStoreCompressHeader *) (ptr))->rawsize = (len))
#define CSTORE_COMPRESS_SET_RAWSIZE(ptr, len) (((CStoreCompressHeader *) (ptr))->rawsize = \
(len))
#else
#define CSTORE_COMPRESS_HDRSZ (0)
#define CSTORE_COMPRESS_HDRSZ (0)
#define CSTORE_COMPRESS_RAWSIZE(ptr) (PGLZ_RAW_SIZE((PGLZ_Header *) buffer->data))
#define CSTORE_COMPRESS_RAWDATA(ptr) (((PGLZ_Header *) (ptr)))
#define CSTORE_COMPRESS_SET_RAWSIZE(ptr, len) (((CStoreCompressHeader *) (ptr))->rawsize = (len))
#define CSTORE_COMPRESS_SET_RAWSIZE(ptr, len) (((CStoreCompressHeader *) (ptr))->rawsize = \
(len))
#endif
/*
* CompressBuffer compresses the given buffer with the given compression type
* outputBuffer enlarged to contain compressed data. The function returns true

View File

@ -85,7 +85,6 @@ typedef struct CStoreValidOption
{
const char *optionName;
Oid optionContextId;
} CStoreValidOption;
#define COMPRESSION_STRING_DELIMITED_LIST "none, pglz"
@ -114,13 +113,13 @@ static void CStoreProcessUtility(Node *parseTree, const char *queryString,
ParamListInfo paramListInfo,
DestReceiver *destReceiver, char *completionTag);
#endif
static bool CopyCStoreTableStatement(CopyStmt* copyStatement);
static void CheckSuperuserPrivilegesForCopy(const CopyStmt* copyStatement);
static bool CopyCStoreTableStatement(CopyStmt *copyStatement);
static void CheckSuperuserPrivilegesForCopy(const CopyStmt *copyStatement);
static void CStoreProcessCopyCommand(CopyStmt *copyStatement, const char *queryString,
char *completionTag);
static uint64 CopyIntoCStoreTable(const CopyStmt *copyStatement,
const char *queryString);
static uint64 CopyOutCStoreTable(CopyStmt* copyStatement, const char* queryString);
static uint64 CopyOutCStoreTable(CopyStmt *copyStatement, const char *queryString);
static void CStoreProcessAlterTableCommand(AlterTableStmt *alterStatement);
static List * DroppedCStoreFilenameList(DropStmt *dropStatement);
static List * FindCStoreTables(List *tableList);
@ -168,7 +167,7 @@ static int CStoreAcquireSampleRows(Relation relation, int logLevel,
HeapTuple *sampleRows, int targetRowCount,
double *totalRowCount, double *totalDeadRowCount);
static List * CStorePlanForeignModify(PlannerInfo *plannerInfo, ModifyTable *plan,
Index resultRelation, int subplanIndex);
Index resultRelation, int subplanIndex);
static void CStoreBeginForeignModify(ModifyTableState *modifyTableState,
ResultRelInfo *relationInfo, List *fdwPrivate,
int subplanIndex, int executorflags);
@ -201,7 +200,8 @@ static ProcessUtility_hook_type PreviousProcessUtilityHook = NULL;
* previous utility hook, and then install our hook to pre-intercept calls to
* the copy command.
*/
void cstore_fdw_init()
void
cstore_fdw_init()
{
PreviousProcessUtilityHook = ProcessUtility_hook;
ProcessUtility_hook = CStoreProcessUtility;
@ -212,7 +212,8 @@ void cstore_fdw_init()
* Called when the module is unloaded. This function uninstalls the
* extension's hooks.
*/
void cstore_fdw_finish()
void
cstore_fdw_finish()
{
ProcessUtility_hook = PreviousProcessUtilityHook;
}
@ -296,10 +297,10 @@ CStoreProcessUtility(PlannedStmt *plannedStatement, const char *queryString,
DestReceiver *destReceiver, char *completionTag)
#else
static void
CStoreProcessUtility(Node * parseTree, const char *queryString,
CStoreProcessUtility(Node * parseTree, const char * queryString,
ProcessUtilityContext context,
ParamListInfo paramListInfo,
DestReceiver *destReceiver, char *completionTag)
DestReceiver * destReceiver, char * completionTag)
#endif
{
#if PG_VERSION_NUM >= 100000
@ -387,11 +388,12 @@ CStoreProcessUtility(Node * parseTree, const char *queryString,
CALL_PREVIOUS_UTILITY(parseTree, queryString, context, paramListInfo,
destReceiver, completionTag);
/* restore the former relation list. Our
* replacement could be freed but still needed
* in a cached plan. A truncate can be cached
* if run from a pl/pgSQL function */
truncateStatement->relations = allTablesList;
/* restore the former relation list. Our
* replacement could be freed but still needed
* in a cached plan. A truncate can be cached
* if run from a pl/pgSQL function */
truncateStatement->relations = allTablesList;
}
TruncateCStoreTables(cstoreRelationList);
@ -439,7 +441,7 @@ CStoreProcessUtility(Node * parseTree, const char *queryString,
* true. The function returns false otherwise.
*/
static bool
CopyCStoreTableStatement(CopyStmt* copyStatement)
CopyCStoreTableStatement(CopyStmt *copyStatement)
{
bool copyCStoreTableStatement = false;
@ -474,7 +476,7 @@ CopyCStoreTableStatement(CopyStmt* copyStatement)
* copy operation and reports error if user does not have superuser rights.
*/
static void
CheckSuperuserPrivilegesForCopy(const CopyStmt* copyStatement)
CheckSuperuserPrivilegesForCopy(const CopyStmt *copyStatement)
{
/*
* We disallow copy from file or program except to superusers. These checks
@ -485,16 +487,16 @@ CheckSuperuserPrivilegesForCopy(const CopyStmt* copyStatement)
if (copyStatement->is_program)
{
ereport(ERROR, (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
errmsg("must be superuser to COPY to or from a program"),
errhint("Anyone can COPY to stdout or from stdin. "
"psql's \\copy command also works for anyone.")));
errmsg("must be superuser to COPY to or from a program"),
errhint("Anyone can COPY to stdout or from stdin. "
"psql's \\copy command also works for anyone.")));
}
else
{
ereport(ERROR, (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
errmsg("must be superuser to COPY to or from a file"),
errhint("Anyone can COPY to stdout or from stdin. "
"psql's \\copy command also works for anyone.")));
errmsg("must be superuser to COPY to or from a file"),
errhint("Anyone can COPY to stdout or from stdin. "
"psql's \\copy command also works for anyone.")));
}
}
}
@ -505,7 +507,7 @@ CheckSuperuserPrivilegesForCopy(const CopyStmt* copyStatement)
* It determines the copy direction and forwards execution to appropriate function.
*/
static void
CStoreProcessCopyCommand(CopyStmt *copyStatement, const char* queryString,
CStoreProcessCopyCommand(CopyStmt *copyStatement, const char *queryString,
char *completionTag)
{
uint64 processedCount = 0;
@ -648,7 +650,7 @@ CopyIntoCStoreTable(const CopyStmt *copyStatement, const char *queryString)
* stream. Copying selected columns from cstore table is not currently supported.
*/
static uint64
CopyOutCStoreTable(CopyStmt* copyStatement, const char* queryString)
CopyOutCStoreTable(CopyStmt *copyStatement, const char *queryString)
{
uint64 processedCount = 0;
RangeVar *relation = NULL;
@ -682,6 +684,7 @@ CopyOutCStoreTable(CopyStmt* copyStatement, const char* queryString)
copyStatement->relation = NULL;
#if (PG_VERSION_NUM >= 100000)
/*
* raw_parser returns list of RawStmt* in PG 10+ we need to
* extract actual query from it.
@ -737,7 +740,7 @@ CStoreProcessAlterTableCommand(AlterTableStmt *alterStatement)
foreach(commandCell, commandList)
{
AlterTableCmd *alterCommand = (AlterTableCmd *) lfirst(commandCell);
if(alterCommand->subtype == AT_AlterColumnType)
if (alterCommand->subtype == AT_AlterColumnType)
{
char *columnName = alterCommand->name;
ColumnDef *columnDef = (ColumnDef *) alterCommand->def;
@ -849,7 +852,7 @@ OpenRelationsForTruncate(List *cstoreTableList)
Relation relation = heap_openrv(rangeVar, AccessExclusiveLock);
Oid relationId = relation->rd_id;
AclResult aclresult = pg_class_aclcheck(relationId, GetUserId(),
ACL_TRUNCATE);
ACL_TRUNCATE);
if (aclresult != ACLCHECK_OK)
{
aclcheck_error(aclresult, ACLCHECK_OBJECT_TABLE, get_rel_name(relationId));
@ -890,6 +893,7 @@ TruncateCStoreTables(List *cstoreRelationList)
}
}
/*
* CStoreTable checks if the given table name belongs to a foreign columnar store
* table. If it does, the function returns true. Otherwise, it returns false.
@ -996,23 +1000,20 @@ DistributedTable(Oid relationId)
static bool
DistributedWorkerCopy(CopyStmt *copyStatement)
{
ListCell *optionCell = NULL;
foreach(optionCell, copyStatement->options)
{
DefElem *defel = (DefElem *) lfirst(optionCell);
if (strncmp(defel->defname, "master_host", NAMEDATALEN) == 0)
{
return true;
}
}
ListCell *optionCell = NULL;
foreach(optionCell, copyStatement->options)
{
DefElem *defel = (DefElem *) lfirst(optionCell);
if (strncmp(defel->defname, "master_host", NAMEDATALEN) == 0)
{
return true;
}
}
return false;
return false;
}
/*
* cstore_table_size returns the total on-disk size of a cstore table in bytes.
* The result includes the sizes of data file and footer file.
@ -1056,7 +1057,7 @@ cstore_table_size(PG_FUNCTION_ARGS)
{
ereport(ERROR, (errcode_for_file_access(),
errmsg("could not stat file \"%s\": %m",
footerFilename->data)));
footerFilename->data)));
}
tableSize += dataFileStatBuffer.st_size;
@ -1428,7 +1429,6 @@ CStoreDefaultFilePath(Oid foreignTableId)
{
databaseOid = MyDatabaseId;
relationFileOid = foreignTableId;
}
cstoreFilePath = makeStringInfo();
@ -1447,7 +1447,8 @@ static void
CStoreGetForeignRelSize(PlannerInfo *root, RelOptInfo *baserel, Oid foreignTableId)
{
CStoreOptions *cstoreOptions = CStoreGetOptions(foreignTableId);
double tupleCountEstimate = TupleCountEstimate(foreignTableId, baserel, cstoreOptions->filename);
double tupleCountEstimate = TupleCountEstimate(foreignTableId, baserel,
cstoreOptions->filename);
double rowSelectivity = clauselist_selectivity(root, baserel->baserestrictinfo,
0, JOIN_INNER, NULL);
@ -1494,7 +1495,8 @@ CStoreGetForeignPaths(PlannerInfo *root, RelOptInfo *baserel, Oid foreignTableId
double queryPageCount = relationPageCount * queryColumnRatio;
double totalDiskAccessCost = seq_page_cost * queryPageCount;
double tupleCountEstimate = TupleCountEstimate(foreignTableId, baserel, cstoreOptions->filename);
double tupleCountEstimate = TupleCountEstimate(foreignTableId, baserel,
cstoreOptions->filename);
/*
* We estimate costs almost the same way as cost_seqscan(), thus assuming
@ -1505,7 +1507,7 @@ CStoreGetForeignPaths(PlannerInfo *root, RelOptInfo *baserel, Oid foreignTableId
double totalCpuCost = cpuCostPerTuple * tupleCountEstimate;
double startupCost = baserel->baserestrictcost.startup;
double totalCost = startupCost + totalCpuCost + totalDiskAccessCost;
double totalCost = startupCost + totalCpuCost + totalDiskAccessCost;
/* create a foreign path node and add it as the only possible path */
#if PG_VERSION_NUM >= 90600
@ -1550,8 +1552,8 @@ CStoreGetForeignPlan(PlannerInfo *root, RelOptInfo *baserel, Oid foreignTableId,
Plan *outerPlan)
#else
static ForeignScan *
CStoreGetForeignPlan(PlannerInfo *root, RelOptInfo *baserel, Oid foreignTableId,
ForeignPath *bestPath, List *targetList, List *scanClauses)
CStoreGetForeignPlan(PlannerInfo * root, RelOptInfo * baserel, Oid foreignTableId,
ForeignPath * bestPath, List * targetList, List * scanClauses)
#endif
{
ForeignScan *foreignScan = NULL;
@ -1720,7 +1722,7 @@ ColumnList(RelOptInfo *baserel, Oid foreignTableId)
{
ListCell *neededColumnCell = NULL;
Var *column = NULL;
Form_pg_attribute attributeForm = TupleDescAttr(tupleDescriptor, columnIndex - 1);
Form_pg_attribute attributeForm = TupleDescAttr(tupleDescriptor, columnIndex - 1);
if (attributeForm->attisdropped)
{
@ -1920,7 +1922,7 @@ CStoreAcquireSampleRows(Relation relation, int logLevel,
{
int sampleRowCount = 0;
double rowCount = 0.0;
double rowCountToSkip = -1; /* -1 means not set yet */
double rowCountToSkip = -1; /* -1 means not set yet */
double selectionState = 0;
MemoryContext oldContext = CurrentMemoryContext;
MemoryContext tupleContext = NULL;
@ -1948,7 +1950,8 @@ CStoreAcquireSampleRows(Relation relation, int logLevel,
if (!attributeForm->attisdropped)
{
Var *column = makeVar(tableId, columnIndex + 1, attributeForm->atttypid,
attributeForm->atttypmod, attributeForm->attcollation, 0);
attributeForm->atttypmod, attributeForm->attcollation,
0);
columnList = lappend(columnList, column);
}
}
@ -2139,7 +2142,7 @@ CStoreBeginForeignModify(ModifyTableState *modifyTableState,
return;
}
Assert (modifyTableState->operation == CMD_INSERT);
Assert(modifyTableState->operation == CMD_INSERT);
CStoreBeginForeignInsert(modifyTableState, relationInfo);
}
@ -2152,7 +2155,7 @@ CStoreBeginForeignModify(ModifyTableState *modifyTableState,
static void
CStoreBeginForeignInsert(ModifyTableState *modifyTableState, ResultRelInfo *relationInfo)
{
Oid foreignTableOid = InvalidOid;
Oid foreignTableOid = InvalidOid;
CStoreOptions *cstoreOptions = NULL;
TupleDesc tupleDescriptor = NULL;
TableWriteState *writeState = NULL;
@ -2183,7 +2186,7 @@ static TupleTableSlot *
CStoreExecForeignInsert(EState *executorState, ResultRelInfo *relationInfo,
TupleTableSlot *tupleSlot, TupleTableSlot *planSlot)
{
TableWriteState *writeState = (TableWriteState*) relationInfo->ri_FdwState;
TableWriteState *writeState = (TableWriteState *) relationInfo->ri_FdwState;
HeapTuple heapTuple;
Assert(writeState != NULL);
@ -2224,7 +2227,7 @@ CStoreEndForeignModify(EState *executorState, ResultRelInfo *relationInfo)
static void
CStoreEndForeignInsert(EState *executorState, ResultRelInfo *relationInfo)
{
TableWriteState *writeState = (TableWriteState*) relationInfo->ri_FdwState;
TableWriteState *writeState = (TableWriteState *) relationInfo->ri_FdwState;
/* writeState is NULL during Explain queries */
if (writeState != NULL)
@ -2238,6 +2241,7 @@ CStoreEndForeignInsert(EState *executorState, ResultRelInfo *relationInfo)
#if PG_VERSION_NUM >= 90600
/*
* CStoreIsForeignScanParallelSafe always returns true to indicate that
* reading from a cstore_fdw table in a parallel worker is safe. This
@ -2254,4 +2258,6 @@ CStoreIsForeignScanParallelSafe(PlannerInfo *root, RelOptInfo *rel,
{
return true;
}
#endif

View File

@ -32,4 +32,4 @@ extern Datum cstore_clean_table_resources(PG_FUNCTION_ARGS);
extern Datum cstore_fdw_handler(PG_FUNCTION_ARGS);
extern Datum cstore_fdw_validator(PG_FUNCTION_ARGS);
#endif /* CSTORE_FDW_H */
#endif /* CSTORE_FDW_H */

View File

@ -143,8 +143,8 @@ SerializeColumnSkipList(ColumnBlockSkipNode *blockSkipNodeArray, uint32 blockCou
{
ColumnBlockSkipNode blockSkipNode = blockSkipNodeArray[blockIndex];
Protobuf__ColumnBlockSkipNode *protobufBlockSkipNode = NULL;
ProtobufCBinaryData binaryMinimumValue = {0, 0};
ProtobufCBinaryData binaryMaximumValue = {0, 0};
ProtobufCBinaryData binaryMinimumValue = { 0, 0 };
ProtobufCBinaryData binaryMaximumValue = { 0, 0 };
if (blockSkipNode.hasMinMax)
{
@ -352,7 +352,7 @@ DeserializeRowCount(StringInfo buffer)
for (blockIndex = 0; blockIndex < blockCount; blockIndex++)
{
Protobuf__ColumnBlockSkipNode *protobufBlockSkipNode =
protobufBlockSkipList->blockskipnodearray[blockIndex];
protobufBlockSkipList->blockskipnodearray[blockIndex];
rowCount += protobufBlockSkipNode->rowcount;
}
@ -452,7 +452,7 @@ DeserializeColumnSkipList(StringInfo buffer, bool typeByValue, int typeLength,
static ProtobufCBinaryData
DatumToProtobufBinary(Datum datum, bool datumTypeByValue, int datumTypeLength)
{
ProtobufCBinaryData protobufBinary = {0, 0};
ProtobufCBinaryData protobufBinary = { 0, 0 };
int datumLength = att_addlength_datum(0, datumTypeLength, datum);
char *datumBuffer = palloc0(datumLength);

View File

@ -31,4 +31,4 @@ extern ColumnBlockSkipNode * DeserializeColumnSkipList(StringInfo buffer,
uint32 blockCount);
#endif /* CSTORE_SERIALIZATION_H */
#endif /* CSTORE_SERIALIZATION_H */

View File

@ -67,7 +67,7 @@ static OpExpr * MakeOpExpression(Var *variable, int16 strategyNumber);
static Oid GetOperatorByType(Oid typeId, Oid accessMethodId, int16 strategyNumber);
static void UpdateConstraint(Node *baseConstraint, Datum minValue, Datum maxValue);
static StripeSkipList * SelectedBlockSkipList(StripeSkipList *stripeSkipList,
bool *projectedColumnMask,
bool *projectedColumnMask,
bool *selectedBlockMask);
static uint32 StripeSkipListRowCount(StripeSkipList *stripeSkipList);
static bool * ProjectedColumnMask(uint32 columnCount, List *projectedColumnList);
@ -104,7 +104,7 @@ CStoreBeginRead(Oid relationId, const char *filename, TupleDesc tupleDescriptor,
MemoryContext stripeReadContext = NULL;
uint32 columnCount = 0;
bool *projectedColumnMask = NULL;
ColumnBlockData **blockDataArray = NULL;
ColumnBlockData **blockDataArray = NULL;
StringInfo tableFooterFilename = makeStringInfo();
appendStringInfo(tableFooterFilename, "%s%s", filename, CSTORE_FOOTER_FILE_SUFFIX);
@ -134,7 +134,7 @@ CStoreBeginRead(Oid relationId, const char *filename, TupleDesc tupleDescriptor,
columnCount = tupleDescriptor->natts;
projectedColumnMask = ProjectedColumnMask(columnCount, projectedColumnList);
blockDataArray = CreateEmptyBlockDataArray(columnCount, projectedColumnMask,
tableFooter->blockRowCount);
tableFooter->blockRowCount);
readState = palloc0(sizeof(TableReadState));
readState->relationId = relationId;
@ -356,7 +356,7 @@ ColumnBlockData **
CreateEmptyBlockDataArray(uint32 columnCount, bool *columnMask, uint32 blockRowCount)
{
uint32 columnIndex = 0;
ColumnBlockData **blockDataArray = palloc0(columnCount * sizeof(ColumnBlockData*));
ColumnBlockData **blockDataArray = palloc0(columnCount * sizeof(ColumnBlockData *));
/* allocate block memory for deserialized data */
for (columnIndex = 0; columnIndex < columnCount; columnIndex++)
@ -448,12 +448,12 @@ StripeRowCount(Oid relid, FILE *tableFile, StripeMetadata *stripeMetadata)
uint64 rowCount = 0;
StringInfo firstColumnSkipListBuffer = NULL;
StripeFooter * stripeFooter = ReadStripeFooter(relid, stripeMetadata->id,
RelationColumnCount(relid));
StripeFooter *stripeFooter = ReadStripeFooter(relid, stripeMetadata->id,
RelationColumnCount(relid));
firstColumnSkipListBuffer = ReadFromFile(tableFile, stripeMetadata->fileOffset,
stripeFooter->skipListSizeArray[0]);
rowCount = DeserializeRowCount(firstColumnSkipListBuffer);
stripeFooter->skipListSizeArray[0]);
rowCount = DeserializeRowCount(firstColumnSkipListBuffer);
return rowCount;
}
@ -573,7 +573,7 @@ LoadColumnBuffers(FILE *tableFile, ColumnBlockSkipNode *blockSkipNodeArray,
ColumnBuffers *columnBuffers = NULL;
uint32 blockIndex = 0;
ColumnBlockBuffers **blockBuffersArray =
palloc0(blockCount * sizeof(ColumnBlockBuffers *));
palloc0(blockCount * sizeof(ColumnBlockBuffers *));
for (blockIndex = 0; blockIndex < blockCount; blockIndex++)
{
@ -761,7 +761,8 @@ SelectedBlockMask(StripeSkipList *stripeSkipList, List *projectedColumnList,
constraintList = list_make1(baseConstraint);
#if (PG_VERSION_NUM >= 100000)
predicateRefuted = predicate_refuted_by(constraintList, restrictInfoList, false);
predicateRefuted = predicate_refuted_by(constraintList, restrictInfoList,
false);
#else
predicateRefuted = predicate_refuted_by(constraintList, restrictInfoList);
#endif
@ -877,7 +878,7 @@ MakeOpExpression(Var *variable, int16 strategyNumber)
Oid accessMethodId = BTREE_AM_OID;
Oid operatorId = InvalidOid;
Const *constantValue = NULL;
Const *constantValue = NULL;
OpExpr *expression = NULL;
/* Load the operator from system catalogs */
@ -888,7 +889,7 @@ MakeOpExpression(Var *variable, int16 strategyNumber)
/* Now make the expression with the given variable and a null constant */
expression = (OpExpr *) make_opclause(operatorId,
InvalidOid, /* no result type yet */
false, /* no return set */
false, /* no return set */
(Expr *) variable,
(Expr *) constantValue,
InvalidOid, collationId);
@ -1163,7 +1164,8 @@ DeserializeBlockData(StripeBuffers *stripeBuffers, uint64 blockIndex,
if (columnBuffers != NULL)
{
ColumnBlockBuffers *blockBuffers = columnBuffers->blockBuffersArray[blockIndex];
ColumnBlockBuffers *blockBuffers =
columnBuffers->blockBuffersArray[blockIndex];
StringInfo valueBuffer = NULL;
/* free previous block's data buffers */
@ -1214,7 +1216,6 @@ DeserializeBlockData(StripeBuffers *stripeBuffers, uint64 blockIndex,
{
memset(blockData->existsArray, false, rowCount);
}
}
}
}
@ -1330,8 +1331,6 @@ ReadFromFile(FILE *file, uint64 offset, uint32 size)
}
/*
* ResetUncompressedBlockData iterates over deserialized column block data
* and sets valueBuffer field to empty buffer. This field is allocated in stripe

View File

@ -22,7 +22,8 @@
#endif
#if PG_VERSION_NUM < 110000
#define ALLOCSET_DEFAULT_SIZES ALLOCSET_DEFAULT_MINSIZE, ALLOCSET_DEFAULT_INITSIZE, ALLOCSET_DEFAULT_MAXSIZE
#define ALLOCSET_DEFAULT_SIZES ALLOCSET_DEFAULT_MINSIZE, ALLOCSET_DEFAULT_INITSIZE, \
ALLOCSET_DEFAULT_MAXSIZE
#define ACLCHECK_OBJECT_TABLE ACL_KIND_CLASS
#else
#define ACLCHECK_OBJECT_TABLE OBJECT_TABLE
@ -46,9 +47,9 @@
#endif
#if PG_VERSION_NUM < 120000
#define TTS_EMPTY(slot) ((slot)->tts_isempty)
#define TTS_EMPTY(slot) ((slot)->tts_isempty)
#define ExecForceStoreHeapTuple(tuple, slot, shouldFree) \
ExecStoreTuple(newTuple, tupleSlot, InvalidBuffer, shouldFree);
ExecStoreTuple(newTuple, tupleSlot, InvalidBuffer, shouldFree);
#define TableScanDesc HeapScanDesc
#define table_beginscan heap_beginscan
#define table_endscan heap_endscan

View File

@ -149,13 +149,15 @@ CStoreBeginWrite(Oid relationId,
for (columnIndex = 0; columnIndex < columnCount; columnIndex++)
{
FmgrInfo *comparisonFunction = NULL;
FormData_pg_attribute *attributeForm = TupleDescAttr(tupleDescriptor, columnIndex);
FormData_pg_attribute *attributeForm = TupleDescAttr(tupleDescriptor,
columnIndex);
if (!attributeForm->attisdropped)
{
Oid typeId = attributeForm->atttypid;
comparisonFunction = GetFunctionInfoOrNull(typeId, BTREE_AM_OID, BTORDER_PROC);
comparisonFunction = GetFunctionInfoOrNull(typeId, BTREE_AM_OID,
BTORDER_PROC);
}
comparisonFunctionArray[columnIndex] = comparisonFunction;
@ -262,7 +264,7 @@ CStoreWriteRow(TableWriteState *writeState, Datum *columnValues, bool *columnNul
bool columnTypeByValue = attributeForm->attbyval;
int columnTypeLength = attributeForm->attlen;
Oid columnCollation = attributeForm->attcollation;
char columnTypeAlign = attributeForm->attalign;
char columnTypeAlign = attributeForm->attalign;
blockData->existsArray[blockRowIndex] = true;
@ -492,7 +494,7 @@ CreateEmptyStripeSkipList(uint32 stripeMaxRowCount, uint32 blockRowCount,
static StripeMetadata
FlushStripe(TableWriteState *writeState)
{
StripeMetadata stripeMetadata = {0, 0, 0, 0};
StripeMetadata stripeMetadata = { 0, 0, 0, 0 };
uint64 skipListLength = 0;
uint64 dataLength = 0;
StringInfo *skipListBufferArray = NULL;
@ -531,7 +533,7 @@ FlushStripe(TableWriteState *writeState)
for (blockIndex = 0; blockIndex < blockCount; blockIndex++)
{
ColumnBlockBuffers *blockBuffers =
columnBuffers->blockBuffersArray[blockIndex];
columnBuffers->blockBuffersArray[blockIndex];
uint64 existsBufferSize = blockBuffers->existsBuffer->len;
uint64 valueBufferSize = blockBuffers->valueBuffer->len;
CompressionType valueCompressionType = blockBuffers->valueCompressionType;
@ -582,7 +584,7 @@ FlushStripe(TableWriteState *writeState)
for (blockIndex = 0; blockIndex < stripeSkipList->blockCount; blockIndex++)
{
ColumnBlockBuffers *blockBuffers =
columnBuffers->blockBuffersArray[blockIndex];
columnBuffers->blockBuffersArray[blockIndex];
StringInfo existsBuffer = blockBuffers->existsBuffer;
WriteToFile(tableFile, existsBuffer->data, existsBuffer->len);
@ -591,7 +593,7 @@ FlushStripe(TableWriteState *writeState)
for (blockIndex = 0; blockIndex < stripeSkipList->blockCount; blockIndex++)
{
ColumnBlockBuffers *blockBuffers =
columnBuffers->blockBuffersArray[blockIndex];
columnBuffers->blockBuffersArray[blockIndex];
StringInfo valueBuffer = blockBuffers->valueBuffer;
WriteToFile(tableFile, valueBuffer->data, valueBuffer->len);

7
mod.c
View File

@ -20,14 +20,15 @@
PG_MODULE_MAGIC;
void _PG_init(void)
void
_PG_init(void)
{
cstore_fdw_init();
}
void _PG_fini(void)
void
_PG_fini(void)
{
cstore_fdw_finish();
}