mirror of https://github.com/citusdata/citus.git
Run check_indent on COPY changes
parent
2a8121ca5f
commit
9bb579b1b1
|
@ -239,14 +239,15 @@ typedef struct ShardConnections
|
||||||
static HTAB * CreateShardConnectionHash(void);
|
static HTAB * CreateShardConnectionHash(void);
|
||||||
static bool IsUniformHashDistribution(ShardInterval **shardIntervalArray,
|
static bool IsUniformHashDistribution(ShardInterval **shardIntervalArray,
|
||||||
int shardCount);
|
int shardCount);
|
||||||
static FmgrInfo * ShardIntervalCompareFunction(Var *partitionColumn, char partitionMethod);
|
static FmgrInfo * ShardIntervalCompareFunction(Var *partitionColumn, char
|
||||||
|
partitionMethod);
|
||||||
static ShardInterval * FindShardInterval(Datum partitionColumnValue,
|
static ShardInterval * FindShardInterval(Datum partitionColumnValue,
|
||||||
ShardInterval **shardIntervalCache,
|
ShardInterval **shardIntervalCache,
|
||||||
int shardCount, char partitionMethod,
|
int shardCount, char partitionMethod,
|
||||||
FmgrInfo *compareFunction,
|
FmgrInfo *compareFunction,
|
||||||
FmgrInfo *hashFunction, bool useBinarySearch);
|
FmgrInfo *hashFunction, bool useBinarySearch);
|
||||||
static ShardInterval * SearchCachedShardInterval(Datum partitionColumnValue,
|
static ShardInterval * SearchCachedShardInterval(Datum partitionColumnValue,
|
||||||
ShardInterval** shardIntervalCache,
|
ShardInterval **shardIntervalCache,
|
||||||
int shardCount,
|
int shardCount,
|
||||||
FmgrInfo *compareFunction);
|
FmgrInfo *compareFunction);
|
||||||
static void OpenShardConnections(CopyStmt *copyStatement,
|
static void OpenShardConnections(CopyStmt *copyStatement,
|
||||||
|
@ -266,7 +267,7 @@ static void ReportCopyError(PGconn *connection, PGresult *result);
|
||||||
* and range-partitioned tables.
|
* and range-partitioned tables.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
CitusCopyFrom(CopyStmt *copyStatement, char* completionTag)
|
CitusCopyFrom(CopyStmt *copyStatement, char *completionTag)
|
||||||
{
|
{
|
||||||
RangeVar *relation = copyStatement->relation;
|
RangeVar *relation = copyStatement->relation;
|
||||||
Oid tableId = RangeVarGetRelid(relation, NoLock, false);
|
Oid tableId = RangeVarGetRelid(relation, NoLock, false);
|
||||||
|
@ -319,7 +320,8 @@ CitusCopyFrom(CopyStmt *copyStatement, char* completionTag)
|
||||||
if (partitionMethod != DISTRIBUTE_BY_RANGE && partitionMethod != DISTRIBUTE_BY_HASH)
|
if (partitionMethod != DISTRIBUTE_BY_RANGE && partitionMethod != DISTRIBUTE_BY_HASH)
|
||||||
{
|
{
|
||||||
ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
||||||
errmsg("COPY is only supported for hash- and range-partitioned tables")));
|
errmsg(
|
||||||
|
"COPY is only supported for hash- and range-partitioned tables")));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* resolve hash function for partition column */
|
/* resolve hash function for partition column */
|
||||||
|
@ -450,14 +452,14 @@ CitusCopyFrom(CopyStmt *copyStatement, char* completionTag)
|
||||||
|
|
||||||
/* find the partition column value */
|
/* find the partition column value */
|
||||||
|
|
||||||
if (columnNulls[partitionColumn->varattno-1])
|
if (columnNulls[partitionColumn->varattno - 1])
|
||||||
{
|
{
|
||||||
ereport(ERROR, (errcode(ERRCODE_NULL_VALUE_NOT_ALLOWED),
|
ereport(ERROR, (errcode(ERRCODE_NULL_VALUE_NOT_ALLOWED),
|
||||||
errmsg("cannot copy row with NULL value "
|
errmsg("cannot copy row with NULL value "
|
||||||
"in partition column")));
|
"in partition column")));
|
||||||
}
|
}
|
||||||
|
|
||||||
partitionColumnValue = columnValues[partitionColumn->varattno-1];
|
partitionColumnValue = columnValues[partitionColumn->varattno - 1];
|
||||||
|
|
||||||
/* find the shard interval and id for the partition column value */
|
/* find the shard interval and id for the partition column value */
|
||||||
shardInterval = FindShardInterval(partitionColumnValue, shardIntervalCache,
|
shardInterval = FindShardInterval(partitionColumnValue, shardIntervalCache,
|
||||||
|
@ -649,7 +651,7 @@ FindShardInterval(Datum partitionColumnValue, ShardInterval **shardIntervalCache
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
uint32 hashTokenIncrement = (uint32) (HASH_TOKEN_COUNT / shardCount);
|
uint32 hashTokenIncrement = (uint32) (HASH_TOKEN_COUNT / shardCount);
|
||||||
int shardHashCode = ((uint32) (hashedValue-INT32_MIN)/hashTokenIncrement);
|
int shardHashCode = ((uint32) (hashedValue - INT32_MIN) / hashTokenIncrement);
|
||||||
|
|
||||||
shardInterval = shardIntervalCache[shardHashCode];
|
shardInterval = shardIntervalCache[shardHashCode];
|
||||||
}
|
}
|
||||||
|
@ -670,7 +672,7 @@ FindShardInterval(Datum partitionColumnValue, ShardInterval **shardIntervalCache
|
||||||
* given partition column value and returns it.
|
* given partition column value and returns it.
|
||||||
*/
|
*/
|
||||||
static ShardInterval *
|
static ShardInterval *
|
||||||
SearchCachedShardInterval(Datum partitionColumnValue, ShardInterval** shardIntervalCache,
|
SearchCachedShardInterval(Datum partitionColumnValue, ShardInterval **shardIntervalCache,
|
||||||
int shardCount, FmgrInfo *compareFunction)
|
int shardCount, FmgrInfo *compareFunction)
|
||||||
{
|
{
|
||||||
int lowerBoundIndex = 0;
|
int lowerBoundIndex = 0;
|
||||||
|
@ -682,17 +684,18 @@ SearchCachedShardInterval(Datum partitionColumnValue, ShardInterval** shardInter
|
||||||
if (DatumGetInt32(FunctionCall2Coll(compareFunction,
|
if (DatumGetInt32(FunctionCall2Coll(compareFunction,
|
||||||
DEFAULT_COLLATION_OID,
|
DEFAULT_COLLATION_OID,
|
||||||
partitionColumnValue,
|
partitionColumnValue,
|
||||||
shardIntervalCache[middleIndex]->minValue)) < 0)
|
shardIntervalCache[middleIndex]->minValue)) <
|
||||||
|
0)
|
||||||
{
|
{
|
||||||
upperBoundIndex = middleIndex;
|
upperBoundIndex = middleIndex;
|
||||||
}
|
}
|
||||||
else if (DatumGetInt32(FunctionCall2Coll(compareFunction,
|
else if (DatumGetInt32(FunctionCall2Coll(compareFunction,
|
||||||
DEFAULT_COLLATION_OID,
|
DEFAULT_COLLATION_OID,
|
||||||
partitionColumnValue,
|
partitionColumnValue,
|
||||||
shardIntervalCache[middleIndex]->maxValue)) <= 0)
|
shardIntervalCache[middleIndex]->maxValue))
|
||||||
|
<= 0)
|
||||||
{
|
{
|
||||||
return shardIntervalCache[middleIndex];
|
return shardIntervalCache[middleIndex];
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -848,7 +851,8 @@ AppendCopyOptions(StringInfo command, List *copyOptionList)
|
||||||
{
|
{
|
||||||
ereport(ERROR,
|
ereport(ERROR,
|
||||||
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
|
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
|
||||||
errmsg("argument to option \"%s\" must be a list of column names",
|
errmsg(
|
||||||
|
"argument to option \"%s\" must be a list of column names",
|
||||||
option->defname)));
|
option->defname)));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -924,7 +928,7 @@ ConnectionList(HTAB *connectionHash)
|
||||||
{
|
{
|
||||||
List *connectionList = NIL;
|
List *connectionList = NIL;
|
||||||
HASH_SEQ_STATUS status;
|
HASH_SEQ_STATUS status;
|
||||||
ShardConnections* shardConnections = NULL;
|
ShardConnections *shardConnections = NULL;
|
||||||
|
|
||||||
hash_seq_init(&status, connectionHash);
|
hash_seq_init(&status, connectionHash);
|
||||||
while ((shardConnections = (ShardConnections *) hash_seq_search(&status)) != NULL)
|
while ((shardConnections = (ShardConnections *) hash_seq_search(&status)) != NULL)
|
||||||
|
|
|
@ -21,7 +21,7 @@ extern int CopyTransactionManager;
|
||||||
|
|
||||||
|
|
||||||
/* function declarations for copying into a distributed table */
|
/* function declarations for copying into a distributed table */
|
||||||
extern void CitusCopyFrom(CopyStmt *copyStatement, char* completionTag);
|
extern void CitusCopyFrom(CopyStmt *copyStatement, char *completionTag);
|
||||||
|
|
||||||
|
|
||||||
#endif /* MULTI_COPY_H */
|
#endif /* MULTI_COPY_H */
|
||||||
|
|
|
@ -43,7 +43,7 @@ typedef struct TransactionConnection
|
||||||
{
|
{
|
||||||
int64 connectionId;
|
int64 connectionId;
|
||||||
TransactionState transactionState;
|
TransactionState transactionState;
|
||||||
PGconn* connection;
|
PGconn *connection;
|
||||||
} TransactionConnection;
|
} TransactionConnection;
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue