本文整理汇总了C++中cstring_to_text_with_len函数的典型用法代码示例。如果您正苦于以下问题:C++ cstring_to_text_with_len函数的具体用法?C++ cstring_to_text_with_len怎么用?C++ cstring_to_text_with_len使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了cstring_to_text_with_len函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: 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
示例2: hstore_to_array_internal
static ArrayType *
hstore_to_array_internal(HStore *hs, int ndims)
{
HEntry *entries = ARRPTR(hs);
char *base = STRPTR(hs);
int count = HS_COUNT(hs);
int out_size[2] = {0, 2};
int lb[2] = {1, 1};
Datum *out_datums;
bool *out_nulls;
int i;
Assert(ndims < 3);
if (count == 0 || ndims == 0)
return construct_empty_array(TEXTOID);
out_size[0] = count * 2 / ndims;
out_datums = palloc(sizeof(Datum) * count * 2);
out_nulls = palloc(sizeof(bool) * count * 2);
for (i = 0; i < count; ++i)
{
text *key = cstring_to_text_with_len(HS_KEY(entries, base, i),
HS_KEYLEN(entries, i));
out_datums[i * 2] = PointerGetDatum(key);
out_nulls[i * 2] = false;
if (HS_VALISNULL(entries, i))
{
out_datums[i * 2 + 1] = (Datum) 0;
out_nulls[i * 2 + 1] = true;
}
else
{
text *item = cstring_to_text_with_len(HS_VAL(entries, base, i),
HS_VALLEN(entries, i));
out_datums[i * 2 + 1] = PointerGetDatum(item);
out_nulls[i * 2 + 1] = false;
}
}
return construct_md_array(out_datums, out_nulls,
ndims, out_size, lb,
TEXTOID, -1, false, 'i');
}
开发者ID:nathanwadhwani,项目名称:recdb-postgresql,代码行数:48,代码来源:hstore_op.c
示例3: 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
示例4: LogicalOutputWrite
/*
* Perform output plugin write into tuplestore.
*/
static void
LogicalOutputWrite(LogicalDecodingContext *ctx, XLogRecPtr lsn, TransactionId xid,
bool last_write)
{
Datum values[3];
bool nulls[3];
DecodingOutputState *p;
/* SQL Datums can only be of a limited length... */
if (ctx->out->len > MaxAllocSize - VARHDRSZ)
elog(ERROR, "too much output for sql interface");
p = (DecodingOutputState *) ctx->output_writer_private;
memset(nulls, 0, sizeof(nulls));
values[0] = LSNGetDatum(lsn);
values[1] = TransactionIdGetDatum(xid);
/*
* Assert ctx->out is in database encoding when we're writing textual
* output.
*/
if (!p->binary_output)
Assert(pg_verify_mbstr(GetDatabaseEncoding(),
ctx->out->data, ctx->out->len,
false));
/* ick, but cstring_to_text_with_len works for bytea perfectly fine */
values[2] = PointerGetDatum(
cstring_to_text_with_len(ctx->out->data, ctx->out->len));
tuplestore_putvalues(p->tupstore, p->tupdesc, values, nulls);
p->returned_rows++;
}
开发者ID:RingsC,项目名称:postgres,代码行数:37,代码来源:logicalfuncs.c
示例5: elements_array_element_end
static void
elements_array_element_end(void *state, bool isnull)
{
ElementsState _state = (ElementsState) state;
MemoryContext old_cxt;
int len;
text *val;
HeapTuple tuple;
Datum values[1];
static bool nulls[1] = {false};
/* skip over nested objects */
if (_state->lex->lex_level != 1)
return;
/* use the tmp context so we can clean up after each tuple is done */
old_cxt = MemoryContextSwitchTo(_state->tmp_cxt);
len = _state->lex->prev_token_terminator - _state->result_start;
val = cstring_to_text_with_len(_state->result_start, len);
values[0] = PointerGetDatum(val);
tuple = heap_form_tuple(_state->ret_tdesc, values, nulls);
tuplestore_puttuple(_state->tuple_store, tuple);
/* clean up and switch back */
MemoryContextSwitchTo(old_cxt);
MemoryContextReset(_state->tmp_cxt);
}
开发者ID:50wu,项目名称:gpdb,代码行数:31,代码来源:jsonfuncs.c
示例6: varchar2
/*
* Converts a VARCHAR2 type to the specified size.
*
* maxlen is the typmod, ie, declared length plus VARHDRSZ bytes.
* isExplicit is true if this is for an explicit cast to varchar2(N).
*
* Truncation rules: for an explicit cast, silently truncate to the given
* length; for an implicit cast, raise error if length limit is exceeded
*/
PGDLLEXPORT
Datum
varchar2(PG_FUNCTION_ARGS)
{
VarChar *source = PG_GETARG_VARCHAR_PP(0);
int32 typmod = PG_GETARG_INT32(1);
bool isExplicit = PG_GETARG_BOOL(2);
int32 len,
maxlen;
char *s_data;
len = VARSIZE_ANY_EXHDR(source);
s_data = VARDATA_ANY(source);
maxlen = typmod - VARHDRSZ;
/* No work if typmod is invalid or supplied data fits it already */
if (maxlen < 0 || len <= maxlen)
PG_RETURN_VARCHAR_P(source);
/* error out if value too long unless it's an explicit cast */
if (!isExplicit)
{
if (len > maxlen)
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("input value length is %d; too long for type varchar2(%d)",len ,maxlen)));
}
PG_RETURN_VARCHAR_P((VarChar *) cstring_to_text_with_len(s_data,maxlen));
}
开发者ID:asdliuquan,项目名称:orafce,代码行数:39,代码来源:varchar2.c
示例7: nvarchar2_input
static VarChar *
nvarchar2_input(const char *s, size_t len, int32 atttypmod)
{
VarChar *result; /* input data */
size_t maxlen;
maxlen = atttypmod - VARHDRSZ;
/*
* Perform the typmod check; error out if value too long for NVARCHAR2
*/
if (atttypmod >= (int32) VARHDRSZ && len > maxlen)
{
/* Verify that input length is within typmod limit.
*
* NOTE: blankspace is not truncated
*/
size_t mbmaxlen = pg_mbstrlen(s);
if (mbmaxlen > maxlen)
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("input value length is %zd; too long for type nvarchar2(%zd)", mbmaxlen , maxlen)));
}
result = (VarChar *) cstring_to_text_with_len(s, len);
return result;
}
开发者ID:KinoSun,项目名称:orafce,代码行数:28,代码来源:nvarchar2.c
示例8: gin_extract_tsvector
Datum
gin_extract_tsvector(PG_FUNCTION_ARGS)
{
TSVector vector = PG_GETARG_TSVECTOR(0);
int32 *nentries = (int32 *) PG_GETARG_POINTER(1);
Datum *entries = NULL;
*nentries = vector->size;
if (vector->size > 0)
{
int i;
WordEntry *we = ARRPTR(vector);
entries = (Datum *) palloc(sizeof(Datum) * vector->size);
for (i = 0; i < vector->size; i++)
{
text *txt;
txt = cstring_to_text_with_len(STRPTR(vector) + we->pos, we->len);
entries[i] = PointerGetDatum(txt);
we++;
}
}
PG_FREE_IF_COPY(vector, 0);
PG_RETURN_POINTER(entries);
}
开发者ID:bjornharrtell,项目名称:postgres,代码行数:29,代码来源:tsginidx.c
示例9: fsm_page_contents
Datum
fsm_page_contents(PG_FUNCTION_ARGS)
{
bytea *raw_page = PG_GETARG_BYTEA_P(0);
StringInfoData sinfo;
FSMPage fsmpage;
int i;
if (!superuser())
ereport(ERROR,
(errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
(errmsg("must be superuser to use raw page functions"))));
fsmpage = (FSMPage) PageGetContents(VARDATA(raw_page));
initStringInfo(&sinfo);
for (i = 0; i < NodesPerPage; i++)
{
if (fsmpage->fp_nodes[i] != 0)
appendStringInfo(&sinfo, "%d: %d\n", i, fsmpage->fp_nodes[i]);
}
appendStringInfo(&sinfo, "fp_next_slot: %d\n", fsmpage->fp_next_slot);
PG_RETURN_TEXT_P(cstring_to_text_with_len(sinfo.data, sinfo.len));
}
开发者ID:AlexHill,项目名称:postgres,代码行数:26,代码来源:fsmfuncs.c
示例10: dbms_pipe_unique_session_name
Datum
dbms_pipe_unique_session_name (PG_FUNCTION_ARGS)
{
StringInfoData strbuf;
text *result;
float8 endtime;
int cycle = 0;
int timeout = 10;
WATCH_PRE(timeout, endtime, cycle);
if (ora_lock_shmem(SHMEMMSGSZ, MAX_PIPES,MAX_EVENTS,MAX_LOCKS,false))
{
initStringInfo(&strbuf);
appendStringInfo(&strbuf,"PG$PIPE$%d$%d",sid, MyProcPid);
result = cstring_to_text_with_len(strbuf.data, strbuf.len);
pfree(strbuf.data);
LWLockRelease(shmem_lockid);
PG_RETURN_TEXT_P(result);
}
WATCH_POST(timeout, endtime, cycle);
LOCK_ERROR();
PG_RETURN_NULL();
}
开发者ID:orafce,项目名称:orafce,代码行数:27,代码来源:pipe.c
示例11: 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
示例12: 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
示例13: jsonb_pretty
/*
* jsonb_pretty:
* Pretty-printed text for the jsonb
*/
Datum
jsonb_pretty(PG_FUNCTION_ARGS)
{
Jsonb *jb = PG_GETARG_JSONB(0);
StringInfo str = makeStringInfo();
JsonbToCStringWorker(str, &jb->root, VARSIZE(jb), true);
PG_RETURN_TEXT_P(cstring_to_text_with_len(str->data, str->len));
}
开发者ID:dreamsxin,项目名称:jsonbx,代码行数:14,代码来源:jsonbx.c
示例14: uri_new
static HeapTuple uri_new(FunctionCallInfo fcinfo, const char *str, size_t len)
{
TupleDesc td;
struct uri_info u;
Datum d[URI_LEN];
bool n[URI_LEN];
if (!uri_parse(str, len, &u))
ereport(ERROR, (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
errmsg("invalid uri: \"%.*s\"", (int)len, str)));
if (!(n[URI_SCHEME] = !u.scheme))
d[URI_SCHEME] = PointerGetDatum(cstring_to_text_with_len(u.scheme, u.scheme_len));
if (!(n[URI_HOST] = !u.host))
d[URI_HOST] = PointerGetDatum(domainname_new(u.host, u.host_len));
if (!(n[URI_PORT] = u.port < 0))
d[URI_PORT] = Int16GetDatum(u.port);
if (!(n[URI_PATH] = !u.path))
d[URI_PATH] = PointerGetDatum(cstring_to_text_with_len(u.path, u.path_len));
get_call_result_type(fcinfo, NULL, &td);
return heap_form_tuple(BlessTupleDesc(td), d, n);
}
开发者ID:dylex,项目名称:huzblem,代码行数:22,代码来源:pguri.c
示例15: build_regexp_matches_result
/*
* build_regexp_matches_result - build output array for current match
*/
static ArrayType *
build_regexp_matches_result(regexp_matches_ctx *matchctx)
{
char *buf = matchctx->conv_buf;
int bufsiz PG_USED_FOR_ASSERTS_ONLY = matchctx->conv_bufsiz;
Datum *elems = matchctx->elems;
bool *nulls = matchctx->nulls;
int dims[1];
int lbs[1];
int loc;
int i;
/* Extract matching substrings from the original string */
loc = matchctx->next_match * matchctx->npatterns * 2;
for (i = 0; i < matchctx->npatterns; i++)
{
int so = matchctx->match_locs[loc++];
int eo = matchctx->match_locs[loc++];
if (so < 0 || eo < 0)
{
elems[i] = (Datum) 0;
nulls[i] = true;
}
else if (buf)
{
int len = pg_wchar2mb_with_len(matchctx->wide_str + so,
buf,
eo - so);
Assert(len < bufsiz);
elems[i] = PointerGetDatum(cstring_to_text_with_len(buf, len));
nulls[i] = false;
}
else
{
elems[i] = DirectFunctionCall3(text_substr,
PointerGetDatum(matchctx->orig_str),
Int32GetDatum(so + 1),
Int32GetDatum(eo - so));
nulls[i] = false;
}
}
/* And form an array */
dims[0] = matchctx->npatterns;
lbs[0] = 1;
/* XXX: this hardcodes assumptions about the text type */
return construct_md_array(elems, nulls, 1, dims, lbs,
TEXTOID, -1, false, 'i');
}
开发者ID:winlibs,项目名称:postgresql,代码行数:53,代码来源:regexp.c
示例16: comment_recv
Datum
comment_recv(PG_FUNCTION_ARGS)
{
StringInfo buf = (StringInfo) PG_GETARG_POINTER(0);
Comment *result;
char *str;
int nbytes;
str = pq_getmsgtext(buf, buf->len - buf->cursor, &nbytes);
result = cstring_to_text_with_len(str, nbytes);
pfree(str);
PG_RETURN_COMMENT_P(result);
}
开发者ID:zeray87,项目名称:gpdb,代码行数:14,代码来源:pg_comment.c
示例17: get_object_field_end
static void
get_object_field_end(void *state, char *fname, bool isnull)
{
GetState _state = (GetState) state;
bool get_last = false;
int lex_level = _state->lex->lex_level;
/* same tests as in get_object_field_start, mutatis mutandis */
if (lex_level == 1 && _state->search_type == JSON_SEARCH_OBJECT &&
strcmp(fname, _state->search_term) == 0)
{
get_last = true;
}
else if (_state->search_type == JSON_SEARCH_PATH &&
lex_level <= _state->npath &&
_state->pathok[lex_level - 1] &&
strcmp(fname, _state->path[lex_level - 1]) == 0)
{
/* done with this field so reset pathok */
if (lex_level < _state->npath)
_state->pathok[lex_level] = false;
if (lex_level == _state->npath)
get_last = true;
}
/* for as_test variants our work is already done */
if (get_last && _state->result_start != NULL)
{
/*
* make a text object from the string from the prevously noted json
* start up to the end of the previous token (the lexer is by now
* ahead of us on whatevere came after what we're interested in).
*/
int len = _state->lex->prev_token_terminator - _state->result_start;
if (isnull && _state->normalize_results)
_state->tresult = (text *) NULL;
else
_state->tresult = cstring_to_text_with_len(_state->result_start, len);
}
/*
* don't need to reset _state->result_start b/c we're only returning one
* datum, the conditions should not occur more than once, and this lets us
* check cheaply that they don't (see object_field_start() )
*/
}
开发者ID:50wu,项目名称:gpdb,代码行数:49,代码来源:jsonfuncs.c
示例18: quote_variant_name
Datum
quote_variant_name(PG_FUNCTION_ARGS)
{
StringInfo out;
char *variant_name;
Assert(fcinfo->flinfo->fn_strict); /* Must be strict */
variant_name = text_to_cstring(PG_GETARG_TEXT_PP(0));
out = quote_variant_name_cstring(variant_name);
/* out is wrapped in () which is not what we want, so we don't return it directly */
PG_RETURN_TEXT_P( cstring_to_text_with_len(out->data + 1, out->len-2) );
}
开发者ID:decibel,项目名称:variant,代码行数:16,代码来源:variant.c
示例19: each_object_field_end
static void
each_object_field_end(void *state, char *fname, bool isnull)
{
EachState _state = (EachState) state;
MemoryContext old_cxt;
int len;
text *val;
HeapTuple tuple;
Datum values[2];
bool nulls[2] = {false, false};
/* skip over nested objects */
if (_state->lex->lex_level != 1)
return;
/* use the tmp context so we can clean up after each tuple is done */
old_cxt = MemoryContextSwitchTo(_state->tmp_cxt);
values[0] = CStringGetTextDatum(fname);
if (isnull && _state->normalize_results)
{
nulls[1] = true;
values[1] = (Datum) NULL;
}
else if (_state->next_scalar)
{
values[1] = CStringGetTextDatum(_state->normalized_scalar);
_state->next_scalar = false;
}
else
{
len = _state->lex->prev_token_terminator - _state->result_start;
val = cstring_to_text_with_len(_state->result_start, len);
values[1] = PointerGetDatum(val);
}
tuple = heap_form_tuple(_state->ret_tdesc, values, nulls);
tuplestore_puttuple(_state->tuple_store, tuple);
/* clean up and switch back */
MemoryContextSwitchTo(old_cxt);
MemoryContextReset(_state->tmp_cxt);
}
开发者ID:50wu,项目名称:gpdb,代码行数:46,代码来源:jsonfuncs.c
示例20: hstore_svals
Datum
hstore_svals(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);
if (HS_VALISNULL(entries, i))
{
ReturnSetInfo *rsi;
/* ugly ugly ugly. why no macro for this? */
(funcctx)->call_cntr++;
rsi = (ReturnSetInfo *) fcinfo->resultinfo;
rsi->isDone = ExprMultipleResult;
PG_RETURN_NULL();
}
else
{
text *item;
item = cstring_to_text_with_len(HS_VAL(entries, STRPTR(hs), i),
HS_VALLEN(entries, i));
SRF_RETURN_NEXT(funcctx, PointerGetDatum(item));
}
}
SRF_RETURN_DONE(funcctx);
}
开发者ID:nathanwadhwani,项目名称:recdb-postgresql,代码行数:45,代码来源:hstore_op.c
注:本文中的cstring_to_text_with_len函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论