当前位置: 首页>>代码示例>>C++>>正文


C++ DatumGetCString函数代码示例

本文整理汇总了C++中DatumGetCString函数的典型用法代码示例。如果您正苦于以下问题:C++ DatumGetCString函数的具体用法?C++ DatumGetCString怎么用?C++ DatumGetCString使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了DatumGetCString函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: pgpool_remote_start

Datum
pgpool_remote_start(PG_FUNCTION_ARGS)
{
	int r;
	char *remote_host = DatumGetCString(DirectFunctionCall1(textout,
															PointerGetDatum(PG_GETARG_TEXT_P(0))));
	char *remote_data_directory = DatumGetCString(DirectFunctionCall1(textout,
																	  PointerGetDatum(PG_GETARG_TEXT_P(1))));

	if (!superuser())
		ereport(ERROR,
				(errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
				 (errmsg("must be superuser to use pgpool_remote_start function"))));

	snprintf(recovery_script, sizeof(recovery_script),
			 "%s/%s %s %s", DataDir, REMOTE_START_FILE,
			 remote_host, remote_data_directory);
	elog(DEBUG1, "recovery_script: %s", recovery_script);
	r = system(recovery_script);

	if (r != 0)
	{
		elog(ERROR, "pgpool_remote_start failed");
	}

	PG_RETURN_BOOL(true);
}
开发者ID:machack666,项目名称:pgpool-II,代码行数:27,代码来源:pgpool-recovery.c

示例2: find_language_template

/*
 * Look to see if we have template information for the given language name.
 */
static PLTemplate *
find_language_template(const char *languageName)
{
	PLTemplate *result;
	Relation	rel;
	SysScanDesc scan;
	ScanKeyData key;
	HeapTuple	tup;

	rel = heap_open(PLTemplateRelationId, AccessShareLock);

	ScanKeyInit(&key,
				Anum_pg_pltemplate_tmplname,
				BTEqualStrategyNumber, F_NAMEEQ,
				NameGetDatum(languageName));
	scan = systable_beginscan(rel, PLTemplateNameIndexId, true,
							  SnapshotNow, 1, &key);

	tup = systable_getnext(scan);
	if (HeapTupleIsValid(tup))
	{
		Form_pg_pltemplate tmpl = (Form_pg_pltemplate) GETSTRUCT(tup);
		Datum		datum;
		bool		isnull;

		result = (PLTemplate *) palloc0(sizeof(PLTemplate));
		result->tmpltrusted = tmpl->tmpltrusted;

		/* Remaining fields are variable-width so we need heap_getattr */
		datum = heap_getattr(tup, Anum_pg_pltemplate_tmplhandler,
							 RelationGetDescr(rel), &isnull);
		if (!isnull)
			result->tmplhandler =
				DatumGetCString(DirectFunctionCall1(textout, datum));

		datum = heap_getattr(tup, Anum_pg_pltemplate_tmplvalidator,
							 RelationGetDescr(rel), &isnull);
		if (!isnull)
			result->tmplvalidator =
				DatumGetCString(DirectFunctionCall1(textout, datum));

		datum = heap_getattr(tup, Anum_pg_pltemplate_tmpllibrary,
							 RelationGetDescr(rel), &isnull);
		if (!isnull)
			result->tmpllibrary =
				DatumGetCString(DirectFunctionCall1(textout, datum));

		/* Ignore template if handler or library info is missing */
		if (!result->tmplhandler || !result->tmpllibrary)
			result = NULL;
	}
	else
		result = NULL;

	systable_endscan(scan);

	heap_close(rel, AccessShareLock);

	return result;
}
开发者ID:CraigBryan,项目名称:PostgresqlFun,代码行数:63,代码来源:proclang.c

示例3: pr_set

/*
 * DML Functions
 */
Datum
pr_set(PG_FUNCTION_ARGS) {
	text * key_arg = PG_GETARG_TEXT_P(0);
	text * value_arg = PG_GETARG_TEXT_P(1);
	int expire = PG_GETARG_UINT32(2);
	int ret;
	
	char * key = NULL;
	char * value = NULL;
	
	if (!pgredis || !pgredis->redis_server) {
		elog(ERROR, "Unable to set, redis instance missing");
		PG_RETURN_FALSE;
	}

  	key = DatumGetCString(DirectFunctionCall1(textout, PointerGetDatum(key_arg)));
  	value = DatumGetCString(DirectFunctionCall1(textout, PointerGetDatum(value_arg)));
	
	if (!key || !value) {
		elog(ERROR, "Key/value incomplete in pgredis set");
		PG_RETURN_FALSE;
	}

	ret = credis_set(pgredis->redis_server, key, value);
	if (ret == CREDIS_OK) {
		ret = credis_expire(pgredis->redis_server, key, expire);
	}
  	PG_RETURN_BOOL(ret == CREDIS_OK);
}
开发者ID:tutunci,项目名称:pgredis,代码行数:32,代码来源:pgredis.c

