本文整理汇总了C++中PG_GETARG_HS函数的典型用法代码示例。如果您正苦于以下问题:C++ PG_GETARG_HS函数的具体用法?C++ PG_GETARG_HS怎么用?C++ PG_GETARG_HS使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了PG_GETARG_HS函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: hstore_to_plpython
Datum
hstore_to_plpython(PG_FUNCTION_ARGS)
{
HStore *in = PG_GETARG_HS(0);
int i;
int count = HS_COUNT(in);
char *base = STRPTR(in);
HEntry *entries = ARRPTR(in);
PyObject *dict;
dict = PyDict_New();
for (i = 0; i < count; i++)
{
PyObject *key;
key = PyString_FromStringAndSize(HSTORE_KEY(entries, base, i),
HSTORE_KEYLEN(entries, i));
if (HSTORE_VALISNULL(entries, i))
PyDict_SetItem(dict, key, Py_None);
else
{
PyObject *value;
value = PyString_FromStringAndSize(HSTORE_VAL(entries, base, i),
HSTORE_VALLEN(entries, i));
PyDict_SetItem(dict, key, value);
Py_XDECREF(value);
}
Py_XDECREF(key);
}
return PointerGetDatum(dict);
}
开发者ID:BertrandAreal,项目名称:postgres,代码行数:34,代码来源:hstore_plpython.c
示例2: gin_extract_hstore
Datum
gin_extract_hstore(PG_FUNCTION_ARGS)
{
HStore *hs = PG_GETARG_HS(0);
int32 *nentries = (int32 *) PG_GETARG_POINTER(1);
Datum *entries = NULL;
HEntry *hsent = ARRPTR(hs);
char *ptr = STRPTR(hs);
int count = HS_COUNT(hs);
int i;
*nentries = 2 * count;
if (count)
entries = (Datum *) palloc(sizeof(Datum) * 2 * count);
for (i = 0; i < count; ++i)
{
text *item;
item = makeitem(HS_KEY(hsent, ptr, i), HS_KEYLEN(hsent, i),
KEYFLAG);
entries[2 * i] = PointerGetDatum(item);
if (HS_VALISNULL(hsent, i))
item = makeitem(NULL, 0, NULLFLAG);
else
item = makeitem(HS_VAL(hsent, ptr, i), HS_VALLEN(hsent, i),
VALFLAG);
entries[2 * i + 1] = PointerGetDatum(item);
}
PG_RETURN_POINTER(entries);
}
开发者ID:BioBD,项目名称:Hypothetical_Indexes,代码行数:33,代码来源:hstore_gin.c
示例3: hstore_exists_all
Datum
hstore_exists_all(PG_FUNCTION_ARGS)
{
HStore *hs = PG_GETARG_HS(0);
ArrayType *keys = PG_GETARG_ARRAYTYPE_P(1);
int nkeys;
Pairs *key_pairs = hstoreArrayToPairs(keys, &nkeys);
int i;
int lowbound = 0;
bool res = true;
/*
* we exploit the fact that the pairs list is already sorted into strictly
* increasing order to narrow the hstoreFindKey search; each search can
* start one entry past the previous "found" entry, or at the lower bound
* of the last search.
*/
for (i = 0; i < nkeys; i++)
{
int idx = hstoreFindKey(hs, &lowbound,
key_pairs[i].key, key_pairs[i].keylen);
if (idx < 0)
{
res = false;
break;
}
}
PG_RETURN_BOOL(res);
}
开发者ID:nathanwadhwani,项目名称:recdb-postgresql,代码行数:31,代码来源:hstore_op.c
示例4: hstore_send
Datum
hstore_send(PG_FUNCTION_ARGS)
{
HStore *in = PG_GETARG_HS(0);
int i;
int count = HS_COUNT(in);
char *base = STRPTR(in);
HEntry *entries = ARRPTR(in);
StringInfoData buf;
pq_begintypsend(&buf);
pq_sendint(&buf, count, 4);
for (i = 0; i < count; i++)
{
int32 keylen = HS_KEYLEN(entries, i);
pq_sendint(&buf, keylen, 4);
pq_sendtext(&buf, HS_KEY(entries, base, i), keylen);
if (HS_VALISNULL(entries, i))
{
pq_sendint(&buf, -1, 4);
}
else
{
int32 vallen = HS_VALLEN(entries, i);
pq_sendint(&buf, vallen, 4);
pq_sendtext(&buf, HS_VAL(entries, base, i), vallen);
}
}
PG_RETURN_BYTEA_P(pq_endtypsend(&buf));
}
开发者ID:d,项目名称:gpdb,代码行数:35,代码来源:hstore_io.c
示例5: hstore_slice_to_array
Datum
hstore_slice_to_array(PG_FUNCTION_ARGS)
{
HStore *hs = PG_GETARG_HS(0);
HEntry *entries = ARRPTR(hs);
char *ptr = STRPTR(hs);
ArrayType *key_array = PG_GETARG_ARRAYTYPE_P(1);
ArrayType *aout;
Datum *key_datums;
bool *key_nulls;
Datum *out_datums;
bool *out_nulls;
int key_count;
int i;
deconstruct_array(key_array,
TEXTOID, -1, false, 'i',
&key_datums, &key_nulls, &key_count);
if (key_count == 0)
{
aout = construct_empty_array(TEXTOID);
PG_RETURN_POINTER(aout);
}
out_datums = palloc(sizeof(Datum) * key_count);
out_nulls = palloc(sizeof(bool) * key_count);
for (i = 0; i < key_count; ++i)
{
text *key = (text *) DatumGetPointer(key_datums[i]);
int idx;
if (key_nulls[i])
idx = -1;
else
idx = hstoreFindKey(hs, NULL, VARDATA(key), VARSIZE(key) - VARHDRSZ);
if (idx < 0 || HS_VALISNULL(entries, idx))
{
out_nulls[i] = true;
out_datums[i] = (Datum) 0;
}
else
{
out_datums[i] = PointerGetDatum(
cstring_to_text_with_len(HS_VAL(entries, ptr, idx),
HS_VALLEN(entries, idx)));
out_nulls[i] = false;
}
}
aout = construct_md_array(out_datums, out_nulls,
ARR_NDIM(key_array),
ARR_DIMS(key_array),
ARR_LBOUND(key_array),
TEXTOID, -1, false, 'i');
PG_RETURN_POINTER(aout);
}
开发者ID:nathanwadhwani,项目名称:recdb-postgresql,代码行数:60,代码来源:hstore_op.c
示例6: hstore_skeys
Datum
hstore_skeys(PG_FUNCTION_ARGS)
{
FuncCallContext *funcctx;
HStore *hs;
int i;
if (SRF_IS_FIRSTCALL())
{
hs = PG_GETARG_HS(0);
funcctx = SRF_FIRSTCALL_INIT();
setup_firstcall(funcctx, hs, NULL);
}
funcctx = SRF_PERCALL_SETUP();
hs = (HStore *) funcctx->user_fctx;
i = funcctx->call_cntr;
if (i < HS_COUNT(hs))
{
HEntry *entries = ARRPTR(hs);
text *item;
item = cstring_to_text_with_len(HS_KEY(entries, STRPTR(hs), i),
HS_KEYLEN(entries, i));
SRF_RETURN_NEXT(funcctx, PointerGetDatum(item));
}
SRF_RETURN_DONE(funcctx);
}
开发者ID:nathanwadhwani,项目名称:recdb-postgresql,代码行数:31,代码来源:hstore_op.c
示例7: hstore_to_plperl
Datum
hstore_to_plperl(PG_FUNCTION_ARGS)
{
HStore *in = PG_GETARG_HS(0);
int i;
int count = HS_COUNT(in);
char *base = STRPTR(in);
HEntry *entries = ARRPTR(in);
HV *hv;
hv = newHV();
for (i = 0; i < count; i++)
{
const char *key;
SV *value;
key = pnstrdup(HS_KEY(entries, base, i), HS_KEYLEN(entries, i));
value = HS_VALISNULL(entries, i) ? newSV(0) : cstr2sv(pnstrdup(HS_VAL(entries, base, i), HS_VALLEN(entries, i)));
(void) hv_store(hv, key, strlen(key), value, 0);
}
return PointerGetDatum(newRV((SV *) hv));
}
开发者ID:DBInsight,项目名称:postgres,代码行数:25,代码来源:hstore_plperl.c
示例8: skeys
Datum
skeys(PG_FUNCTION_ARGS)
{
FuncCallContext *funcctx;
AKStore *st;
if (SRF_IS_FIRSTCALL())
{
HStore *hs = PG_GETARG_HS(0);
funcctx = SRF_FIRSTCALL_INIT();
setup_firstcall(funcctx, hs);
PG_FREE_IF_COPY(hs, 0);
}
funcctx = SRF_PERCALL_SETUP();
st = (AKStore *) funcctx->user_fctx;
if (st->i < st->hs->size)
{
HEntry *ptr = &(ARRPTR(st->hs)[st->i]);
text *item = (text *) palloc(VARHDRSZ + ptr->keylen);
SET_VARSIZE(item, VARHDRSZ + ptr->keylen);
memcpy(VARDATA(item), STRPTR(st->hs) + ptr->pos, ptr->keylen);
st->i++;
SRF_RETURN_NEXT(funcctx, PointerGetDatum(item));
}
pfree(st->hs);
pfree(st);
SRF_RETURN_DONE(funcctx);
}
开发者ID:AnLingm,项目名称:gpdb,代码行数:35,代码来源:hstore_op.c
示例9: hstore_akeys
Datum
hstore_akeys(PG_FUNCTION_ARGS)
{
HStore *hs = PG_GETARG_HS(0);
Datum *d;
ArrayType *a;
HEntry *entries = ARRPTR(hs);
char *base = STRPTR(hs);
int count = HS_COUNT(hs);
int i;
if (count == 0)
{
a = construct_empty_array(TEXTOID);
PG_RETURN_POINTER(a);
}
d = (Datum *) palloc(sizeof(Datum) * count);
for (i = 0; i < count; ++i)
{
text *item = cstring_to_text_with_len(HS_KEY(entries, base, i),
HS_KEYLEN(entries, i));
d[i] = PointerGetDatum(item);
}
a = construct_array(d, count,
TEXTOID, -1, false, 'i');
PG_RETURN_POINTER(a);
}
开发者ID:nathanwadhwani,项目名称:recdb-postgresql,代码行数:32,代码来源:hstore_op.c
示例10: hstore_to_matrix
Datum
hstore_to_matrix(PG_FUNCTION_ARGS)
{
HStore *hs = PG_GETARG_HS(0);
ArrayType *out = hstore_to_array_internal(hs, 2);
PG_RETURN_POINTER(out);
}
开发者ID:nathanwadhwani,项目名称:recdb-postgresql,代码行数:8,代码来源:hstore_op.c
示例11: hstore_slice_to_hstore
Datum
hstore_slice_to_hstore(PG_FUNCTION_ARGS)
{
HStore *hs = PG_GETARG_HS(0);
HEntry *entries = ARRPTR(hs);
char *ptr = STRPTR(hs);
ArrayType *key_array = PG_GETARG_ARRAYTYPE_P(1);
HStore *out;
int nkeys;
Pairs *key_pairs = hstoreArrayToPairs(key_array, &nkeys);
Pairs *out_pairs;
int bufsiz;
int lastidx = 0;
int i;
int out_count = 0;
if (nkeys == 0)
{
out = hstorePairs(NULL, 0, 0);
PG_RETURN_POINTER(out);
}
out_pairs = palloc(sizeof(Pairs) * nkeys);
bufsiz = 0;
/*
* we exploit the fact that the pairs list is already sorted into strictly
* increasing order to narrow the hstoreFindKey search; each search can
* start one entry past the previous "found" entry, or at the lower bound
* of the last search.
*/
for (i = 0; i < nkeys; ++i)
{
int idx = hstoreFindKey(hs, &lastidx,
key_pairs[i].key, key_pairs[i].keylen);
if (idx >= 0)
{
out_pairs[out_count].key = key_pairs[i].key;
bufsiz += (out_pairs[out_count].keylen = key_pairs[i].keylen);
out_pairs[out_count].val = HS_VAL(entries, ptr, idx);
bufsiz += (out_pairs[out_count].vallen = HS_VALLEN(entries, idx));
out_pairs[out_count].isnull = HS_VALISNULL(entries, idx);
out_pairs[out_count].needfree = false;
++out_count;
}
}
/*
* we don't use uniquePairs here because we know that the pairs list is
* already sorted and uniq'ed.
*/
out = hstorePairs(out_pairs, out_count, bufsiz);
PG_RETURN_POINTER(out);
}
开发者ID:nathanwadhwani,项目名称:recdb-postgresql,代码行数:58,代码来源:hstore_op.c
示例12: hstore_exists
Datum
hstore_exists(PG_FUNCTION_ARGS)
{
HStore *hs = PG_GETARG_HS(0);
text *key = PG_GETARG_TEXT_PP(1);
int idx = hstoreFindKey(hs, NULL,
VARDATA_ANY(key), VARSIZE_ANY_EXHDR(key));
PG_RETURN_BOOL(idx >= 0);
}
开发者ID:nathanwadhwani,项目名称:recdb-postgresql,代码行数:10,代码来源:hstore_op.c
示例13: hstore_contains
Datum
hstore_contains(PG_FUNCTION_ARGS)
{
HStore *val = PG_GETARG_HS(0);
HStore *tmpl = PG_GETARG_HS(1);
bool res = true;
HEntry *te = ARRPTR(tmpl);
char *tstr = STRPTR(tmpl);
HEntry *ve = ARRPTR(val);
char *vstr = STRPTR(val);
int tcount = HS_COUNT(tmpl);
int lastidx = 0;
int i;
/*
* we exploit the fact that keys in "tmpl" are in strictly increasing
* order to narrow the hstoreFindKey search; each search can start one
* entry past the previous "found" entry, or at the lower bound of the
* search
*/
for (i = 0; res && i < tcount; ++i)
{
int idx = hstoreFindKey(val, &lastidx,
HS_KEY(te, tstr, i), HS_KEYLEN(te, i));
if (idx >= 0)
{
bool nullval = HS_VALISNULL(te, i);
int vallen = HS_VALLEN(te, i);
if (nullval != HS_VALISNULL(ve, idx)
|| (!nullval
&& (vallen != HS_VALLEN(ve, idx)
|| memcmp(HS_VAL(te, tstr, i), HS_VAL(ve, vstr, idx), vallen))))
res = false;
}
else
res = false;
}
PG_RETURN_BOOL(res);
}
开发者ID:nathanwadhwani,项目名称:recdb-postgresql,代码行数:43,代码来源:hstore_op.c
示例14: hstore_out
Datum
hstore_out(PG_FUNCTION_ARGS)
{
HStore *in = PG_GETARG_HS(0);
int buflen,
i;
char *out,
*ptr;
char *base = STRPTR(in);
HEntry *entries = ARRPTR(in);
if (in->size == 0)
{
out = palloc(1);
*out = '\0';
PG_FREE_IF_COPY(in, 0);
PG_RETURN_CSTRING(out);
}
buflen = (4 /* " */ + 2 /* => */ + 2 /* , */ ) * in->size +
2 /* esc */ * (in->len - CALCDATASIZE(in->size, 0));
out = ptr = palloc(buflen);
for (i = 0; i < in->size; i++)
{
*ptr++ = '"';
ptr = cpw(ptr, base + entries[i].pos, entries[i].keylen);
*ptr++ = '"';
*ptr++ = '=';
*ptr++ = '>';
if (entries[i].valisnull)
{
*ptr++ = 'N';
*ptr++ = 'U';
*ptr++ = 'L';
*ptr++ = 'L';
}
else
{
*ptr++ = '"';
ptr = cpw(ptr, base + entries[i].pos + entries[i].keylen, entries[i].vallen);
*ptr++ = '"';
}
if (i + 1 != in->size)
{
*ptr++ = ',';
*ptr++ = ' ';
}
}
*ptr = '\0';
PG_FREE_IF_COPY(in, 0);
PG_RETURN_CSTRING(out);
}
开发者ID:berkeley-cs186,项目名称:course-fa07,代码行数:55,代码来源:hstore_io.c
示例15: hstore_defined
Datum
hstore_defined(PG_FUNCTION_ARGS)
{
HStore *hs = PG_GETARG_HS(0);
text *key = PG_GETARG_TEXT_PP(1);
HEntry *entries = ARRPTR(hs);
int idx = hstoreFindKey(hs, NULL,
VARDATA_ANY(key), VARSIZE_ANY_EXHDR(key));
bool res = (idx >= 0 && !HS_VALISNULL(entries, idx));
PG_RETURN_BOOL(res);
}
开发者ID:nathanwadhwani,项目名称:recdb-postgresql,代码行数:12,代码来源:hstore_op.c
示例16: hstore_each
Datum
hstore_each(PG_FUNCTION_ARGS)
{
FuncCallContext *funcctx;
HStore *hs;
int i;
if (SRF_IS_FIRSTCALL())
{
hs = PG_GETARG_HS(0);
funcctx = SRF_FIRSTCALL_INIT();
setup_firstcall(funcctx, hs, fcinfo);
}
funcctx = SRF_PERCALL_SETUP();
hs = (HStore *) funcctx->user_fctx;
i = funcctx->call_cntr;
if (i < HS_COUNT(hs))
{
HEntry *entries = ARRPTR(hs);
char *ptr = STRPTR(hs);
Datum res,
dvalues[2];
bool nulls[2] = {false, false};
text *item;
HeapTuple tuple;
item = cstring_to_text_with_len(HS_KEY(entries, ptr, i),
HS_KEYLEN(entries, i));
dvalues[0] = PointerGetDatum(item);
if (HS_VALISNULL(entries, i))
{
dvalues[1] = (Datum) 0;
nulls[1] = true;
}
else
{
item = cstring_to_text_with_len(HS_VAL(entries, ptr, i),
HS_VALLEN(entries, i));
dvalues[1] = PointerGetDatum(item);
}
tuple = heap_form_tuple(funcctx->tuple_desc, dvalues, nulls);
res = HeapTupleGetDatum(tuple);
SRF_RETURN_NEXT(funcctx, PointerGetDatum(res));
}
SRF_RETURN_DONE(funcctx);
}
开发者ID:nathanwadhwani,项目名称:recdb-postgresql,代码行数:52,代码来源:hstore_op.c
示例17: svals
Datum
svals(PG_FUNCTION_ARGS)
{
FuncCallContext *funcctx;
AKStore *st;
if (SRF_IS_FIRSTCALL())
{
HStore *hs = PG_GETARG_HS(0);
funcctx = SRF_FIRSTCALL_INIT();
setup_firstcall(funcctx, hs);
PG_FREE_IF_COPY(hs, 0);
}
funcctx = SRF_PERCALL_SETUP();
st = (AKStore *) funcctx->user_fctx;
if (st->i < st->hs->size)
{
HEntry *ptr = &(ARRPTR(st->hs)[st->i]);
if (ptr->valisnull)
{
ReturnSetInfo *rsi;
st->i++;
(funcctx)->call_cntr++;
rsi = (ReturnSetInfo *) fcinfo->resultinfo;
rsi->isDone = ExprMultipleResult;
PG_RETURN_NULL();
}
else
{
int vallen = ptr->vallen;
text *item = (text *) palloc(VARHDRSZ + vallen);
SET_VARSIZE(item, VARHDRSZ + vallen);
memcpy(VARDATA(item), STRPTR(st->hs) + ptr->pos + ptr->keylen, vallen);
st->i++;
SRF_RETURN_NEXT(funcctx, PointerGetDatum(item));
}
}
pfree(st->hs);
pfree(st);
SRF_RETURN_DONE(funcctx);
}
开发者ID:AnLingm,项目名称:gpdb,代码行数:50,代码来源:hstore_op.c
示例18: exists
Datum
exists(PG_FUNCTION_ARGS)
{
HStore *hs = PG_GETARG_HS(0);
text *key = PG_GETARG_TEXT_P(1);
HEntry *entry;
entry = findkey(hs, VARDATA(key), VARSIZE(key) - VARHDRSZ);
PG_FREE_IF_COPY(hs, 0);
PG_FREE_IF_COPY(key, 1);
PG_RETURN_BOOL(entry);
}
开发者ID:AnLingm,项目名称:gpdb,代码行数:14,代码来源:hstore_op.c
示例19: hs_contains
Datum
hs_contains(PG_FUNCTION_ARGS)
{
HStore *val = PG_GETARG_HS(0);
HStore *tmpl = PG_GETARG_HS(1);
bool res = true;
HEntry *te = ARRPTR(tmpl);
char *vv = STRPTR(val);
char *tv = STRPTR(tmpl);
while (res && te - ARRPTR(tmpl) < tmpl->size)
{
HEntry *entry = findkey(val, tv + te->pos, te->keylen);
if (entry)
{
if (te->valisnull || entry->valisnull)
{
if (!(te->valisnull && entry->valisnull))
res = false;
}
else if (te->vallen != entry->vallen ||
strncmp(vv + entry->pos + entry->keylen,
tv + te->pos + te->keylen,
te->vallen))
res = false;
}
else
res = false;
te++;
}
PG_FREE_IF_COPY(val, 0);
PG_FREE_IF_COPY(tmpl, 1);
PG_RETURN_BOOL(res);
}
开发者ID:AnLingm,项目名称:gpdb,代码行数:37,代码来源:hstore_op.c
示例20: exists
Datum
exists(PG_FUNCTION_ARGS)
{
HStore *hs = PG_GETARG_HS(0);
text *key = PG_GETARG_TEXT_P(1);
HEntry *entry;
bool res;
entry = findkey(hs, VARDATA(key), VARSIZE(key) - VARHDRSZ);
res = (entry != NULL) ? true : false;
PG_FREE_IF_COPY(hs, 0);
PG_FREE_IF_COPY(key, 1);
PG_RETURN_BOOL(res);
}
开发者ID:50wu,项目名称:gpdb,代码行数:16,代码来源:hstore_op.c
注:本文中的PG_GETARG_HS函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论