本文整理汇总了C++中PG_GETARG_TEXT_PP函数的典型用法代码示例。如果您正苦于以下问题:C++ PG_GETARG_TEXT_PP函数的具体用法?C++ PG_GETARG_TEXT_PP怎么用?C++ PG_GETARG_TEXT_PP使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了PG_GETARG_TEXT_PP函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: plvstr_lstrip
Datum
plvstr_lstrip (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);
while (count < num)
{
pat_p = VARDATA_ANY(pat);
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(str_p,len_s));
}
示例2: tsa_set_curcfg_byname
/* set_curcfg(text) */
Datum
tsa_set_curcfg_byname(PG_FUNCTION_ARGS)
{
text *arg0 = PG_GETARG_TEXT_PP(0);
char *name;
name = text_to_cstring(arg0);
SetConfigOption("default_text_search_config", name,
PGC_USERSET, PGC_S_SESSION);
PG_RETURN_VOID();
}
示例3: pgstattuple_v1_5
/*
* As of pgstattuple version 1.5, we no longer need to check if the user
* is a superuser because we REVOKE EXECUTE on the function from PUBLIC.
* Users can then grant access to it based on their policies.
*
* Otherwise identical to pgstattuple (above).
*/
Datum
pgstattuple_v1_5(PG_FUNCTION_ARGS)
{
text *relname = PG_GETARG_TEXT_PP(0);
RangeVar *relrv;
Relation rel;
/* open relation */
relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
rel = relation_openrv(relrv, AccessShareLock);
PG_RETURN_DATUM(pgstat_relation(rel, fcinfo));
}
示例4: dblink_connect
/*
* dblink_connect(server text) : boolean
*/
Datum
dblink_connect(PG_FUNCTION_ARGS)
{
text *name = PG_GETARG_TEXT_PP(0);
Conn *conn;
bool isNew;
conn = doConnect(name, name, &isNew);
conn->use_xa = PG_GETARG_BOOL(1);
conn->keep = true;
PG_RETURN_BOOL(isNew);
}
示例5: nameregexne
Datum
nameregexne(PG_FUNCTION_ARGS)
{
Name n = PG_GETARG_NAME(0);
text *p = PG_GETARG_TEXT_PP(1);
PG_RETURN_BOOL(!RE_compile_and_execute(p,
NameStr(*n),
strlen(NameStr(*n)),
REG_ADVANCED,
PG_GET_COLLATION(),
0, NULL));
}
示例6: pg_index_column_has_property
/*
* Test property of an index column specified by index OID and column number
*/
Datum
pg_index_column_has_property(PG_FUNCTION_ARGS)
{
Oid relid = PG_GETARG_OID(0);
int32 attno = PG_GETARG_INT32(1);
char *propname = text_to_cstring(PG_GETARG_TEXT_PP(2));
/* Reject attno 0 immediately, so that attno > 0 identifies this case */
if (attno <= 0)
PG_RETURN_NULL();
return indexam_property(fcinfo, propname, InvalidOid, relid, attno);
}
示例7: lo_import
/*
* lo_import -
* imports a file as an (inversion) large object.
*/
Datum
lo_import(PG_FUNCTION_ARGS)
{
text *filename = PG_GETARG_TEXT_PP(0);
#ifdef PGXC
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("Postgres-XC does not support large object yet"),
errdetail("The feature is not currently supported")));
#endif
PG_RETURN_OID(lo_import_internal(filename, InvalidOid));
}
示例8: levenshtein_less_equal
Datum
levenshtein_less_equal(PG_FUNCTION_ARGS)
{
text *src = PG_GETARG_TEXT_PP(0);
text *dst = PG_GETARG_TEXT_PP(1);
int max_d = PG_GETARG_INT32(2);
const char *s_data;
const char *t_data;
int s_bytes,
t_bytes;
/* Extract a pointer to the actual character data */
s_data = VARDATA_ANY(src);
t_data = VARDATA_ANY(dst);
/* Determine length of each string in bytes */
s_bytes = VARSIZE_ANY_EXHDR(src);
t_bytes = VARSIZE_ANY_EXHDR(dst);
PG_RETURN_INT32(varstr_levenshtein_less_equal(s_data, s_bytes,
t_data, t_bytes,
1, 1, 1,
max_d, false));
}
示例9: nameicnlike
Datum
nameicnlike(PG_FUNCTION_ARGS)
{
Name str = PG_GETARG_NAME(0);
text *pat = PG_GETARG_TEXT_PP(1);
bool result;
text *strtext;
strtext = DatumGetTextP(DirectFunctionCall1(name_text,
NameGetDatum(str)));
result = (Generic_Text_IC_like(strtext, pat, PG_GET_COLLATION()) != LIKE_TRUE);
PG_RETURN_BOOL(result);
}
示例10: levenshtein_with_costs
Datum
levenshtein_with_costs(PG_FUNCTION_ARGS)
{
text *src = PG_GETARG_TEXT_PP(0);
text *dst = PG_GETARG_TEXT_PP(1);
int ins_c = PG_GETARG_INT32(2);
int del_c = PG_GETARG_INT32(3);
int sub_c = PG_GETARG_INT32(4);
const char *s_data;
const char *t_data;
int s_bytes,
t_bytes;
/* Extract a pointer to the actual character data */
s_data = VARDATA_ANY(src);
t_data = VARDATA_ANY(dst);
/* Determine length of each string in bytes and characters */
s_bytes = VARSIZE_ANY_EXHDR(src);
t_bytes = VARSIZE_ANY_EXHDR(dst);
PG_RETURN_INT32(varstr_levenshtein(s_data, s_bytes, t_data, t_bytes, ins_c,
del_c, sub_c));
}
示例11: pg_decrypt_iv
Datum
pg_decrypt_iv(PG_FUNCTION_ARGS)
{
int err;
bytea *data,
*key,
*iv,
*res;
text *type;
PX_Combo *c;
unsigned dlen,
klen,
rlen,
ivlen;
type = PG_GETARG_TEXT_PP(3);
c = find_provider(type, (PFN) px_find_combo, "Cipher", 0);
data = PG_GETARG_BYTEA_PP(0);
key = PG_GETARG_BYTEA_PP(1);
iv = PG_GETARG_BYTEA_PP(2);
dlen = VARSIZE_ANY_EXHDR(data);
klen = VARSIZE_ANY_EXHDR(key);
ivlen = VARSIZE_ANY_EXHDR(iv);
rlen = px_combo_decrypt_len(c, dlen);
res = palloc(VARHDRSZ + rlen);
err = px_combo_init(c, (uint8 *) VARDATA_ANY(key), klen,
(uint8 *) VARDATA_ANY(iv), ivlen);
if (!err)
err = px_combo_decrypt(c, (uint8 *) VARDATA_ANY(data), dlen,
(uint8 *) VARDATA(res), &rlen);
px_combo_free(c);
if (err)
ereport(ERROR,
(errcode(ERRCODE_EXTERNAL_ROUTINE_INVOCATION_EXCEPTION),
errmsg("decrypt_iv 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(iv, 2);
PG_FREE_IF_COPY(type, 3);
PG_RETURN_BYTEA_P(res);
}
示例12: gin_cmp_prefix
Datum
gin_cmp_prefix(PG_FUNCTION_ARGS)
{
text *a = PG_GETARG_TEXT_PP(0);
text *b = PG_GETARG_TEXT_PP(1);
#ifdef NOT_USED
StrategyNumber strategy = PG_GETARG_UINT16(2);
Pointer extra_data = PG_GETARG_POINTER(3);
#endif
int cmp;
cmp = tsCompareString(VARDATA_ANY(a), VARSIZE_ANY_EXHDR(a),
VARDATA_ANY(b), VARSIZE_ANY_EXHDR(b),
true);
if (cmp < 0)
cmp = 1; /* prevent continue scan */
PG_FREE_IF_COPY(a, 0);
PG_FREE_IF_COPY(b, 1);
PG_RETURN_INT32(cmp);
}
示例13: ts_parse_byname
Datum
ts_parse_byname(PG_FUNCTION_ARGS)
{
FuncCallContext *funcctx;
Datum result;
if (SRF_IS_FIRSTCALL())
{
text *prsname = PG_GETARG_TEXT_PP(0);
text *txt = PG_GETARG_TEXT_PP(1);
Oid prsId;
funcctx = SRF_FIRSTCALL_INIT();
prsId = get_ts_parser_oid(textToQualifiedNameList(prsname), false);
prs_setup_firstcall(funcctx, prsId, txt);
}
funcctx = SRF_PERCALL_SETUP();
if ((result = prs_process_call(funcctx)) != (Datum) 0)
SRF_RETURN_NEXT(funcctx, result);
SRF_RETURN_DONE(funcctx);
}
示例14: ora_date_round
Datum
ora_date_round(PG_FUNCTION_ARGS)
{
DateADT day = PG_GETARG_DATEADT(0);
text *fmt = PG_GETARG_TEXT_PP(1);
DateADT result;
int f = ora_seq_search(VARDATA_ANY(fmt), date_fmt, VARSIZE_ANY_EXHDR(fmt));
CHECK_SEQ_SEARCH(f, "round/trunc format string");
result = _ora_date_round(day, f);
PG_RETURN_DATEADT(result);
}
示例15: jsonb_delete
/*
* jsonb_delete:
* Return copy of jsonb with the specified item removed.
* Item is a one key or element from jsonb, specified by name.
* If there are many keys or elements with than name,
* the first one will be removed.
*/
Datum
jsonb_delete(PG_FUNCTION_ARGS)
{
Jsonb *in = PG_GETARG_JSONB(0);
text *key = PG_GETARG_TEXT_PP(1);
char *keyptr = VARDATA_ANY(key);
int keylen = VARSIZE_ANY_EXHDR(key);
JsonbParseState *state = NULL;
JsonbIterator *it;
uint32 r;
JsonbValue v, *res = NULL;
bool skipped = false;
if (JB_ROOT_IS_SCALAR(in))
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("cannot delete from scalar")));
if (JB_ROOT_COUNT(in) == 0)
{
PG_RETURN_JSONB(in);
}
it = JsonbIteratorInit(&in->root);
while((r = JsonbIteratorNext(&it, &v, false)) != 0)
{
if (!skipped && (r == WJB_ELEM || r == WJB_KEY) &&
(v.type == jbvString && keylen == v.val.string.len &&
memcmp(keyptr, v.val.string.val, keylen) == 0))
{
/* we should delete only one key/element */
skipped = true;
if (r == WJB_KEY)
{
/* skip corresponding value */
JsonbIteratorNext(&it, &v, true);
}
continue;
}
res = pushJsonbValue(&state, r, r < WJB_BEGIN_ARRAY ? &v : NULL);
}
Assert(res != NULL);
PG_RETURN_JSONB(JsonbValueToJsonb(res));
}