示例4: CheckInMemConstraintsPgType

/*
 * CheckInMemConstraintsPgType
 * 		Check uniqueness constraints for pg_type in-memory tuples upon insert
 */
static void
CheckInMemConstraintsPgType(InMemHeapRelation relation, HeapTuple newTuple)
{
	Assert(NULL != newTuple);
	Assert(NULL != relation);
	Assert(NULL != relation->rel);

	TupleDesc tupleDesc = relation->rel->rd_att;
	Oid relnamespaceNew = DatumGetObjectId(tuple_getattr(newTuple, tupleDesc, Anum_pg_type_typnamespace));
	char *typnameNew    = DatumGetCString(tuple_getattr(newTuple, tupleDesc, Anum_pg_type_typname));

	for (int i = 0; i < relation->tupsize; i++)
	{
		HeapTuple tuple = relation->tuples[i].tuple;
		Assert(NULL != tuple);

		insist_log(HeapTupleGetOid(tuple) != HeapTupleGetOid(newTuple),
					"in-memory tuple with Oid = %d already exists in pg_type.", HeapTupleGetOid(tuple));

		Oid relnamespace = DatumGetObjectId(tuple_getattr(tuple, tupleDesc, Anum_pg_type_typnamespace));
		char *typname    = DatumGetCString(tuple_getattr(tuple, tupleDesc, Anum_pg_type_typname));
		size_t typnameLen = strlen(typname);

		insist_log(relnamespace != relnamespaceNew ||
				   typnameLen != strlen(typnameNew) ||
				   0 != strncmp(typname, typnameNew, typnameLen),
				"in-memory tuple with typname = %s and typnamespace = %d already exists in pg_type.", typname, relnamespace);
	}
}
开发者ID:BALDELab,项目名称:incubator-hawq,代码行数:33,代码来源:cdbinmemheapam.c

示例5: CheckInMemConstraintsPgNamespace

/*
 * CheckInMemConstraintsPgNamespace
 * 		Check uniqueness constraints for pg_namespace in-memory tuples upon insert
 */
static void
CheckInMemConstraintsPgNamespace(InMemHeapRelation relation, HeapTuple newTuple)
{
	Assert(NULL != newTuple);
	Assert(NULL != relation); 
	Assert(NULL != relation->rel);

	TupleDesc tupleDesc = relation->rel->rd_att;
	Oid nspdboidNew     = DatumGetObjectId(tuple_getattr(newTuple, tupleDesc, Anum_pg_namespace_nspdboid));
	char *nspnameNew    = DatumGetCString(tuple_getattr(newTuple, tupleDesc, Anum_pg_namespace_nspname));

	for (int i = 0; i < relation->tupsize; i++)
	{
		HeapTuple tuple = relation->tuples[i].tuple;
		Assert(NULL != tuple);

		insist_log(HeapTupleGetOid(tuple) != HeapTupleGetOid(newTuple), 
			"in-memory tuple with Oid = %d already exists in pg_namespace.", HeapTupleGetOid(tuple));

		Oid nspdboid  = DatumGetObjectId(tuple_getattr(tuple, tupleDesc, Anum_pg_namespace_nspdboid));
		char *nspname = DatumGetCString(tuple_getattr(tuple, tupleDesc, Anum_pg_namespace_nspname));
		size_t nspnameLen = strlen(nspname);

		insist_log(nspdboid != nspdboidNew ||
				   nspnameLen != strlen(nspnameNew) ||
				   0 != strncmp(nspname, nspnameNew, nspnameLen),
			"in-memory tuple with nspname = %s and nspdboid = %d already exists in pg_namespace.", nspname, nspdboid);
	}
}
开发者ID:BALDELab,项目名称:incubator-hawq,代码行数:33,代码来源:cdbinmemheapam.c

示例6: dump_bvf1_inputs

