fix indentation via citus_indent

merge-cstore-pykello
Nils Dijk 2020-09-16 15:21:57 +02:00
parent 20a8bca426
commit 1e93e15a8d
6 changed files with 62 additions and 32 deletions

View File

@ -204,6 +204,7 @@ typedef struct TableReadState
TableMetadata *tableMetadata; TableMetadata *tableMetadata;
TupleDesc tupleDescriptor; TupleDesc tupleDescriptor;
Relation relation; Relation relation;
/* /*
* List of Var pointers for columns in the query. We use this both for * List of Var pointers for columns in the query. We use this both for
* getting vector of projected columns, and also when we want to build * getting vector of projected columns, and also when we want to build
@ -320,4 +321,5 @@ logical_to_smgr(uint64 logicalOffset)
return addr; return addr;
} }
#endif /* CSTORE_H */ #endif /* CSTORE_H */

View File

@ -833,6 +833,7 @@ TruncateCStoreTables(List *cstoreRelationList)
} }
} }
/* /*
* Version 11 and earlier already assign a relfilenode for foreign * Version 11 and earlier already assign a relfilenode for foreign
* tables. Version 12 and later do not, so we need to create one manually. * tables. Version 12 and later do not, so we need to create one manually.
@ -849,8 +850,10 @@ FdwNewRelFileNode(Relation relation)
tuple = SearchSysCacheCopy1(RELOID, tuple = SearchSysCacheCopy1(RELOID,
ObjectIdGetDatum(RelationGetRelid(relation))); ObjectIdGetDatum(RelationGetRelid(relation)));
if (!HeapTupleIsValid(tuple)) if (!HeapTupleIsValid(tuple))
{
elog(ERROR, "could not find tuple for relation %u", elog(ERROR, "could not find tuple for relation %u",
RelationGetRelid(relation)); RelationGetRelid(relation));
}
classform = (Form_pg_class) GETSTRUCT(tuple); classform = (Form_pg_class) GETSTRUCT(tuple);
if (true) if (true)
@ -870,12 +873,18 @@ FdwNewRelFileNode(Relation relation)
heap_close(tmprel, NoLock); heap_close(tmprel, NoLock);
if (OidIsValid(relation->rd_rel->relfilenode)) if (OidIsValid(relation->rd_rel->relfilenode))
{
RelationDropStorage(relation); RelationDropStorage(relation);
}
if (OidIsValid(relation->rd_rel->reltablespace)) if (OidIsValid(relation->rd_rel->reltablespace))
{
tablespace = relation->rd_rel->reltablespace; tablespace = relation->rd_rel->reltablespace;
}
else else
{
tablespace = MyDatabaseTableSpace; tablespace = MyDatabaseTableSpace;
}
filenode = GetNewRelFileNode(tablespace, NULL, persistence); filenode = GetNewRelFileNode(tablespace, NULL, persistence);
@ -898,6 +907,7 @@ FdwNewRelFileNode(Relation relation)
heap_close(pg_class, RowExclusiveLock); heap_close(pg_class, RowExclusiveLock);
} }
static void static void
FdwCreateStorage(Relation relation) FdwCreateStorage(Relation relation)
{ {
@ -2187,16 +2197,22 @@ cstore_fdw_initrel(Relation rel)
{ {
#if PG_VERSION_NUM >= 120000 #if PG_VERSION_NUM >= 120000
if (rel->rd_rel->relfilenode == InvalidOid) if (rel->rd_rel->relfilenode == InvalidOid)
{
FdwNewRelFileNode(rel); FdwNewRelFileNode(rel);
}
/* /*
* Copied code from RelationInitPhysicalAddr(), which doesn't * Copied code from RelationInitPhysicalAddr(), which doesn't
* work on foreign tables. * work on foreign tables.
*/ */
if (OidIsValid(rel->rd_rel->reltablespace)) if (OidIsValid(rel->rd_rel->reltablespace))
{
rel->rd_node.spcNode = rel->rd_rel->reltablespace; rel->rd_node.spcNode = rel->rd_rel->reltablespace;
}
else else
{
rel->rd_node.spcNode = MyDatabaseTableSpace; rel->rd_node.spcNode = MyDatabaseTableSpace;
}
rel->rd_node.dbNode = MyDatabaseId; rel->rd_node.dbNode = MyDatabaseId;
rel->rd_node.relNode = rel->rd_rel->relfilenode; rel->rd_node.relNode = rel->rd_rel->relfilenode;
@ -2204,6 +2220,7 @@ cstore_fdw_initrel(Relation rel)
FdwCreateStorage(rel); FdwCreateStorage(rel);
} }
static Relation static Relation
cstore_fdw_open(Oid relationId, LOCKMODE lockmode) cstore_fdw_open(Oid relationId, LOCKMODE lockmode)
{ {
@ -2214,6 +2231,7 @@ cstore_fdw_open(Oid relationId, LOCKMODE lockmode)
return rel; return rel;
} }
static Relation static Relation
cstore_fdw_openrv(RangeVar *relation, LOCKMODE lockmode) cstore_fdw_openrv(RangeVar *relation, LOCKMODE lockmode)
{ {

View File

@ -692,9 +692,12 @@ create_estate_for_relation(Relation rel)
estate->es_output_cid = GetCurrentCommandId(true); estate->es_output_cid = GetCurrentCommandId(true);
#if PG_VERSION_NUM < 120000 #if PG_VERSION_NUM < 120000
/* Triggers might need a slot */ /* Triggers might need a slot */
if (resultRelInfo->ri_TrigDesc) if (resultRelInfo->ri_TrigDesc)
{
estate->es_trig_tuple_slot = ExecInitExtraTupleSlot(estate, NULL); estate->es_trig_tuple_slot = ExecInitExtraTupleSlot(estate, NULL);
}
#endif #endif
/* Prepare to catch AFTER triggers. */ /* Prepare to catch AFTER triggers. */

View File

@ -1037,6 +1037,7 @@ ColumnDefaultValue(TupleConstr *tupleConstraints, Form_pg_attribute attributeFor
return defaultValue; return defaultValue;
} }
static StringInfo static StringInfo
ReadFromSmgr(Relation rel, uint64 offset, uint32 size) ReadFromSmgr(Relation rel, uint64 offset, uint32 size)
{ {
@ -1056,7 +1057,7 @@ ReadFromSmgr(Relation rel, uint64 offset, uint32 size)
buffer = ReadBuffer(rel, addr.blockno); buffer = ReadBuffer(rel, addr.blockno);
page = BufferGetPage(buffer); page = BufferGetPage(buffer);
phdr = (PageHeader)page; phdr = (PageHeader) page;
to_read = Min(size - read, phdr->pd_upper - addr.offset); to_read = Min(size - read, phdr->pd_upper - addr.offset);
memcpy(resultBuffer->data + read, page + addr.offset, to_read); memcpy(resultBuffer->data + read, page + addr.offset, to_read);
@ -1067,6 +1068,7 @@ ReadFromSmgr(Relation rel, uint64 offset, uint32 size)
return resultBuffer; return resultBuffer;
} }
/* /*
* ResetUncompressedBlockData iterates over deserialized column block data * ResetUncompressedBlockData iterates over deserialized column block data
* and sets valueBuffer field to empty buffer. This field is allocated in stripe * and sets valueBuffer field to empty buffer. This field is allocated in stripe

View File

@ -363,6 +363,7 @@ CreateEmptyStripeSkipList(uint32 stripeMaxRowCount, uint32 blockRowCount,
return stripeSkipList; return stripeSkipList;
} }
static void static void
WriteToSmgr(TableWriteState *writeState, char *data, uint32 dataLength) WriteToSmgr(TableWriteState *writeState, char *data, uint32 dataLength)
{ {
@ -397,7 +398,9 @@ WriteToSmgr(TableWriteState *writeState, char *data, uint32 dataLength)
page = BufferGetPage(buffer); page = BufferGetPage(buffer);
phdr = (PageHeader) page; phdr = (PageHeader) page;
if (PageIsNew(page)) if (PageIsNew(page))
{
PageInit(page, BLCKSZ, 0); PageInit(page, BLCKSZ, 0);
}
/* always appending */ /* always appending */
Assert(phdr->pd_lower == addr.offset); Assert(phdr->pd_lower == addr.offset);
@ -434,6 +437,7 @@ WriteToSmgr(TableWriteState *writeState, char *data, uint32 dataLength)
} }
} }
/* /*
* FlushStripe flushes current stripe data into the file. The function first ensures * FlushStripe flushes current stripe data into the file. The function first ensures
* the last data block for each column is properly serialized and compressed. Then, * the last data block for each column is properly serialized and compressed. Then,
@ -832,6 +836,7 @@ AppendStripeMetadata(TableMetadata *tableMetadata, StripeMetadata stripeMetadata
stripeMetadataCopy); stripeMetadataCopy);
} }
/* /*
* CopyStringInfo creates a deep copy of given source string allocating only needed * CopyStringInfo creates a deep copy of given source string allocating only needed
* amount of memory. * amount of memory.