本文整理汇总了C++中DirectFunctionCall1函数的典型用法代码示例。如果您正苦于以下问题:C++ DirectFunctionCall1函数的具体用法?C++ DirectFunctionCall1怎么用?C++ DirectFunctionCall1使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了DirectFunctionCall1函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: oid_text
Datum
oid_text(PG_FUNCTION_ARGS)
{
Oid oid = PG_GETARG_OID(0);
text *result;
int len;
char *str;
str = DatumGetCString(DirectFunctionCall1(oidout,
ObjectIdGetDatum(oid)));
len = strlen(str) + VARHDRSZ;
result = (text *) palloc(len);
VARATT_SIZEP(result) = len;
memcpy(VARDATA(result), str, (len - VARHDRSZ));
pfree(str);
PG_RETURN_TEXT_P(result);
}
示例2: uuid_generate_internal
static Datum
uuid_generate_internal(int mode, const uuid_t *ns, const char *name)
{
uuid_t *uuid;
char *str;
uuid_rc_t rc;
rc = uuid_create(&uuid);
if (rc != UUID_RC_OK)
pguuid_complain(rc);
rc = uuid_make(uuid, mode, ns, name);
if (rc != UUID_RC_OK)
pguuid_complain(rc);
str = uuid_to_string(uuid);
rc = uuid_destroy(uuid);
if (rc != UUID_RC_OK)
pguuid_complain(rc);
return DirectFunctionCall1(uuid_in, CStringGetDatum(str));
}
示例3: special_uuid_value
static Datum
special_uuid_value(const char *name)
{
uuid_t *uuid;
char *str;
uuid_rc_t rc;
rc = uuid_create(&uuid);
if (rc != UUID_RC_OK)
pguuid_complain(rc);
rc = uuid_load(uuid, name);
if (rc != UUID_RC_OK)
pguuid_complain(rc);
str = uuid_to_string(uuid);
rc = uuid_destroy(uuid);
if (rc != UUID_RC_OK)
pguuid_complain(rc);
return DirectFunctionCall1(uuid_in, CStringGetDatum(str));
}
示例4: pg_convert_from
/*
* Convert string using encoding_name. The destination
* encoding is the DB encoding.
*
* TEXT convert_from(BYTEA string, NAME encoding_name) */
Datum
pg_convert_from(PG_FUNCTION_ARGS)
{
Datum string = PG_GETARG_DATUM(0);
Datum src_encoding_name = PG_GETARG_DATUM(1);
Datum dest_encoding_name = DirectFunctionCall1(namein,
CStringGetDatum(DatabaseEncoding->name));
Datum result;
result = DirectFunctionCall3(pg_convert, string,
src_encoding_name, dest_encoding_name);
/*
* pg_convert returns a bytea, which we in turn return as text, relying on
* the fact that they are both in fact varlena types, and thus
* structurally identical. Although not all bytea values are valid text,
* in this case it will be because we've told pg_convert to return one
* that is valid as text in the current database encoding.
*/
PG_RETURN_DATUM(result);
}
示例5: poly2path
PATH *
poly2path(POLYGON *poly)
{
int i;
char *output = (char *) palloc(2 * (P_MAXDIG + 1) * poly->npts + 64);
char buf[2 * (P_MAXDIG) + 20];
sprintf(output, "(1, %*d", P_MAXDIG, poly->npts);
for (i = 0; i < poly->npts; i++)
{
snprintf(buf, sizeof(buf), ",%*g,%*g",
P_MAXDIG, poly->p[i].x, P_MAXDIG, poly->p[i].y);
strcat(output, buf);
}
snprintf(buf, sizeof(buf), "%c", RDELIM);
strcat(output, buf);
return DatumGetPathP(DirectFunctionCall1(path_in,
CStringGetDatum(output)));
}
示例6: text_macaddr
Datum
text_macaddr(PG_FUNCTION_ARGS)
{
text *addr = PG_GETARG_TEXT_P(0);
Datum result;
char str[100];
int len;
len = (VARSIZE(addr) - VARHDRSZ);
if (len >= sizeof(str))
ereport(ERROR,
(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
errmsg("text too long to convert to MAC address")));
memcpy(str, VARDATA(addr), len);
*(str + len) = '\0';
result = DirectFunctionCall1(macaddr_in, CStringGetDatum(str));
return (result);
}
示例7: 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);
}
示例8: float4_text
/*
* float4_text - converts a float4 number to a text string
*/
Datum
float4_text(PG_FUNCTION_ARGS)
{
float4 num = PG_GETARG_FLOAT4(0);
text *result;
int len;
char *str;
str = DatumGetCString(DirectFunctionCall1(float4out,
Float4GetDatum(num)));
len = strlen(str) + VARHDRSZ;
result = (text *) palloc(len);
VARATT_SIZEP(result) = len;
memcpy(VARDATA(result), str, (len - VARHDRSZ));
pfree(str);
PG_RETURN_TEXT_P(result);
}
示例9: pcpoint_get_value
Datum pcpoint_get_value(PG_FUNCTION_ARGS)
{
SERIALIZED_POINT *serpt = PG_GETARG_SERPOINT_P(0);
text *dim_name = PG_GETARG_TEXT_P(1);
char *dim_str;
float8 double_result;
PCSCHEMA *schema = pc_schema_from_pcid(serpt->pcid, fcinfo);
PCPOINT *pt = pc_point_deserialize(serpt, schema);
if ( ! pt )
PG_RETURN_NULL();
dim_str = text_to_cstring(dim_name);
if ( ! pc_point_get_double_by_name(pt, dim_str, &double_result) )
{
pc_point_free(pt);
elog(ERROR, "dimension \"%s\" does not exist in schema", dim_str);
}
pfree(dim_str);
pc_point_free(pt);
PG_RETURN_DATUM(DirectFunctionCall1(float8_numeric, Float8GetDatum(double_result)));
}
示例10: LWGEOM_asText
Datum LWGEOM_asText(PG_FUNCTION_ARGS)
{
LWGEOM_UNPARSER_RESULT lwg_unparser_result;
PG_LWGEOM *lwgeom;
PG_LWGEOM *ogclwgeom;
int len, result;
char *lwgeom_result,*loc_wkt;
char *semicolonLoc;
POSTGIS_DEBUG(2, "LWGEOM_asText called.");
lwgeom = (PG_LWGEOM *)PG_DETOAST_DATUM(PG_GETARG_DATUM(0));
/* Force to 2d */
ogclwgeom = (PG_LWGEOM *)DatumGetPointer(DirectFunctionCall1(
LWGEOM_force_2d, PointerGetDatum(lwgeom)));
result = serialized_lwgeom_to_ewkt(&lwg_unparser_result, SERIALIZED_FORM(ogclwgeom), PARSER_CHECK_NONE);
if (result)
PG_UNPARSER_ERROR(lwg_unparser_result);
semicolonLoc = strchr(lwg_unparser_result.wkoutput,';');
/* loc points to start of wkt */
if (semicolonLoc == NULL) loc_wkt = lwg_unparser_result.wkoutput;
else loc_wkt = semicolonLoc +1;
len = strlen(loc_wkt)+VARHDRSZ;
lwgeom_result = palloc(len);
SET_VARSIZE(lwgeom_result, len);
memcpy(VARDATA(lwgeom_result), loc_wkt, len-VARHDRSZ);
pfree(lwg_unparser_result.wkoutput);
PG_FREE_IF_COPY(lwgeom, 0);
if ( ogclwgeom != lwgeom ) pfree(ogclwgeom);
PG_RETURN_POINTER(lwgeom_result);
}
示例11: current_schemas
Datum
current_schemas(PG_FUNCTION_ARGS)
{
List *search_path = fetch_search_path(PG_GETARG_BOOL(0));
ListCell *l;
Datum *names;
int i;
ArrayType *array;
names = (Datum *) palloc(list_length(search_path) * sizeof(Datum));
i = 0;
foreach(l, search_path)
{
char *nspname;
nspname = get_namespace_name(lfirst_oid(l));
if (nspname) /* watch out for deleted namespace */
{
names[i] = DirectFunctionCall1(namein, CStringGetDatum(nspname));
i++;
}
}
示例12: lo_in
/*
* This creates a large object, and sets its OID to the value in the
* supplied string.
*
* If the string is empty, then a new LargeObject is created, and its oid
* is placed in the resulting lo.
*/
Blob *
lo_in(char *str)
{
Blob *result;
Oid oid;
int count;
if (strlen(str) > 0)
{
count = sscanf(str, "%u", &oid);
if (count < 1)
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("error in parsing \"%s\"", str)));
if (oid == InvalidOid)
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("illegal oid: \"%s\"", str)));
}
else
{
/*
* There is no Oid passed, so create a new one
*/
oid = DatumGetObjectId(DirectFunctionCall1(lo_creat,
Int32GetDatum(INV_READ | INV_WRITE)));
if (oid == InvalidOid)
/* internal error */
elog(ERROR, "InvalidOid returned from lo_creat");
}
result = (Blob *) palloc(sizeof(Blob));
*result = oid;
return (result);
}
示例13: spherepoly_out
Datum
spherepoly_out(PG_FUNCTION_ARGS)
{
SPOLY *poly = PG_GETARG_SPOLY(0);
int32 i;
char *out = (char *) palloc(128 * poly->npts);
char *tmp;
strcpy(out, "{");
for (i = 0; i < poly->npts; i++)
{
if (i > 0)
{
strcat(out, ",");
}
tmp = DatumGetPointer(DirectFunctionCall1(spherepoint_out,
PointerGetDatum(&poly->p[i])));
strcat(out, tmp);
pfree(tmp);
}
strcat(out, "}");
PG_RETURN_CSTRING(out);
}
示例14: months_between
Datum
months_between(PG_FUNCTION_ARGS)
{
DateADT date1 = PG_GETARG_DATEADT(0);
DateADT date2 = PG_GETARG_DATEADT(1);
int y1, m1, d1;
int y2, m2, d2;
float8 result;
j2date(date1 + POSTGRES_EPOCH_JDATE, &y1, &m1, &d1);
j2date(date2 + POSTGRES_EPOCH_JDATE, &y2, &m2, &d2);
/* Ignore day components for last days, or based on a 31-day month. */
if (d1 == days_of_month(y1, m1) && d2 == days_of_month(y2, m2))
result = (y1 - y2) * 12 + (m1 - m2);
else
result = (y1 - y2) * 12 + (m1 - m2) + (d1 - d2) / 31.0;
PG_RETURN_NUMERIC(
DirectFunctionCall1(float8_numeric, Float8GetDatumFast(result)));
}
示例15: GeneratePartitioningInformation
/*
* GenereatePartitioningInformation returns the partitioning type and partition column
* for the given parent table in the form of "PARTITION TYPE (partitioning column(s)/expression(s))".
*/
char *
GeneratePartitioningInformation(Oid parentTableId)
{
char *partitionBoundCString = "";
#if (PG_VERSION_NUM >= 100000)
Datum partitionBoundDatum = 0;
if (!PartitionedTable(parentTableId))
{
char *relationName = get_rel_name(parentTableId);
ereport(ERROR, (errmsg("\"%s\" is not a parent table", relationName)));
}
partitionBoundDatum = DirectFunctionCall1(pg_get_partkeydef,
ObjectIdGetDatum(parentTableId));
partitionBoundCString = TextDatumGetCString(partitionBoundDatum);
#endif
return partitionBoundCString;
}