mirror of https://github.com/citusdata/citus.git
header file and include cleanup
parent
59d5d96170
commit
3089c92103
38
cstore.c
38
cstore.c
|
@ -13,12 +13,14 @@
|
|||
|
||||
#include "postgres.h"
|
||||
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "miscadmin.h"
|
||||
#include "utils/rel.h"
|
||||
|
||||
#include "cstore.h"
|
||||
|
||||
#include <sys/stat.h>
|
||||
|
||||
static void CreateDirectory(StringInfo directoryName);
|
||||
static bool DirectoryExists(StringInfo directoryName);
|
||||
|
||||
|
@ -168,3 +170,35 @@ CreateCStoreDatabaseDirectory(Oid databaseOid)
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* DeleteCStoreTableFiles deletes the data and footer files for a cstore table
|
||||
* whose data filename is given.
|
||||
*/
|
||||
void
|
||||
DeleteCStoreTableFiles(char *filename)
|
||||
{
|
||||
int dataFileRemoved = 0;
|
||||
int footerFileRemoved = 0;
|
||||
|
||||
StringInfo tableFooterFilename = makeStringInfo();
|
||||
appendStringInfo(tableFooterFilename, "%s%s", filename, CSTORE_FOOTER_FILE_SUFFIX);
|
||||
|
||||
/* delete the footer file */
|
||||
footerFileRemoved = unlink(tableFooterFilename->data);
|
||||
if (footerFileRemoved != 0)
|
||||
{
|
||||
ereport(WARNING, (errcode_for_file_access(),
|
||||
errmsg("could not delete file \"%s\": %m",
|
||||
tableFooterFilename->data)));
|
||||
}
|
||||
|
||||
/* delete the data file */
|
||||
dataFileRemoved = unlink(filename);
|
||||
if (dataFileRemoved != 0)
|
||||
{
|
||||
ereport(WARNING, (errcode_for_file_access(),
|
||||
errmsg("could not delete file \"%s\": %m",
|
||||
filename)));
|
||||
}
|
||||
}
|
||||
|
|
7
cstore.h
7
cstore.h
|
@ -14,13 +14,9 @@
|
|||
#ifndef CSTORE_H
|
||||
#define CSTORE_H
|
||||
|
||||
#include "access/tupdesc.h"
|
||||
#include "fmgr.h"
|
||||
#include "catalog/pg_am.h"
|
||||
#include "catalog/pg_foreign_server.h"
|
||||
#include "catalog/pg_foreign_table.h"
|
||||
#include "lib/stringinfo.h"
|
||||
#include "utils/rel.h"
|
||||
#include "utils/relcache.h"
|
||||
|
||||
/* Defines for valid option names */
|
||||
#define OPTION_NAME_FILENAME "filename"
|
||||
|
@ -271,6 +267,7 @@ extern void InitializeCStoreTableFile(Oid relationId, Relation relation,
|
|||
CStoreOptions *cstoreOptions);
|
||||
extern void CreateCStoreDatabaseDirectory(Oid databaseOid);
|
||||
extern void RemoveCStoreDatabaseDirectory(Oid databaseOid);
|
||||
extern void DeleteCStoreTableFiles(char *filename);
|
||||
|
||||
/* Function declarations for writing to a cstore file */
|
||||
extern TableWriteState * CStoreBeginWrite(const char *filename,
|
||||
|
|
|
@ -12,7 +12,6 @@
|
|||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
#include "postgres.h"
|
||||
#include "cstore_fdw.h"
|
||||
|
||||
#if PG_VERSION_NUM >= 90500
|
||||
#include "common/pg_lzcompress.h"
|
||||
|
@ -20,6 +19,7 @@
|
|||
#include "utils/pg_lzcompress.h"
|
||||
#endif
|
||||
|
||||
#include "cstore.h"
|
||||
|
||||
|
||||
|
||||
|
|
92
cstore_fdw.c
92
cstore_fdw.c
|
@ -15,15 +15,11 @@
|
|||
*/
|
||||
|
||||
#include "postgres.h"
|
||||
#include "cstore_fdw.h"
|
||||
#include "cstore_version_compat.h"
|
||||
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
#include <limits.h>
|
||||
#include "access/htup_details.h"
|
||||
|
||||
#include "access/heapam.h"
|
||||
#include "access/reloptions.h"
|
||||
#include "access/sysattr.h"
|
||||
#include "access/tuptoaster.h"
|
||||
#include "catalog/namespace.h"
|
||||
#include "catalog/pg_foreign_table.h"
|
||||
|
@ -39,35 +35,71 @@
|
|||
#include "foreign/foreign.h"
|
||||
#include "miscadmin.h"
|
||||
#include "nodes/makefuncs.h"
|
||||
#if PG_VERSION_NUM < 120000
|
||||
#include "optimizer/cost.h"
|
||||
#endif
|
||||
#include "optimizer/pathnode.h"
|
||||
#include "optimizer/planmain.h"
|
||||
#include "optimizer/restrictinfo.h"
|
||||
#if PG_VERSION_NUM >= 120000
|
||||
#include "access/heapam.h"
|
||||
#include "access/tableam.h"
|
||||
#include "executor/tuptable.h"
|
||||
#include "optimizer/optimizer.h"
|
||||
#else
|
||||
#include "optimizer/var.h"
|
||||
#endif
|
||||
#include "parser/parser.h"
|
||||
#include "parser/parsetree.h"
|
||||
#include "parser/parse_coerce.h"
|
||||
#include "parser/parse_type.h"
|
||||
#include "storage/fd.h"
|
||||
#include "tcop/utility.h"
|
||||
#include "utils/builtins.h"
|
||||
#include "utils/fmgroids.h"
|
||||
#include "utils/memutils.h"
|
||||
#include "utils/lsyscache.h"
|
||||
#include "utils/rel.h"
|
||||
#if PG_VERSION_NUM >= 120000
|
||||
#include "utils/snapmgr.h"
|
||||
#else
|
||||
#include "utils/tqual.h"
|
||||
#endif
|
||||
#if PG_VERSION_NUM < 120000
|
||||
#include "utils/rel.h"
|
||||
#endif
|
||||
|
||||
#include "cstore.h"
|
||||
#include "cstore_fdw.h"
|
||||
#include "cstore_version_compat.h"
|
||||
|
||||
/* table containing information about how to partition distributed tables */
|
||||
#define CITUS_EXTENSION_NAME "citus"
|
||||
#define CITUS_PARTITION_TABLE_NAME "pg_dist_partition"
|
||||
|
||||
/* human-readable names for addressing columns of the pg_dist_partition table */
|
||||
#define ATTR_NUM_PARTITION_RELATION_ID 1
|
||||
#define ATTR_NUM_PARTITION_TYPE 2
|
||||
#define ATTR_NUM_PARTITION_KEY 3
|
||||
|
||||
/*
|
||||
* CStoreValidOption keeps an option name and a context. When an option is passed
|
||||
* into cstore_fdw objects (server and foreign table), we compare this option's
|
||||
* name and context against those of valid options.
|
||||
*/
|
||||
typedef struct CStoreValidOption
|
||||
{
|
||||
const char *optionName;
|
||||
Oid optionContextId;
|
||||
|
||||
} CStoreValidOption;
|
||||
|
||||
#define COMPRESSION_STRING_DELIMITED_LIST "none, pglz"
|
||||
|
||||
/* Array of options that are valid for cstore_fdw */
|
||||
static const uint32 ValidOptionCount = 4;
|
||||
static const CStoreValidOption ValidOptionArray[] =
|
||||
{
|
||||
/* foreign table options */
|
||||
{ OPTION_NAME_FILENAME, ForeignTableRelationId },
|
||||
{ OPTION_NAME_COMPRESSION_TYPE, ForeignTableRelationId },
|
||||
{ OPTION_NAME_STRIPE_ROW_COUNT, ForeignTableRelationId },
|
||||
{ OPTION_NAME_BLOCK_ROW_COUNT, ForeignTableRelationId }
|
||||
};
|
||||
|
||||
/* local functions forward declarations */
|
||||
#if PG_VERSION_NUM >= 100000
|
||||
|
@ -94,7 +126,6 @@ static List * DroppedCStoreFilenameList(DropStmt *dropStatement);
|
|||
static List * FindCStoreTables(List *tableList);
|
||||
static List * OpenRelationsForTruncate(List *cstoreTableList);
|
||||
static void TruncateCStoreTables(List *cstoreRelationList);
|
||||
static void DeleteCStoreTableFiles(char *filename);
|
||||
static bool CStoreTable(Oid relationId);
|
||||
static bool CStoreServer(ForeignServer *server);
|
||||
static bool DistributedTable(Oid relationId);
|
||||
|
@ -858,41 +889,6 @@ TruncateCStoreTables(List *cstoreRelationList)
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* DeleteCStoreTableFiles deletes the data and footer files for a cstore table
|
||||
* whose data filename is given.
|
||||
*/
|
||||
static void
|
||||
DeleteCStoreTableFiles(char *filename)
|
||||
{
|
||||
int dataFileRemoved = 0;
|
||||
int footerFileRemoved = 0;
|
||||
|
||||
StringInfo tableFooterFilename = makeStringInfo();
|
||||
appendStringInfo(tableFooterFilename, "%s%s", filename, CSTORE_FOOTER_FILE_SUFFIX);
|
||||
|
||||
/* delete the footer file */
|
||||
footerFileRemoved = unlink(tableFooterFilename->data);
|
||||
if (footerFileRemoved != 0)
|
||||
{
|
||||
ereport(WARNING, (errcode_for_file_access(),
|
||||
errmsg("could not delete file \"%s\": %m",
|
||||
tableFooterFilename->data)));
|
||||
}
|
||||
|
||||
/* delete the data file */
|
||||
dataFileRemoved = unlink(filename);
|
||||
if (dataFileRemoved != 0)
|
||||
{
|
||||
ereport(WARNING, (errcode_for_file_access(),
|
||||
errmsg("could not delete file \"%s\": %m",
|
||||
filename)));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* 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.
|
||||
|
|
44
cstore_fdw.h
44
cstore_fdw.h
|
@ -14,49 +14,9 @@
|
|||
#ifndef CSTORE_FDW_H
|
||||
#define CSTORE_FDW_H
|
||||
|
||||
#include "access/tupdesc.h"
|
||||
#include "postgres.h"
|
||||
|
||||
#include "fmgr.h"
|
||||
#include "catalog/pg_am.h"
|
||||
#include "catalog/pg_foreign_server.h"
|
||||
#include "catalog/pg_foreign_table.h"
|
||||
#include "lib/stringinfo.h"
|
||||
#include "utils/rel.h"
|
||||
|
||||
#include "cstore.h"
|
||||
|
||||
/* table containing information about how to partition distributed tables */
|
||||
#define CITUS_EXTENSION_NAME "citus"
|
||||
#define CITUS_PARTITION_TABLE_NAME "pg_dist_partition"
|
||||
|
||||
/* human-readable names for addressing columns of the pg_dist_partition table */
|
||||
#define ATTR_NUM_PARTITION_RELATION_ID 1
|
||||
#define ATTR_NUM_PARTITION_TYPE 2
|
||||
#define ATTR_NUM_PARTITION_KEY 3
|
||||
|
||||
/*
|
||||
* CStoreValidOption keeps an option name and a context. When an option is passed
|
||||
* into cstore_fdw objects (server and foreign table), we compare this option's
|
||||
* name and context against those of valid options.
|
||||
*/
|
||||
typedef struct CStoreValidOption
|
||||
{
|
||||
const char *optionName;
|
||||
Oid optionContextId;
|
||||
|
||||
} CStoreValidOption;
|
||||
|
||||
#define COMPRESSION_STRING_DELIMITED_LIST "none, pglz"
|
||||
|
||||
/* Array of options that are valid for cstore_fdw */
|
||||
static const uint32 ValidOptionCount = 4;
|
||||
static const CStoreValidOption ValidOptionArray[] =
|
||||
{
|
||||
/* foreign table options */
|
||||
{ OPTION_NAME_FILENAME, ForeignTableRelationId },
|
||||
{ OPTION_NAME_COMPRESSION_TYPE, ForeignTableRelationId },
|
||||
{ OPTION_NAME_STRIPE_ROW_COUNT, ForeignTableRelationId },
|
||||
{ OPTION_NAME_BLOCK_ROW_COUNT, ForeignTableRelationId }
|
||||
};
|
||||
|
||||
void cstore_fdw_init(void);
|
||||
void cstore_fdw_finish(void);
|
||||
|
|
|
@ -14,11 +14,12 @@
|
|||
|
||||
|
||||
#include "postgres.h"
|
||||
#include "cstore_fdw.h"
|
||||
#include "cstore_metadata_serialization.h"
|
||||
#include "cstore.pb-c.h"
|
||||
|
||||
#include "access/tupmacs.h"
|
||||
|
||||
#include "cstore.h"
|
||||
#include "cstore_metadata_serialization.h"
|
||||
#include "cstore.pb-c.h"
|
||||
|
||||
/* local functions forward declarations */
|
||||
static ProtobufCBinaryData DatumToProtobufBinary(Datum datum, bool typeByValue,
|
||||
|
|
|
@ -14,12 +14,6 @@
|
|||
#ifndef CSTORE_SERIALIZATION_H
|
||||
#define CSTORE_SERIALIZATION_H
|
||||
|
||||
#include "catalog/pg_attribute.h"
|
||||
#include "nodes/pg_list.h"
|
||||
#include "lib/stringinfo.h"
|
||||
#include "cstore_fdw.h"
|
||||
|
||||
|
||||
/* Function declarations for metadata serialization */
|
||||
extern StringInfo SerializePostScript(uint64 tableFooterLength);
|
||||
extern StringInfo SerializeTableFooter(TableFooter *tableFooter);
|
||||
|
|
|
@ -15,30 +15,26 @@
|
|||
|
||||
|
||||
#include "postgres.h"
|
||||
#include "cstore_fdw.h"
|
||||
#include "cstore_metadata_serialization.h"
|
||||
#include "cstore_version_compat.h"
|
||||
|
||||
#include "access/nbtree.h"
|
||||
#include "access/skey.h"
|
||||
#include "catalog/pg_am.h"
|
||||
#include "commands/defrem.h"
|
||||
#include "nodes/makefuncs.h"
|
||||
#if PG_VERSION_NUM >= 120000
|
||||
#include "nodes/pathnodes.h"
|
||||
#include "nodes/nodeFuncs.h"
|
||||
#include "optimizer/optimizer.h"
|
||||
#else
|
||||
#include "optimizer/clauses.h"
|
||||
#include "optimizer/predtest.h"
|
||||
#include "optimizer/var.h"
|
||||
#endif
|
||||
#include "optimizer/restrictinfo.h"
|
||||
#include "port.h"
|
||||
#include "storage/fd.h"
|
||||
#include "utils/memutils.h"
|
||||
#include "utils/lsyscache.h"
|
||||
#include "utils/rel.h"
|
||||
|
||||
#include "cstore.h"
|
||||
#include "cstore_metadata_serialization.h"
|
||||
#include "cstore_version_compat.h"
|
||||
|
||||
/* static function declarations */
|
||||
static StripeBuffers * LoadFilteredStripeBuffers(FILE *tableFile,
|
||||
|
|
|
@ -49,7 +49,7 @@
|
|||
#define TTS_EMPTY(slot) ((slot)->tts_isempty)
|
||||
#define ExecForceStoreHeapTuple(tuple, slot, shouldFree) \
|
||||
ExecStoreTuple(newTuple, tupleSlot, InvalidBuffer, shouldFree);
|
||||
#define HeapScanDesc TableScanDesc
|
||||
#define TableScanDesc HeapScanDesc
|
||||
#define table_beginscan heap_beginscan
|
||||
#define table_endscan heap_endscan
|
||||
|
||||
|
|
|
@ -15,25 +15,17 @@
|
|||
|
||||
|
||||
#include "postgres.h"
|
||||
#include "cstore_fdw.h"
|
||||
#include "cstore_metadata_serialization.h"
|
||||
#include "cstore_version_compat.h"
|
||||
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include "access/nbtree.h"
|
||||
#include "catalog/pg_collation.h"
|
||||
#include "commands/defrem.h"
|
||||
#if PG_VERSION_NUM >= 120000
|
||||
#include "optimizer/optimizer.h"
|
||||
#else
|
||||
#include "optimizer/var.h"
|
||||
#endif
|
||||
#include "port.h"
|
||||
#include "catalog/pg_am.h"
|
||||
#include "storage/fd.h"
|
||||
#include "utils/memutils.h"
|
||||
#include "utils/lsyscache.h"
|
||||
#include "utils/rel.h"
|
||||
|
||||
#include "cstore.h"
|
||||
#include "cstore_metadata_serialization.h"
|
||||
#include "cstore_version_compat.h"
|
||||
|
||||
static void CStoreWriteFooter(StringInfo footerFileName, TableFooter *tableFooter);
|
||||
static StripeBuffers * CreateEmptyStripeBuffers(uint32 stripeMaxRowCount,
|
||||
|
|
Loading…
Reference in New Issue