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


C++ PG_RETURN_TEXT_P函数代码示例

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


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

示例1: json_recv

/*
 * Binary receive.
 */
Datum
json_recv(PG_FUNCTION_ARGS)
{
	StringInfo	buf = (StringInfo) PG_GETARG_POINTER(0);
	text	   *result;
	char	   *str;
	int			nbytes;
	JsonLexContext *lex;

	str = pq_getmsgtext(buf, buf->len - buf->cursor, &nbytes);

	result = palloc(nbytes + VARHDRSZ);
	SET_VARSIZE(result, nbytes + VARHDRSZ);
	memcpy(VARDATA(result), str, nbytes);

	/* Validate it. */
	lex = makeJsonLexContext(result, false);
	pg_parse_json(lex, NullSemAction);

	PG_RETURN_TEXT_P(result);
}
开发者ID:TesterRandolph,项目名称:postgres-x2,代码行数:24,代码来源:json.c

示例2: utl_file_tmpdir

Datum
utl_file_tmpdir(PG_FUNCTION_ARGS)
{
#ifndef WIN32
	const char *tmpdir = getenv("TMPDIR");

	if (!tmpdir)
		tmpdir = "/tmp";
#else
	char		tmpdir[MAXPGPATH];
	int			ret;

	ret = GetTempPath(MAXPGPATH, tmpdir);
	if (ret == 0 || ret > MAXPGPATH)
		CUSTOM_EXCEPTION(INVALID_PATH, strerror(errno));

	canonicalize_path(tmpdir);
#endif

	PG_RETURN_TEXT_P(cstring_to_text(tmpdir));
}
开发者ID:50wu,项目名称:gpdb,代码行数:21,代码来源:file.c

示例3: EnableXform

Datum
EnableXform(PG_FUNCTION_ARGS)
{
	char *szXform = textToString(PG_GETARG_TEXT_P(0));
	bool fResult = COptTasks::FSetXform(szXform, false /*fDisable*/);

	StringInfoData str;
	initStringInfo(&str);

	if (fResult)
	{
		appendStringInfo(&str, "%s is enabled", szXform);
	}
	else
	{
		appendStringInfo(&str, "%s is not recognized", szXform);
	}
	text *result = stringToText(str.data);

	PG_RETURN_TEXT_P(result);
}
开发者ID:BenjaminYu,项目名称:gpdb,代码行数:21,代码来源:funcs.cpp

示例4: ExecuteMinidumpFromFile

Datum
ExecuteMinidumpFromFile(PG_FUNCTION_ARGS)
{
	char *szFileName = textToString(PG_GETARG_TEXT_P(0));
	char *szResultDXL = COptTasks::SzOptimizeMinidumpFromFile(szFileName);
	if (NULL == szResultDXL)
	{
		elog(NOTICE, "Execution of UDF 'ExecuteMinidumpFromFile' failed. Consult the LOG for more information.");

		// return a dummy value
		PG_RETURN_NULL();
	}
	int iProcessed = executeXMLPlan(szResultDXL);
	gpdb::GPDBFree(szResultDXL);
	StringInfoData str;
	initStringInfo(&str);
	appendStringInfo(&str, "processed %d rows", iProcessed);
	text *ptResult = stringToText(str.data);

	PG_RETURN_TEXT_P(ptResult);
}
开发者ID:BenjaminYu,项目名称:gpdb,代码行数:21,代码来源:funcs.cpp

示例5: LWGEOM_to_text

Datum LWGEOM_to_text(PG_FUNCTION_ARGS)
{
	GSERIALIZED *geom = (GSERIALIZED*)PG_DETOAST_DATUM(PG_GETARG_DATUM(0));
	LWGEOM *lwgeom;
	char *hexwkb;
	size_t hexwkb_size;
	text *result;

	/* Generate WKB hex text */
	lwgeom = lwgeom_from_gserialized(geom);
	hexwkb = lwgeom_to_hexwkb(lwgeom, WKB_EXTENDED, &hexwkb_size);
	lwgeom_free(lwgeom);
	
	/* Copy into text obect */
	result = cstring2text(hexwkb);
	pfree(hexwkb);
	
	/* Clean up and return */
	PG_FREE_IF_COPY(geom, 0);
	PG_RETURN_TEXT_P(result);
}
开发者ID:JeremyGrosser,项目名称:postgis,代码行数:21,代码来源:lwgeom_inout.c

