示例#1
0
	List *createSnapshotCommands = MetadataCreateCommands();
	List *snapshotCommandList = NIL;
	ListCell *snapshotCommandCell = NULL;
	int snapshotCommandCount = 0;
	Datum *snapshotCommandDatumArray = NULL;
	ArrayType *snapshotCommandArrayType = NULL;
	int snapshotCommandIndex = 0;
	Oid ddlCommandTypeId = TEXTOID;

	snapshotCommandList = list_concat(snapshotCommandList, dropSnapshotCommands);
	snapshotCommandList = list_concat(snapshotCommandList, createSnapshotCommands);

	snapshotCommandCount = list_length(snapshotCommandList);
	snapshotCommandDatumArray = palloc0(snapshotCommandCount * sizeof(Datum));

	foreach(snapshotCommandCell, snapshotCommandList)
	{
		char *metadataSnapshotCommand = (char *) lfirst(snapshotCommandCell);
		Datum metadataSnapshotCommandDatum = CStringGetTextDatum(metadataSnapshotCommand);

		snapshotCommandDatumArray[snapshotCommandIndex] = metadataSnapshotCommandDatum;
		snapshotCommandIndex++;
	}

	snapshotCommandArrayType = DatumArrayToArrayType(snapshotCommandDatumArray,
													 snapshotCommandCount,
													 ddlCommandTypeId);

	PG_RETURN_ARRAYTYPE_P(snapshotCommandArrayType);
}
示例#2
0
		shardList = LoadShardIntervalList(distributedTableId);
	}

	shardIdCount = list_length(shardList);
	shardIdDatumArray = palloc0(shardIdCount * sizeof(Datum));

	foreach(shardCell, shardList)
	{
		ShardInterval *shardId = (ShardInterval *) lfirst(shardCell);
		Datum shardIdDatum = Int64GetDatum(shardId->id);

		shardIdDatumArray[shardIdIndex] = shardIdDatum;
		shardIdIndex++;
	}

	shardIdArrayType = DatumArrayToArrayType(shardIdDatumArray, shardIdCount,
											 shardIdTypeId);

	PG_RETURN_ARRAYTYPE_P(shardIdArrayType);
}


/*
 * load_shard_interval_array loads a shard interval using a provided identifier
 * and returns a two-element array consisting of min/max values contained in
 * that shard interval (currently always integer values). If no such interval
 * can be found, this function raises an error instead.
 */
Datum
load_shard_interval_array(PG_FUNCTION_ARGS)
{
	int64 shardId = PG_GETARG_INT64(0);
示例#3
0
	ListCell *colocatedTableCell = NULL;
	int colocatedTableCount = list_length(colocatedTableList);
	Datum *colocatedTablesDatumArray = palloc0(colocatedTableCount * sizeof(Datum));
	Oid arrayTypeId = OIDOID;
	int colocatedTableIndex = 0;

	foreach(colocatedTableCell, colocatedTableList)
	{
		Oid colocatedTableId = lfirst_oid(colocatedTableCell);
		Datum colocatedTableDatum = ObjectIdGetDatum(colocatedTableId);

		colocatedTablesDatumArray[colocatedTableIndex] = colocatedTableDatum;
		colocatedTableIndex++;
	}

	colocatedTablesArrayType = DatumArrayToArrayType(colocatedTablesDatumArray,
													 colocatedTableCount, arrayTypeId);

	PG_RETURN_ARRAYTYPE_P(colocatedTablesArrayType);
}


/*
 * get_colocated_shards_array returns array of shards ids which are co-located with given
 * shard.
 */
Datum
get_colocated_shard_array(PG_FUNCTION_ARGS)
{
	uint32 shardId = PG_GETARG_UINT32(0);
	ShardInterval *shardInterval = LoadShardInterval(shardId);
示例#4
0
	Datum *ddlCommandDatumArray = palloc0(ddlCommandCount * sizeof(Datum));

	ListCell *ddlCommandCell = NULL;
	int ddlCommandIndex = 0;
	Oid ddlCommandTypeId = TEXTOID;

	foreach(ddlCommandCell, ddlCommandList)
	{
		char *ddlCommand = (char *) lfirst(ddlCommandCell);
		Datum ddlCommandDatum = CStringGetTextDatum(ddlCommand);

		ddlCommandDatumArray[ddlCommandIndex] = ddlCommandDatum;
		ddlCommandIndex++;
	}

	ddlCommandArrayType = DatumArrayToArrayType(ddlCommandDatumArray, ddlCommandCount,
												ddlCommandTypeId);

	PG_RETURN_ARRAYTYPE_P(ddlCommandArrayType);
}


/*
 * alter_server_host_and_port_command is used to test foreign server OPTION
 * generation. When provided with a foreign server name, hostname and port,
 * the function will return an ALTER SERVER command to set the server's host
 * and port options to the provided values.
 */
Datum
alter_server_host_and_port_command(PG_FUNCTION_ARGS)
{
	char *serverName = PG_GETARG_CSTRING(0);