void dump_bvf1_inputs(ArrayType *broker_list_p, text *sector_name_p) {
	int ndim, nitems;
	int *dim;

	int16 typlen;
	bool typbyval;
	char typalign;

	int i;

	char *broker_list;

	ndim = ARR_NDIM(broker_list_p);
	dim = ARR_DIMS(broker_list_p);
	nitems = ArrayGetNItems(ndim, dim);
	get_typlenbyvalalign(ARR_ELEMTYPE(broker_list_p), &typlen, &typbyval,
			&typalign);

	broker_list = ARR_DATA_PTR(broker_list_p);
	elog(NOTICE, "BVF1: INPUTS START");
	for (i = 0; i < nitems; i++) {
		elog(NOTICE, "BVF1: broker_list[%d] %s", i,
				DatumGetCString(DirectFunctionCall1(textout,
				PointerGetDatum(broker_list))));
		broker_list = att_addlength_pointer(broker_list, typlen,
				broker_list);
		broker_list = (char *) att_align_nominal(broker_list, typalign);
	}
	elog(NOTICE, "BVF1: sector_name %s",
			DatumGetCString(DirectFunctionCall1(textout,
			PointerGetDatum(sector_name_p))));
	elog(NOTICE, "BVF1: INPUTS END");
}
开发者ID:EvilMcJerkface,项目名称:quro,代码行数:33,代码来源:broker_volume.c

示例7: tintervalout

/*
 *		tintervalout	- converts an internal tinterval format to a string
 */
Datum
tintervalout(PG_FUNCTION_ARGS)
{
	TimeInterval tinterval = PG_GETARG_TIMEINTERVAL(0);
	char	   *i_str,
			   *p;

	i_str = (char *) palloc(T_INTERVAL_LEN);	/* ["..." "..."] */
	strcpy(i_str, "[\"");
	if (tinterval->status == T_INTERVAL_INVAL)
		strcat(i_str, INVALID_INTERVAL_STR);
	else
	{
		p = DatumGetCString(DirectFunctionCall1(abstimeout,
								  AbsoluteTimeGetDatum(tinterval->data[0])));
		strcat(i_str, p);
		pfree(p);
		strcat(i_str, "\" \"");
		p = DatumGetCString(DirectFunctionCall1(abstimeout,
								  AbsoluteTimeGetDatum(tinterval->data[1])));
		strcat(i_str, p);
		pfree(p);
	}
	strcat(i_str, "\"]");
	PG_RETURN_CSTRING(i_str);
}
开发者ID:GisKook,项目名称:Gis,代码行数:29,代码来源:nabstime.c

示例8: pgpool_recovery

Datum
pgpool_recovery(PG_FUNCTION_ARGS)
{
	int			r;
	char	   *script = DatumGetCString(DirectFunctionCall1(textout,
															 PointerGetDatum(PG_GETARG_TEXT_P(0))));

	char	   *remote_host = DatumGetCString(DirectFunctionCall1(textout,
																  PointerGetDatum(PG_GETARG_TEXT_P(1))));
	char	   *remote_data_directory = DatumGetCString(DirectFunctionCall1(textout,
																			PointerGetDatum(PG_GETARG_TEXT_P(2))));

	if (!superuser())
#ifdef ERRCODE_INSUFFICIENT_PRIVILEGE
		ereport(ERROR,
				(errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
				 (errmsg("must be superuser to use pgpool_recovery function"))));
#else
		elog(ERROR, "must be superuser to use pgpool_recovery function");
#endif

	if (PG_NARGS() >= 5)		/* Pgpool-II 4.0 or later */
	{
		char	   *remote_port = DatumGetCString(DirectFunctionCall1(textout,
																	  PointerGetDatum(PG_GETARG_TEXT_P(3))));
		int			recovery_node = PG_GETARG_INT32(4);

		snprintf(recovery_script, sizeof(recovery_script), "\"%s/%s\" \"%s\" \"%s\" \"%s\" \"%s\" %d",
				 DataDir, script, DataDir, remote_host,
				 remote_data_directory, remote_port, recovery_node);
	}
	else if (PG_NARGS() >= 4)	/* Pgpool-II 3.4 - 3.7 */
	{
		char	   *remote_port = DatumGetCString(DirectFunctionCall1(textout,
																	  PointerGetDatum(PG_GETARG_TEXT_P(3))));

		snprintf(recovery_script, sizeof(recovery_script), "\"%s/%s\" \"%s\" \"%s\" \"%s\" \"%s\"",
				 DataDir, script, DataDir, remote_host,
				 remote_data_directory, remote_port);
	}
	else
	{
		snprintf(recovery_script, sizeof(recovery_script), "\"%s/%s\" \"%s\" \"%s\" \"%s\"",
				 DataDir, script, DataDir, remote_host,
				 remote_data_directory);
	}

	elog(DEBUG1, "recovery_script: %s", recovery_script);
	r = system(recovery_script);

	if (r != 0)
	{
		elog(ERROR, "pgpool_recovery failed");
	}

	PG_RETURN_BOOL(true);
}
开发者ID:pgpool,项目名称:pgpool2,代码行数:57,代码来源:pgpool-recovery.c

