mirror of https://github.com/citusdata/citus.git
39 lines
1011 B
C
39 lines
1011 B
C
/*-------------------------------------------------------------------------
|
|
*
|
|
* shard_utils.c
|
|
*
|
|
* This file contains functions to perform useful operations on shards.
|
|
*
|
|
* Copyright (c) Citus Data, Inc.
|
|
*
|
|
*-------------------------------------------------------------------------
|
|
*/
|
|
|
|
#include "postgres.h"
|
|
|
|
#include "utils/lsyscache.h"
|
|
#include "distributed/relay_utility.h"
|
|
#include "distributed/shard_utils.h"
|
|
|
|
/*
|
|
* GetTableLocalShardOid returns the oid of the shard from the given distributed
|
|
* relation with the shardId.
|
|
*/
|
|
Oid
|
|
GetTableLocalShardOid(Oid citusTableOid, uint64 shardId)
|
|
{
|
|
const char *citusTableName = get_rel_name(citusTableOid);
|
|
|
|
Assert(citusTableName != NULL);
|
|
|
|
/* construct shard relation name */
|
|
char *shardRelationName = pstrdup(citusTableName);
|
|
AppendShardIdToName(&shardRelationName, shardId);
|
|
|
|
Oid citusTableSchemaOid = get_rel_namespace(citusTableOid);
|
|
|
|
Oid shardRelationOid = get_relname_relid(shardRelationName, citusTableSchemaOid);
|
|
|
|
return shardRelationOid;
|
|
}
|