示例6: pgp_sym_encrypt_text

Datum
pgp_sym_encrypt_text(PG_FUNCTION_ARGS)
{
	bytea	   *data,
			   *key;
	text	   *arg = NULL;
	text	   *res;

	data = PG_GETARG_BYTEA_P(0);
	key = PG_GETARG_BYTEA_P(1);
	if (PG_NARGS() > 2)
		arg = PG_GETARG_BYTEA_P(2);

	res = encrypt_internal(0, 1, data, key, arg);

	PG_FREE_IF_COPY(data, 0);
	PG_FREE_IF_COPY(key, 1);
	if (PG_NARGS() > 2)
		PG_FREE_IF_COPY(arg, 2);
	PG_RETURN_TEXT_P(res);
}
开发者ID:5A68656E67,项目名称:postgres,代码行数:21,代码来源:pgp-pgsql.c

示例7: get_group_name

Datum get_group_name(PG_FUNCTION_ARGS) {
  
  int group_id = PG_GETARG_INT32(0);

  int ret = SPI_connect();
  if (ret < 0)
        elog(ERROR, "get_group_name: SPI_connect returned %d", ret);

  char buf[1024];
  sprintf(buf, "SELECT get_group_name_by_id(%d)", group_id);
  elog (INFO, "get_group_name: %s", buf);

  ret = SPI_exec(buf, 10);

  if (ret < 0)
    elog(ERROR, "get_group_name: SPI_exec returned %d", ret);
  else
    elog(INFO, "get_group_name: SPI_exec succeeded");

  char *group_name = SPI_getvalue(SPI_tuptable->vals[0],
                                  SPI_tuptable->tupdesc,
                                  1);
  SPI_finish();  

  elog (INFO, "get_group_name: %s", group_name);

  text *result = 0;
  if (0 == group_name) {
    elog(ERROR, "get_group_name: SPI_getvalue returned null");
    result = (text *)palloc(VARHDRSZ);
    SET_VARSIZE(result, VARHDRSZ);
  } else {
    int len = strlen(group_name);
    result = (text *)palloc(VARHDRSZ + len);
    SET_VARSIZE(result, VARHDRSZ + len);
    memcpy(VARDATA(result), group_name, len);
  }

  PG_RETURN_TEXT_P(result);
}
开发者ID:AhmetsafinV,项目名称:db36,代码行数:40,代码来源:libdb36.c

示例8: brin_page_type

Datum
brin_page_type(PG_FUNCTION_ARGS)
{
	bytea	   *raw_page = PG_GETARG_BYTEA_P(0);
	Page		page = VARDATA(raw_page);
	int			raw_page_size;
	char	   *type;

	if (!superuser())
		ereport(ERROR,
				(errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
				 (errmsg("must be superuser to use raw page functions"))));

	raw_page_size = VARSIZE(raw_page) - VARHDRSZ;

	if (raw_page_size != BLCKSZ)
		ereport(ERROR,
				(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
				 errmsg("input page too small"),
				 errdetail("Expected size %d, got %d",
						   BLCKSZ, raw_page_size)));

	switch (BrinPageType(page))
	{
		case BRIN_PAGETYPE_META:
			type = "meta";
			break;
		case BRIN_PAGETYPE_REVMAP:
			type = "revmap";
			break;
		case BRIN_PAGETYPE_REGULAR:
			type = "regular";
			break;
		default:
			type = psprintf("unknown (%02x)", BrinPageType(page));
			break;
	}

	PG_RETURN_TEXT_P(cstring_to_text(type));
}
开发者ID:MasahikoSawada,项目名称:postgresql,代码行数:40,代码来源:brinfuncs.c