示例9: pgpool_pgctl

Datum
pgpool_pgctl(PG_FUNCTION_ARGS)
{
	int			r;
	char	   *action = DatumGetCString(DirectFunctionCall1(textout,
															 PointerGetDatum(PG_GETARG_TEXT_P(0))));
	char	   *stop_mode = DatumGetCString(DirectFunctionCall1(textout,
																PointerGetDatum(PG_GETARG_TEXT_P(1))));
	char	   *pg_ctl;
	char	   *data_directory;

	if (!superuser())
#ifdef ERRCODE_INSUFFICIENT_PRIVILEGE
		ereport(ERROR,
				(errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
				 (errmsg("must be superuser to use pgpool_pgctl function"))));
#else
		elog(ERROR, "must be superuser to use pgpool_pgctl function");
#endif

#if defined(PG_VERSION_NUM) && (PG_VERSION_NUM >= 90600)
	pg_ctl = GetConfigOptionByName("pgpool.pg_ctl", NULL, false);
	data_directory = GetConfigOptionByName("data_directory", NULL, false);
#else
	pg_ctl = GetConfigOptionByName("pgpool.pg_ctl", NULL);
	data_directory = GetConfigOptionByName("data_directory", NULL);
#endif

	if (strcmp(stop_mode, "") != 0)
	{
		snprintf(command_text, sizeof(command_text),
				 "%s %s -D %s -m %s 2>/dev/null 1>/dev/null < /dev/null &",
				 pg_ctl, action, data_directory, stop_mode);

	}
	else
	{
		snprintf(command_text, sizeof(command_text),
				 "%s %s -D %s 2>/dev/null 1>/dev/null < /dev/null &",
				 pg_ctl, action, data_directory);
	}

	elog(DEBUG1, "command_text: %s", command_text);
	r = system(command_text);

	if (strcmp(action, "reload") == 0 && r != 0)
	{
		elog(ERROR, "pgpool_pgctl failed");
	}

	PG_RETURN_BOOL(true);
}
开发者ID:pgpool,项目名称:pgpool2,代码行数:52,代码来源:pgpool-recovery.c

示例10: PLyDecimal_FromNumeric

static PyObject *
PLyDecimal_FromNumeric(PLyDatumToOb *arg, Datum d)
{
	static PyObject *decimal_constructor;
	char	   *str;
	PyObject   *pyvalue;

	/* Try to import cdecimal.  If it doesn't exist, fall back to decimal. */
	if (!decimal_constructor)
	{
		PyObject   *decimal_module;

		decimal_module = PyImport_ImportModule("cdecimal");
		if (!decimal_module)
		{
			PyErr_Clear();
			decimal_module = PyImport_ImportModule("decimal");
		}
		if (!decimal_module)
			PLy_elog(ERROR, "could not import a module for Decimal constructor");

		decimal_constructor = PyObject_GetAttrString(decimal_module, "Decimal");
		if (!decimal_constructor)
			PLy_elog(ERROR, "no Decimal attribute in module");
	}

	str = DatumGetCString(DirectFunctionCall1(numeric_out, d));
	pyvalue = PyObject_CallFunction(decimal_constructor, "s", str);
	if (!pyvalue)
		PLy_elog(ERROR, "conversion from numeric to Decimal failed");

	return pyvalue;
}
开发者ID:PJMODOS,项目名称:postgres,代码行数:33,代码来源:plpy_typeio.c

示例11: fetch_restriction

