本文整理汇总了C++中PG_GETARG_TEXT_P函数的典型用法代码示例。如果您正苦于以下问题:C++ PG_GETARG_TEXT_P函数的具体用法?C++ PG_GETARG_TEXT_P怎么用?C++ PG_GETARG_TEXT_P使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了PG_GETARG_TEXT_P函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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));
}
开发者ID:adunstan,项目名称:pg-cvs-mirror,代码行数:18,代码来源:pgstattuple.c
示例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);
}
开发者ID:KMU-embedded,项目名称:mosbench-ext,代码行数:18,代码来源:ltree_op.c
示例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);
}
开发者ID:sunyangkobe,项目名称:cscd43,代码行数:18,代码来源:char.c
示例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);
}
开发者ID:adunstan,项目名称:pg-cvs-mirror,代码行数:44,代码来源:pgcrypto.c
示例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);
}
开发者ID:shubham2094,项目名称:postgresql_8.2,代码行数:19,代码来源:wparser.c
示例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;
}
开发者ID:50wu,项目名称:gpdb,代码行数:20,代码来源:file.c
示例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);
}
开发者ID:mintuhouse,项目名称:postgresql-tuning,代码行数:43,代码来源:to_tsany.c
示例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);
}
开发者ID:dylex,项目名称:huzblem,代码行数:43,代码来源:pguri.c
示例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;
}
开发者ID:rtzassociates,项目名称:postgresql-8.2.23,代码行数:19,代码来源:int.c
示例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();
}
}
开发者ID:b-xiang,项目名称:gpdb,代码行数:19,代码来源:funcs.cpp
示例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);
}
开发者ID:sunyangkobe,项目名称:cscd43,代码行数:22,代码来源:float.c
示例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));
}
开发者ID:b-xiang,项目名称:gpdb,代码行数:19,代码来源:funcs.cpp
示例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);
}
开发者ID:JeremyGrosser,项目名称:postgis,代码行数:43,代码来源:lwgeom_inout.c
示例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);
}
开发者ID:FilipinOTech,项目名称:postgres,代码行数:28,代码来源:xlogfuncs.c
示例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();
}
开发者ID:WhiteCatmi,项目名称:orafce,代码行数:19,代码来源:alert.c
示例16: LWGEOM_asBinary
Datum LWGEOM_asBinary(PG_FUNCTION_ARGS)
{
GSERIALIZED *geom;
LWGEOM *lwgeom;
uint8_t *wkb;
size_t wkb_size;
bytea *result;
uint8_t variant = WKB_ISO;
/* Get a 2D version of the geometry */
geom = (GSERIALIZED*)PG_DETOAST_DATUM(PG_GETARG_DATUM(0));
lwgeom = lwgeom_from_gserialized(geom);
/* If user specified endianness, respect it */
if ( (PG_NARGS()>1) && (!PG_ARGISNULL(1)) )
{
text *wkb_endian = PG_GETARG_TEXT_P(1);
if ( ! strncmp(VARDATA(wkb_endian), "xdr", 3) ||
! strncmp(VARDATA(wkb_endian), "XDR", 3) )
{
variant = variant | WKB_XDR;
}
else
{
variant = variant | WKB_NDR;
}
}
/* Write to WKB and free the geometry */
wkb = lwgeom_to_wkb(lwgeom, variant, &wkb_size);
lwgeom_free(lwgeom);
/* Write to text and free the WKT */
result = palloc(wkb_size + VARHDRSZ);
memcpy(VARDATA(result), wkb, wkb_size);
SET_VARSIZE(result, wkb_size + VARHDRSZ);
pfree(wkb);
/* Return the text */
PG_FREE_IF_COPY(geom, 0);
PG_RETURN_BYTEA_P(result);
}
开发者ID:gravitystorm,项目名称:postgis,代码行数:43,代码来源:lwgeom_ogc.c
示例17: hashtext
Datum
hashtext(PG_FUNCTION_ARGS)
{
text *key = PG_GETARG_TEXT_P(0);
Datum result;
/*
* Note: this is currently identical in behavior to hashvarlena, but
* it seems likely that we may need to do something different in non-C
* locales. (See also hashbpchar, if so.)
*/
result = hash_any((unsigned char *) VARDATA(key),
VARSIZE(key) - VARHDRSZ);
/* Avoid leaking memory for toasted inputs */
PG_FREE_IF_COPY(key, 0);
return result;
}
开发者ID:sunyangkobe,项目名称:cscd43,代码行数:19,代码来源:hashfunc.c
示例18: sys_eval
extern PGDLLIMPORT Datum sys_eval(PG_FUNCTION_ARGS) {
#else
extern DLLIMPORT Datum sys_eval(PG_FUNCTION_ARGS) {
#endif
text *argv0 = PG_GETARG_TEXT_P(0);
text *result_text;
char *command;
char *result;
FILE *pipe;
char *line;
int32 outlen, linelen;
command = text_ptr_to_char_ptr(argv0);
/*
Only if you want to log
elog(NOTICE, "Command evaluated: %s", command);
*/
line = (char *)malloc(1024);
result = (char *)malloc(1);
outlen = 0;
pipe = popen(command, "r");
while (fgets(line, sizeof(line), pipe) != NULL) {
linelen = strlen(line);
result = (char *)realloc(result, outlen + linelen);
strncpy(result + outlen, line, linelen);
outlen = outlen + linelen;
}
pclose(pipe);
if (*result) {
result[outlen-1] = 0x00;
}
result_text = chr_ptr_to_text_ptr(result);
PG_RETURN_POINTER(result_text);
}
开发者ID:DavisHevin,项目名称:sqli_benchmark,代码行数:42,代码来源:lib_postgresqludf_sys.c
示例19: master_create_worker_shards
/*
* master_create_worker_shards is a user facing function to create worker shards
* for the given relation in round robin order.
*/
Datum
master_create_worker_shards(PG_FUNCTION_ARGS)
{
text *tableNameText = PG_GETARG_TEXT_P(0);
int32 shardCount = PG_GETARG_INT32(1);
int32 replicationFactor = PG_GETARG_INT32(2);
Oid distributedTableId = ResolveRelationId(tableNameText);
/* do not add any data */
bool useExclusiveConnections = false;
EnsureCoordinator();
CheckCitusVersion(ERROR);
CreateShardsWithRoundRobinPolicy(distributedTableId, shardCount, replicationFactor,
useExclusiveConnections);
PG_RETURN_VOID();
}
开发者ID:marcocitus,项目名称:citus,代码行数:24,代码来源:master_create_shards.c
示例20: copytext
Datum
copytext(PG_FUNCTION_ARGS)
{
text *t = PG_GETARG_TEXT_P(0);
/*
* VARSIZE is the total size of the struct in bytes.
*/
text *new_t = (text *) palloc(VARSIZE(t));
SET_VARSIZE(new_t, VARSIZE(t));
/*
* VARDATA is a pointer to the data region of the struct.
*/
memcpy((void *) VARDATA(new_t), /* destination */
(void *) VARDATA(t), /* source */
VARSIZE(t) - VARHDRSZ); /* how many bytes */
PG_RETURN_TEXT_P(new_t);
}
开发者ID:FilipinOTech,项目名称:postgres,代码行数:20,代码来源:funcs_new.c
注:本文中的PG_GETARG_TEXT_P函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论