示例9: plvstr_rstrip

Datum
plvstr_rstrip (PG_FUNCTION_ARGS)
{
	text *str = PG_GETARG_TEXT_PP(0);
	text *pat = PG_GETARG_TEXT_PP(1);
	int num = PG_GETARG_INT32(2);
	int count = 0;
	int len_p, len_s, i;

	char *str_p, *aux_str_p, *pat_p;
	len_p = VARSIZE_ANY_EXHDR(pat);
	len_s = VARSIZE_ANY_EXHDR(str);

	str_p = VARDATA_ANY(str) + len_s - 1;

	while (count < num)
	{
		pat_p = VARDATA_ANY(pat) + len_p - 1;
		aux_str_p = str_p;

		if (len_s < len_p)
			break;

		for (i = 0; i < len_p; i++)
			if (*aux_str_p-- != *pat_p--)
				break;

		if (i >= len_p)
		{
			count++;
			/* found */
			str_p = aux_str_p;
			len_s -= len_p;
			continue;
		}
		break;
	}

	PG_RETURN_TEXT_P(cstring_to_text_with_len(VARDATA_ANY(str),len_s));
}
开发者ID:protodef,项目名称:orafce,代码行数:40,代码来源:plvstr.c

示例10: dmetaphone

Datum
dmetaphone(PG_FUNCTION_ARGS)
{
	text	   *arg,
			   *result;
	int			alen,
				rsize;
	char	   *aptr,
			   *codes[2],
			   *code,
			   *rptr;

#ifdef DMETAPHONE_NOSTRICT
	if (PG_ARGISNULL(0))
		PG_RETURNNULL();
#endif
	arg = PG_GETARG_TEXT_P(0);
	alen = VARSIZE(arg) - VARHDRSZ;

	/*
	 * Postgres' string values might not have trailing nuls. The VARSIZE will
	 * not include the nul in any case so we copy things out and add a
	 * trailing nul. When we copy back we ignore the nul (and we don't make
	 * space for it).
	 */

	aptr = palloc(alen + 1);
	memcpy(aptr, VARDATA(arg), alen);
	aptr[alen] = 0;
	DoubleMetaphone(aptr, codes);
	code = codes[0];
	if (!code)
		code = "";
	rsize = VARHDRSZ + strlen(code);
	result = (text *) palloc(rsize);
	rptr = VARDATA(result);
	memcpy(rptr, code, rsize - VARHDRSZ);
	SET_VARSIZE(result, rsize);
	PG_RETURN_TEXT_P(result);
}
开发者ID:KMU-embedded,项目名称:mosbench-ext,代码行数:40,代码来源:dmetaphone.c

示例11: repack_indexdef

/**
 * @fn      Datum repack_indexdef(PG_FUNCTION_ARGS)
 * @brief   Reproduce DDL that create index at the temp table.
 *
 * repack_indexdef(index, table)
 *
 * @param	index		Oid of target index.
 * @param	table		Oid of table of the index.
 * @param	tablespace	Namespace for the index. If NULL keep the original.
 * @param   boolean		Whether to use CONCURRENTLY when creating the index.
 * @retval			Create index DDL for temp table.
 */
Datum
repack_indexdef(PG_FUNCTION_ARGS)
{
	Oid				index;
	Oid				table;
	Name			tablespace = NULL;
	IndexDef		stmt;
	StringInfoData	str;
	bool			concurrent_index = PG_GETARG_BOOL(3);

	if (PG_ARGISNULL(0) || PG_ARGISNULL(1))
		PG_RETURN_NULL();

	index = PG_GETARG_OID(0);
	table = PG_GETARG_OID(1);

	if (!PG_ARGISNULL(2))
		tablespace = PG_GETARG_NAME(2);

	parse_indexdef(&stmt, index, table);

	initStringInfo(&str);
	if (concurrent_index)
		appendStringInfo(&str, "%s CONCURRENTLY index_%u ON %s USING %s (%s)%s",
			stmt.create, index, stmt.table, stmt.type, stmt.columns, stmt.options);
	else
		appendStringInfo(&str, "%s index_%u ON repack.table_%u USING %s (%s)%s",
			stmt.create, index, table, stmt.type, stmt.columns, stmt.options);

	/* specify the new tablespace or the original one if any */
	if (tablespace || stmt.tablespace)
		appendStringInfo(&str, " TABLESPACE %s",
			(tablespace ? NameStr(*tablespace) : stmt.tablespace));

	if (stmt.where)
		appendStringInfo(&str, " WHERE %s", stmt.where);

	PG_RETURN_TEXT_P(cstring_to_text(str.data));
}
开发者ID:reorg,项目名称:pg_repack,代码行数:51,代码来源:repack.c