static
void fetch_restriction(
        HeapTuple *tuple,
        TupleDesc *tupdesc,
        Column_info_t info[4],
        Restrict_t *restriction) {
    restriction->id = pgr_SPI_getBigInt(tuple, tupdesc, info[0]);
    restriction->cost = pgr_SPI_getFloat8(tuple, tupdesc,  info[1]);
    char *str = DatumGetCString(
            SPI_getvalue(*tuple, *tupdesc, info[2].colNumber));

// TODO(someone) because its text, no guarantee the text read is correct
// move this code to c++ to tokenize the integers.
    int i = 0;
    for (i = 0; i < MAX_RULE_LENGTH; ++i) restriction->restricted_edges[i] = -1;
    str[0] = ',';
    if (str != NULL) {
        char *token = NULL;
        int i = 0;

        token = (char *)strtok(str, " ,");

        while (token != NULL && i < MAX_RULE_LENGTH) {
            restriction->restricted_edges[i] = atoi(token);
            i++;
            token = (char *)strtok(NULL, " ,");
        }
    }
}
开发者ID:chahidinho,项目名称:pgrouting,代码行数:29,代码来源:restrict_input.c

示例12: printTypmod

/*
 * Add typmod decoration to the basic type name
 */
static char *
printTypmod(const char *typname, int32 typmod, Oid typmodout)
{
	char	   *res;

	/* Shouldn't be called if typmod is -1 */
	Assert(typmod >= 0);

	if (typmodout == InvalidOid)
	{
		/* Default behavior: just print the integer typmod with parens */
		res = psnprintf(strlen(typname) + MAX_INT32_LEN + 3, "%s(%d)",
						typname, (int) typmod);
	}
	else
	{
		/* Use the type-specific typmodout procedure */
		char	   *tmstr;

		tmstr = DatumGetCString(OidFunctionCall1(typmodout,
												 Int32GetDatum(typmod)));
		res = psnprintf(strlen(typname) + strlen(tmstr) + 1, "%s%s",
						typname, tmstr);
	}

	return res;
}
开发者ID:50wu,项目名称:gpdb,代码行数:30,代码来源:format_type.c

示例13: binary_decode

Datum
binary_decode(PG_FUNCTION_ARGS)
{
	text	   *data = PG_GETARG_TEXT_P(0);
	Datum		name = PG_GETARG_DATUM(1);
	bytea	   *result;
	char	   *namebuf;
	int			datalen,
				resultlen,
				res;
	struct pg_encoding *enc;

	datalen = VARSIZE(data) - VARHDRSZ;

	namebuf = DatumGetCString(DirectFunctionCall1(textout, name));

	enc = pg_find_encoding(namebuf);
	if (enc == NULL)
		ereport(ERROR,
				(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
				 errmsg("unrecognized encoding: \"%s\"", namebuf)));

	resultlen = enc->decode_len(VARDATA(data), datalen);
	result = palloc(VARHDRSZ + resultlen);

	res = enc->decode(VARDATA(data), datalen, VARDATA(result));

	/* Make this FATAL 'cause we've trodden on memory ... */
	if (res > resultlen)
		elog(FATAL, "overflow - decode estimate too small");

	VARATT_SIZEP(result) = VARHDRSZ + res;

	PG_RETURN_BYTEA_P(result);
}
开发者ID:berkeley-cs186,项目名称:course-fa07,代码行数:35,代码来源:encode.c

示例14: base36_cast_from_text

Datum
base36_cast_from_text(PG_FUNCTION_ARGS)
{
	text *txt = PG_GETARG_TEXT_P(0);
	char *str = DatumGetCString(DirectFunctionCall1(textout, PointerGetDatum(txt)));
	PG_RETURN_INT32(base36_from_str(str));
}
开发者ID:adjust,项目名称:pg-base36,代码行数:7,代码来源:base36.c

示例15: jsonb_put_escaped_value

static void
jsonb_put_escaped_value(StringInfo out, JsonbValue *scalarVal)
{
	switch (scalarVal->type)
	{
		case jbvNull:
			appendBinaryStringInfo(out, "null", 4);
			break;
		case jbvString:
			escape_json(out, pnstrdup(scalarVal->val.string.val, scalarVal->val.string.len));
			break;
		case jbvNumeric:
			appendStringInfoString(out,
							 DatumGetCString(DirectFunctionCall1(numeric_out,
								  PointerGetDatum(scalarVal->val.numeric))));
			break;
		case jbvBool:
			if (scalarVal->val.boolean)
				appendBinaryStringInfo(out, "true", 4);
			else
				appendBinaryStringInfo(out, "false", 5);
			break;
		default:
			elog(ERROR, "unknown jsonb scalar type");
	}
}
开发者ID:MiniHero,项目名称:postgres,代码行数:26,代码来源:jsonb.c


注:本文中的DatumGetCString函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。