本文整理汇总了C++中PG_GETARG_TEXT_P函数的典型用法代码示例。如果您正苦于以下问题:C++ PG_GETARG_TEXT_P函数的具体用法?C++ PG_GETARG_TEXT_P怎么用?C++ PG_GETARG_TEXT_P使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了PG_GETARG_TEXT_P函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: pgstattuple
Datum
pgstattuple(PG_FUNCTION_ARGS)
{
text *relname = PG_GETARG_TEXT_P(0);
RangeVar *relrv;
Relation rel;
if (!superuser())
ereport(ERROR,
(errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
(errmsg("must be superuser to use pgstattuple functions"))));
/* open relation */
relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
rel = relation_openrv(relrv, AccessShareLock);
PG_RETURN_DATUM(pgstat_relation(rel, fcinfo));
}
示例2: text2ltree
Datum
text2ltree(PG_FUNCTION_ARGS)
{
text *in = PG_GETARG_TEXT_P(0);
char *s = (char *) palloc(VARSIZE(in) - VARHDRSZ + 1);
ltree *out;
memcpy(s, VARDATA(in), VARSIZE(in) - VARHDRSZ);
s[VARSIZE(in) - VARHDRSZ] = '\0';
out = (ltree *) DatumGetPointer(DirectFunctionCall1(
ltree_in,
PointerGetDatum(s)
));
pfree(s);
PG_FREE_IF_COPY(in, 0);
PG_RETURN_POINTER(out);
}
示例3: text_char
Datum
text_char(PG_FUNCTION_ARGS)
{
text *arg1 = PG_GETARG_TEXT_P(0);
char result;
/*
* An empty input string is converted to \0 (for consistency with
* charin). If the input is longer than one character, the excess data
* is silently discarded.
*/
if (VARSIZE(arg1) > VARHDRSZ)
result = *(VARDATA(arg1));
else
result = '\0';
PG_RETURN_CHAR(result);
}
示例4: pg_decrypt
Datum
pg_decrypt(PG_FUNCTION_ARGS)
{
int err;
bytea *data,
*key,
*res;
text *type;
PX_Combo *c;
unsigned dlen,
klen,
rlen;
type = PG_GETARG_TEXT_P(2);
c = find_provider(type, (PFN) px_find_combo, "Cipher", 0);
data = PG_GETARG_BYTEA_P(0);
key = PG_GETARG_BYTEA_P(1);
dlen = VARSIZE(data) - VARHDRSZ;
klen = VARSIZE(key) - VARHDRSZ;
rlen = px_combo_decrypt_len(c, dlen);
res = palloc(VARHDRSZ + rlen);
err = px_combo_init(c, (uint8 *) VARDATA(key), klen, NULL, 0);
if (!err)
err = px_combo_decrypt(c, (uint8 *) VARDATA(data), dlen,
(uint8 *) VARDATA(res), &rlen);
px_combo_free(c);
if (err)
ereport(ERROR,
(errcode(ERRCODE_EXTERNAL_ROUTINE_INVOCATION_EXCEPTION),
errmsg("decrypt error: %s", px_strerror(err))));
SET_VARSIZE(res, VARHDRSZ + rlen);
PG_FREE_IF_COPY(data, 0);
PG_FREE_IF_COPY(key, 1);
PG_FREE_IF_COPY(type, 2);
PG_RETURN_BYTEA_P(res);
}
示例5: headline_byname
Datum
headline_byname(PG_FUNCTION_ARGS)
{
text *cfg = PG_GETARG_TEXT_P(0);
Datum out;
SET_FUNCOID();
out = DirectFunctionCall4(
headline,
ObjectIdGetDatum(name2id_cfg(cfg)),
PG_GETARG_DATUM(1),
PG_GETARG_DATUM(2),
(PG_NARGS() > 3) ? PG_GETARG_DATUM(3) : PointerGetDatum(NULL)
);
PG_FREE_IF_COPY(cfg, 0);
PG_RETURN_DATUM(out);
}
示例6: do_write
/* fwrite(encode(args[n], encoding), f) */
static int
do_write(PG_FUNCTION_ARGS, int n, FILE *f, int max_linesize, int encoding)
{
text *arg = PG_GETARG_TEXT_P(n);
char *str;
int len;
str = encode_text(encoding, arg, &len);
CHECK_LENGTH(len);
if (fwrite(str, 1, len, f) != len)
CHECK_ERRNO_PUT();
if (VARDATA(arg) != str)
pfree(str);
PG_FREE_IF_COPY(arg, n);
return len;
}
示例7: to_tsquery_byid
Datum
to_tsquery_byid(PG_FUNCTION_ARGS)
{
Oid cfgid = PG_GETARG_OID(0);
text *in = PG_GETARG_TEXT_P(1);
TSQuery query;
QueryItem *res;
int4 len;
query = parse_tsquery(text_to_cstring(in), pushval_morph, ObjectIdGetDatum(cfgid), false);
if (query->size == 0)
PG_RETURN_TSQUERY(query);
/* clean out any stopword placeholders from the tree */
res = clean_fakeval(GETQUERY(query), &len);
if (!res)
{
SET_VARSIZE(query, HDRSIZETQ);
query->size = 0;
PG_RETURN_POINTER(query);
}
memcpy((void *) GETQUERY(query), (void *) res, len * sizeof(QueryItem));
/*
* Removing the stopword placeholders might've resulted in fewer
* QueryItems. If so, move the operands up accordingly.
*/
if (len != query->size)
{
char *oldoperand = GETOPERAND(query);
int4 lenoperand = VARSIZE(query) - (oldoperand - (char *) query);
Assert(len < query->size);
query->size = len;
memmove((void *) GETOPERAND(query), oldoperand, VARSIZE(query) - (oldoperand - (char *) query));
SET_VARSIZE(query, COMPUTESIZE(len, lenoperand));
}
pfree(res);
PG_RETURN_TSQUERY(query);
}
示例8: domainname_parts
Datum domainname_parts(PG_FUNCTION_ARGS)
{
text *in = PG_GETARG_TEXT_P(0);
const char *s = VARDATA(in);
const char *b = s, *p = s, *e = s + VARSIZE_ANY_EXHDR(in);
int nelems = 0;
int nbytes = ARR_OVERHEAD_NONULLS(1);
ArrayType *r;
char *o;
while (p < e)
{
b = p;
STRSEARCH(p, e-p, *p == '.');
nelems ++;
nbytes += VARHDRSZ + (p-b);
nbytes = INTALIGN(nbytes);
p ++;
}
r = (ArrayType *)palloc(nbytes);
SET_VARSIZE(r, nbytes);
r->ndim = 1;
r->dataoffset = 0;
r->elemtype = TEXTOID;
*ARR_DIMS(r) = nelems;
*ARR_LBOUND(r) = 1;
p = s;
o = ARR_DATA_PTR(r);
while (p < e)
{
b = p;
STRSEARCH(p, e-p, *p == '.');
SET_VARSIZE(o, VARHDRSZ+(p-b));
o = VARDATA(o);
memcpy(o, b, p-b);
o += INTALIGN(p-b);
p ++;
}
PG_FREE_IF_COPY(in, 0);
PG_RETURN_ARRAYTYPE_P(r);
}
示例9: text_int4
Datum
text_int4(PG_FUNCTION_ARGS)
{
text *string = PG_GETARG_TEXT_P(0);
Datum result;
int len;
char *str;
len = VARSIZE(string) - VARHDRSZ;
str = palloc(len + 1);
memcpy(str, VARDATA(string), len);
*(str + len) = '\0';
result = DirectFunctionCall1(int4in, CStringGetDatum(str));
pfree(str);
return result;
}
示例10: OptimizeMinidumpFromFile
Datum
OptimizeMinidumpFromFile(PG_FUNCTION_ARGS)
{
char *szFileName = textToString(PG_GETARG_TEXT_P(0));
char *szResultDXL = COptTasks::SzOptimizeMinidumpFromFile(szFileName);
if (NULL != szResultDXL)
{
text *ptResult = stringToText(szResultDXL);
gpdb::GPDBFree(szResultDXL);
PG_RETURN_TEXT_P(ptResult);
}
else
{
elog(NOTICE, "Execution of UDF 'OptimizeMinidumpFromFile' failed. Consult the LOG for more information.");
// return a dummy value
PG_RETURN_NULL();
}
}
示例11: text_float4
/*
* text_float4 - converts a text string to a float4 number
*/
Datum
text_float4(PG_FUNCTION_ARGS)
{
text *string = PG_GETARG_TEXT_P(0);
Datum result;
int len;
char *str;
len = (VARSIZE(string) - VARHDRSZ);
str = palloc(len + 1);
memcpy(str, VARDATA(string), len);
*(str + len) = '\0';
result = DirectFunctionCall1(float4in, CStringGetDatum(str));
pfree(str);
PG_RETURN_DATUM(result);
}
示例12: Optimize
Datum
Optimize(PG_FUNCTION_ARGS)
{
char *szSQLText = textToString(PG_GETARG_TEXT_P(0));
Query *pquery = parseSQL(szSQLText);
Query *pqueryNormalized = preprocess_query_optimizer(pquery, NULL);
Assert(pqueryNormalized);
char *szOutput = COptTasks::SzOptimize(pqueryNormalized);
if (NULL == szOutput)
{
elog(ERROR, "Error optimizing query");
}
PG_RETURN_TEXT_P(stringToText(szOutput));
}
示例13: LWGEOM_asHEXEWKB
Datum LWGEOM_asHEXEWKB(PG_FUNCTION_ARGS)
{
GSERIALIZED *geom = (GSERIALIZED*)PG_DETOAST_DATUM(PG_GETARG_DATUM(0));
LWGEOM *lwgeom;
char *hexwkb;
size_t hexwkb_size;
uint8_t variant = 0;
text *result;
text *type;
size_t text_size;
/* If user specified endianness, respect it */
if ( (PG_NARGS()>1) && (!PG_ARGISNULL(1)) )
{
type = PG_GETARG_TEXT_P(1);
if ( ! strncmp(VARDATA(type), "xdr", 3) ||
! strncmp(VARDATA(type), "XDR", 3) )
{
variant = variant | WKB_XDR;
}
else
{
variant = variant | WKB_NDR;
}
}
/* Create WKB hex string */
lwgeom = lwgeom_from_gserialized(geom);
hexwkb = lwgeom_to_hexwkb(lwgeom, variant | WKB_EXTENDED, &hexwkb_size);
lwgeom_free(lwgeom);
/* Prepare the PgSQL text return type */
text_size = hexwkb_size - 1 + VARHDRSZ;
result = palloc(text_size);
memcpy(VARDATA(result), hexwkb, hexwkb_size - 1);
SET_VARSIZE(result, text_size);
/* Clean up and return */
pfree(hexwkb);
PG_FREE_IF_COPY(geom, 0);
PG_RETURN_TEXT_P(result);
}
示例14: pg_start_backup
/*
* pg_start_backup: set up for taking an on-line backup dump
*
* Essentially what this does is to create a backup label file in $PGDATA,
* where it will be archived as part of the backup dump. The label file
* contains the user-supplied label string (typically this would be used
* to tell where the backup dump will be stored) and the starting time and
* starting WAL location for the dump.
*/
Datum
pg_start_backup(PG_FUNCTION_ARGS)
{
text *backupid = PG_GETARG_TEXT_P(0);
bool fast = PG_GETARG_BOOL(1);
char *backupidstr;
XLogRecPtr startpoint;
backupidstr = text_to_cstring(backupid);
if (!superuser() && !has_rolreplication(GetUserId()))
ereport(ERROR,
(errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
errmsg("must be superuser or replication role to run a backup")));
startpoint = do_pg_start_backup(backupidstr, fast, NULL, NULL);
PG_RETURN_LSN(startpoint);
}
示例15: dbms_alert_register
Datum
dbms_alert_register(PG_FUNCTION_ARGS)
{
text *name = PG_GETARG_TEXT_P(0);
int cycle = 0;
float8 endtime;
float8 timeout = 2;
WATCH_PRE(timeout, endtime, cycle);
if (ora_lock_shmem(SHMEMMSGSZ, MAX_PIPES, MAX_EVENTS, MAX_LOCKS, false))
{
register_event(name);
LWLockRelease(shmem_lock);
PG_RETURN_VOID();
}
WATCH_POST(timeout, endtime, cycle);
LOCK_ERROR();
PG_RETURN_VOID();
}