示例12: geometry_geometrytype

Datum geometry_geometrytype(PG_FUNCTION_ARGS)
{
	GSERIALIZED *lwgeom;
	text *type_text;
	char *type_str = palloc(32);

	lwgeom = (GSERIALIZED*)PG_DETOAST_DATUM(PG_GETARG_DATUM(0));

	/* Make it empty string to start */
	*type_str = 0;

	/* Build up the output string */
	strncat(type_str, "ST_", 32);
	strncat(type_str, lwtype_name(gserialized_get_type(lwgeom)), 32);
	
	/* Build a text type to store things in */
	type_text = cstring2text(type_str);
	pfree(type_str);

	PG_FREE_IF_COPY(lwgeom, 0);
	PG_RETURN_TEXT_P(type_text);
}
开发者ID:gravitystorm,项目名称:postgis,代码行数:22,代码来源:lwgeom_ogc.c

示例13: plr_set_display

Datum
plr_set_display(PG_FUNCTION_ARGS)
{
	char		   *display = PG_TEXT_GET_STR(PG_GETARG_TEXT_P(0));
	size_t			d_len = strlen(display);

	if (d_len)
	{
		char			   *denv;
		MemoryContext		oldcontext;

		/* Needs to live until/unless we explicitly delete it */
		oldcontext = MemoryContextSwitchTo(TopMemoryContext);
		denv = palloc(9 + d_len);
		MemoryContextSwitchTo(oldcontext);

		sprintf(denv, "DISPLAY=%s", display);
		putenv(denv);
	}

	PG_RETURN_TEXT_P(PG_STR_GET_TEXT("OK"));
}
开发者ID:bhavinkamani,项目名称:plr,代码行数:22,代码来源:pg_userfuncs.c

示例14: macaddr_text

Datum
macaddr_text(PG_FUNCTION_ARGS)
{
	/* Input is a macaddr, but may as well leave it in Datum form */
	Datum		addr = PG_GETARG_DATUM(0);
	text	   *result;
	char	   *str;
	int			len;

	str = DatumGetCString(DirectFunctionCall1(macaddr_out, addr));

	len = (strlen(str) + VARHDRSZ);

	result = palloc(len);

	SET_VARSIZE(result, len);
	memcpy(VARDATA(result), str, (len - VARHDRSZ));

	pfree(str);

	PG_RETURN_TEXT_P(result);
}
开发者ID:AnLingm,项目名称:gpdb,代码行数:22,代码来源:mac.c

示例15: pg_read_file

/*
 * Read a section of a file, returning it as text
 */
Datum
pg_read_file(PG_FUNCTION_ARGS)
{
	text	   *filename_t = PG_GETARG_TEXT_P(0);
	int64		seek_offset = PG_GETARG_INT64(1);
	int64		bytes_to_read = PG_GETARG_INT64(2);
	char	   *filename;

	if (!superuser())
		ereport(ERROR,
				(errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
				 (errmsg("must be superuser to read files"))));

	filename = convert_and_check_filename(filename_t);

	if (bytes_to_read < 0)
		ereport(ERROR,
				(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
				 errmsg("requested length cannot be negative")));

	PG_RETURN_TEXT_P(read_text_file(filename, seek_offset, bytes_to_read));
}
开发者ID:BioBD,项目名称:Hypothetical_Indexes,代码行数:25,代码来源:genfile.c


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