本文整理汇总了C++中pg_database_encoding_max_length函数的典型用法代码示例。如果您正苦于以下问题:C++ pg_database_encoding_max_length函数的具体用法?C++ pg_database_encoding_max_length怎么用?C++ pg_database_encoding_max_length使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了pg_database_encoding_max_length函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: show_trgm
Datum
show_trgm(PG_FUNCTION_ARGS)
{
text *in = PG_GETARG_TEXT_P(0);
TRGM *trg;
Datum *d;
ArrayType *a;
trgm *ptr;
int i;
trg = generate_trgm(VARDATA(in), VARSIZE(in) - VARHDRSZ);
d = (Datum *) palloc(sizeof(Datum) * (1 + ARRNELEM(trg)));
for (i = 0, ptr = GETARR(trg); i < ARRNELEM(trg); i++, ptr++)
{
text *item = (text *) palloc(VARHDRSZ + Max(12, pg_database_encoding_max_length() * 3));
if (pg_database_encoding_max_length() > 1 && !ISPRINTABLETRGM(ptr))
{
snprintf(VARDATA(item), 12, "0x%06x", trgm2int(ptr));
SET_VARSIZE(item, VARHDRSZ + strlen(VARDATA(item)));
}
else
{
SET_VARSIZE(item, VARHDRSZ + 3);
CPTRGM(VARDATA(item), ptr);
}
d[i] = PointerGetDatum(item);
}
a = construct_array(
d,
ARRNELEM(trg),
TEXTOID,
-1,
false,
'i'
);
for (i = 0; i < ARRNELEM(trg); i++)
pfree(DatumGetPointer(d[i]));
pfree(d);
pfree(trg);
PG_FREE_IF_COPY(in, 0);
PG_RETURN_POINTER(a);
}
开发者ID:dchichkov,项目名称:postgres,代码行数:48,代码来源:trgm_op.c
示例2: gbt_bpchar_consistent
Datum
gbt_bpchar_consistent(PG_FUNCTION_ARGS)
{
GISTENTRY *entry = (GISTENTRY *) PG_GETARG_POINTER(0);
void *query = (void *) DatumGetPointer(PG_DETOAST_DATUM(PG_GETARG_DATUM(1)));
StrategyNumber strategy = (StrategyNumber) PG_GETARG_UINT16(2);
/* Oid subtype = PG_GETARG_OID(3); */
bool *recheck = (bool *) PG_GETARG_POINTER(4);
bool retval;
GBT_VARKEY *key = (GBT_VARKEY *) DatumGetPointer(entry->key);
GBT_VARKEY_R r = gbt_var_key_readable(key);
void *trim = (void *) DatumGetPointer(DirectFunctionCall1(rtrim1, PointerGetDatum(query)));
/* All cases served by this function are exact */
*recheck = false;
if (tinfo.eml == 0)
{
tinfo.eml = pg_database_encoding_max_length();
}
retval = gbt_var_consistent(&r, trim, &strategy, GIST_LEAF(entry), &tinfo);
PG_RETURN_BOOL(retval);
}
开发者ID:joshstewart,项目名称:postgres,代码行数:25,代码来源:btree_text.c
示例3: TParserInit
TParser *
TParserInit(char *str, int len)
{
TParser *prs = (TParser *) palloc0(sizeof(TParser));
prs->charmaxlen = pg_database_encoding_max_length();
prs->str = str;
prs->lenstr = len;
#ifdef TS_USE_WIDE
/*
* Use wide char code only when max encoding length > 1.
*/
if (prs->charmaxlen > 1)
{
prs->usewide = true;
prs->wstr = (wchar_t *) palloc(sizeof(wchar_t) * (prs->lenstr+1));
prs->lenwstr = char2wchar(prs->wstr, prs->str, prs->lenstr);
}
else
#endif
prs->usewide = false;
prs->state = newTParserPosition(NULL);
prs->state->state = TPS_Base;
return prs;
}
开发者ID:berkeley-cs186,项目名称:course-fa07,代码行数:30,代码来源:parser.c
示例4: ora_mb_strlen1
int
ora_mb_strlen1(text *str)
{
int r_len;
int c;
char *p;
r_len = VARSIZE_ANY_EXHDR(str);
if (pg_database_encoding_max_length() == 1)
return r_len;
p = VARDATA_ANY(str);
c = 0;
while (r_len > 0)
{
int sz;
sz = _pg_mblen(p);
p += sz;
r_len -= sz;
c += 1;
}
return c;
}
开发者ID:protodef,项目名称:orafce,代码行数:26,代码来源:plvstr.c
示例5: gbt_bpchar_compress
Datum
gbt_bpchar_compress(PG_FUNCTION_ARGS)
{
GISTENTRY *entry = (GISTENTRY *) PG_GETARG_POINTER(0);
GISTENTRY *retval;
if (tinfo.eml == 0)
{
tinfo.eml = pg_database_encoding_max_length();
}
if (entry->leafkey)
{
Datum d = DirectFunctionCall1(rtrim1, entry->key);
GISTENTRY trim;
gistentryinit(trim, d,
entry->rel, entry->page,
entry->offset, VARSIZE(DatumGetPointer(d)), TRUE);
retval = gbt_var_compress(&trim, &tinfo);
}
else
retval = entry;
PG_RETURN_POINTER(retval);
}
开发者ID:CraigBryan,项目名称:PostgresqlFun,代码行数:28,代码来源:btree_text.c
示例6: regexp_fixed_prefix
/*
* regexp_fixed_prefix - extract fixed prefix, if any, for a regexp
*
* The result is NULL if there is no fixed prefix, else a palloc'd string.
* If it is an exact match, not just a prefix, *exact is returned as TRUE.
*/
char *
regexp_fixed_prefix(text *text_re, bool case_insensitive, Oid collation,
bool *exact)
{
char *result;
regex_t *re;
int cflags;
int re_result;
pg_wchar *str;
size_t slen;
size_t maxlen;
char errMsg[100];
*exact = false; /* default result */
/* Compile RE */
cflags = REG_ADVANCED;
if (case_insensitive)
cflags |= REG_ICASE;
re = RE_compile_and_cache(text_re, cflags, collation);
/* Examine it to see if there's a fixed prefix */
re_result = pg_regprefix(re, &str, &slen);
switch (re_result)
{
case REG_NOMATCH:
return NULL;
case REG_PREFIX:
/* continue with wchar conversion */
break;
case REG_EXACT:
*exact = true;
/* continue with wchar conversion */
break;
default:
/* re failed??? */
CHECK_FOR_INTERRUPTS();
pg_regerror(re_result, re, errMsg, sizeof(errMsg));
ereport(ERROR,
(errcode(ERRCODE_INVALID_REGULAR_EXPRESSION),
errmsg("regular expression failed: %s", errMsg)));
break;
}
/* Convert pg_wchar result back to database encoding */
maxlen = pg_database_encoding_max_length() * slen + 1;
result = (char *) palloc(maxlen);
slen = pg_wchar2mb_with_len(str, result, slen);
Assert(slen < maxlen);
free(str);
return result;
}
开发者ID:BioBD,项目名称:Hypothetical_Indexes,代码行数:65,代码来源:regexp.c
示例7: protect_out_of_mem
/*
* Guard against possible overflow in the palloc requests below. (We
* don't worry about the additive constants, since palloc can detect
* requests that are a little above MaxAllocSize --- we just need to
* prevent integer overflow in the multiplications.)
*/
static void
protect_out_of_mem(int slen)
{
if ((Size) (slen / 2) >= (MaxAllocSize / (sizeof(trgm) * 3)) ||
(Size) slen >= (MaxAllocSize / pg_database_encoding_max_length()))
ereport(ERROR,
(errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
errmsg("out of memory")));
}
开发者ID:BenjaminYu,项目名称:postgres,代码行数:15,代码来源:trgm_op.c
示例8: generate_trgm_only
/*
* Make array of trigrams without sorting and removing duplicate items.
*
* trg: where to return the array of trigrams.
* str: source string, of length slen bytes.
* bounds: where to return bounds of trigrams (if needed).
*
* Returns length of the generated array.
*/
static int
generate_trgm_only(trgm *trg, char *str, int slen, TrgmBound *bounds)
{
trgm *tptr;
char *buf;
int charlen,
bytelen;
char *bword,
*eword;
if (slen + LPADDING + RPADDING < 3 || slen == 0)
return 0;
tptr = trg;
/* Allocate a buffer for case-folded, blank-padded words */
buf = (char *) palloc(slen * pg_database_encoding_max_length() + 4);
if (LPADDING > 0)
{
*buf = ' ';
if (LPADDING > 1)
*(buf + 1) = ' ';
}
eword = str;
while ((bword = find_word(eword, slen - (eword - str), &eword, &charlen)) != NULL)
{
#ifdef IGNORECASE
bword = lowerstr_with_len(bword, eword - bword);
bytelen = strlen(bword);
#else
bytelen = eword - bword;
#endif
memcpy(buf + LPADDING, bword, bytelen);
#ifdef IGNORECASE
pfree(bword);
#endif
buf[LPADDING + bytelen] = ' ';
buf[LPADDING + bytelen + 1] = ' ';
/* Calculate trigrams marking their bounds if needed */
if (bounds)
bounds[tptr - trg] |= TRGM_BOUND_LEFT;
tptr = make_trigrams(tptr, buf, bytelen + LPADDING + RPADDING,
charlen + LPADDING + RPADDING);
if (bounds)
bounds[tptr - trg - 1] |= TRGM_BOUND_RIGHT;
}
pfree(buf);
return tptr - trg;
}
开发者ID:RingsC,项目名称:postgres,代码行数:66,代码来源:trgm_op.c
示例9: GenericMatchText
/* Generic for all cases not requiring inline case-folding */
static inline int
GenericMatchText(char *s, int slen, char *p, int plen)
{
if (pg_database_encoding_max_length() == 1)
return SB_MatchText(s, slen, p, plen, 0, true);
else if (GetDatabaseEncoding() == PG_UTF8)
return UTF8_MatchText(s, slen, p, plen, 0, true);
else
return MB_MatchText(s, slen, p, plen, 0, true);
}
开发者ID:AllenDou,项目名称:postgresql,代码行数:11,代码来源:like.c
示例10: gbt_text_compress
Datum
gbt_text_compress(PG_FUNCTION_ARGS)
{
GISTENTRY *entry = (GISTENTRY *) PG_GETARG_POINTER(0);
if (tinfo.eml == 0)
{
tinfo.eml = pg_database_encoding_max_length();
}
PG_RETURN_POINTER(gbt_var_compress(entry, &tinfo));
}
开发者ID:CraigBryan,项目名称:PostgresqlFun,代码行数:12,代码来源:btree_text.c
示例11: like_escape
/*
* like_escape() --- given a pattern and an ESCAPE string,
* convert the pattern to use Postgres' standard backslash escape convention.
*/
Datum
like_escape(PG_FUNCTION_ARGS)
{
text *pat = PG_GETARG_TEXT_PP(0);
text *esc = PG_GETARG_TEXT_PP(1);
text *result;
if (pg_database_encoding_max_length() == 1)
result = SB_do_like_escape(pat, esc);
else
result = MB_do_like_escape(pat, esc);
PG_RETURN_TEXT_P(result);
}
开发者ID:AllenDou,项目名称:postgresql,代码行数:18,代码来源:like.c
示例12: bpcharlen
Datum
bpcharlen(PG_FUNCTION_ARGS)
{
BpChar *arg = PG_GETARG_BPCHAR_P(0);
int len;
/* get number of bytes, ignoring trailing spaces */
len = bcTruelen(arg);
/* in multibyte encoding, convert to number of characters */
if (pg_database_encoding_max_length() != 1)
len = pg_mbstrlen_with_len(VARDATA(arg), len);
PG_RETURN_INT32(len);
}
开发者ID:shubham2094,项目名称:postgresql_8.1,代码行数:15,代码来源:varchar.c
示例13: orafce_bpcharlen
Datum
orafce_bpcharlen(PG_FUNCTION_ARGS)
{
BpChar *arg = PG_GETARG_BPCHAR_PP(0);
int len;
/* byte-length of the argument (trailing spaces not ignored) */
len = VARSIZE_ANY_EXHDR(arg);
/* in multibyte encoding, convert to number of characters */
if (pg_database_encoding_max_length() != 1)
len = pg_mbstrlen_with_len(VARDATA_ANY(arg), len);
PG_RETURN_INT32(len);
}
开发者ID:KinoSun,项目名称:orafce,代码行数:15,代码来源:charlen.c
示例14: init_tsvector_parser
/*
* Initializes parser for the input string. If oprisdelim is set, the
* following characters are treated as delimiters in addition to whitespace:
* ! | & ( )
*/
TSVectorParseState
init_tsvector_parser(char *input, bool oprisdelim, bool is_tsquery)
{
TSVectorParseState state;
state = (TSVectorParseState) palloc(sizeof(struct TSVectorParseStateData));
state->prsbuf = input;
state->bufstart = input;
state->len = 32;
state->word = (char *) palloc(state->len);
state->eml = pg_database_encoding_max_length();
state->oprisdelim = oprisdelim;
state->is_tsquery = is_tsquery;
return state;
}
开发者ID:jarulraj,项目名称:postgres-cpp,代码行数:21,代码来源:tsvector_parser.c
示例15: pg_mbstrlen
/* returns the length (counted in wchars) of a multibyte string */
int
pg_mbstrlen(const char *mbstr)
{
int len = 0;
/* optimization for single byte encoding */
if (pg_database_encoding_max_length() == 1)
return strlen(mbstr);
while (*mbstr)
{
mbstr += pg_mblen(mbstr);
len++;
}
return len;
}
开发者ID:MicroMirror,项目名称:gpdb,代码行数:17,代码来源:mbutils.c
示例16: ora_instr
int
ora_instr(text *txt, text *pattern, int start, int nth)
{
int len_txt, len_pat;
const char *str_txt, *str_pat;
int beg, end, i, dx;
if (nth <= 0)
PARAMETER_ERROR("Four parameter isn't positive.");
/* Forward for multibyte strings */
if (pg_database_encoding_max_length() > 1)
return ora_instr_mb(txt, pattern, start, nth);
str_txt = VARDATA_ANY(txt);
len_txt = VARSIZE_ANY_EXHDR(txt);
str_pat = VARDATA_ANY(pattern);
len_pat = VARSIZE_ANY_EXHDR(pattern);
if (start > 0)
{
dx = 1;
beg = start - 1;
end = len_txt - len_pat + 1;
if (beg >= end)
return 0; /* out of range */
}
else
{
dx = -1;
beg = Min(len_txt + start, len_txt - len_pat);
end = -1;
if (beg <= end)
return 0; /* out of range */
}
for (i = beg; i != end; i += dx)
{
if (memcmp(str_txt + i, str_pat, len_pat) == 0)
{
if (--nth == 0)
return i + 1;
}
}
return 0;
}
开发者ID:protodef,项目名称:orafce,代码行数:47,代码来源:plvstr.c
示例17: plvchr_is_kind_a
Datum
plvchr_is_kind_a (PG_FUNCTION_ARGS)
{
text *str = PG_GETARG_TEXT_PP(0);
int32 k = PG_GETARG_INT32(1);
char c;
NON_EMPTY_CHECK(str);
if (pg_database_encoding_max_length() > 1)
{
if (_pg_mblen(VARDATA_ANY(str)) > 1)
PG_RETURN_INT32( (k == 5) );
}
c = *VARDATA_ANY(str);
PG_RETURN_INT32(is_kind(c,k));
}
开发者ID:protodef,项目名称:orafce,代码行数:17,代码来源:plvstr.c
示例18: plvstr_is_prefix_text
Datum
plvstr_is_prefix_text (PG_FUNCTION_ARGS)
{
text *str = PG_GETARG_TEXT_PP(0);
text *prefix = PG_GETARG_TEXT_PP(1);
bool case_sens = PG_GETARG_BOOL(2);
bool mb_encode;
int str_len = VARSIZE_ANY_EXHDR(str);
int pref_len = VARSIZE_ANY_EXHDR(prefix);
int i;
char *ap, *bp;
mb_encode = pg_database_encoding_max_length() > 1;
if (mb_encode && !case_sens)
{
str = (text*)DatumGetPointer(DirectFunctionCall1(lower, PointerGetDatum(str)));
prefix = (text*)DatumGetPointer(DirectFunctionCall1(lower, PointerGetDatum(prefix)));
}
ap = VARDATA_ANY(str);
bp = VARDATA_ANY(prefix);
for (i = 0; i < pref_len; i++)
{
if (i >= str_len)
break;
if (case_sens || mb_encode)
{
if (*ap++ != *bp++)
break;
}
else if (!mb_encode)
{
if (pg_toupper((unsigned char) *ap++) != pg_toupper((unsigned char) *bp++))
break;
}
}
PG_RETURN_BOOL(i == pref_len);
}
开发者ID:protodef,项目名称:orafce,代码行数:44,代码来源:plvstr.c
示例19: gbt_text_consistent
Datum
gbt_text_consistent(PG_FUNCTION_ARGS)
{
GISTENTRY *entry = (GISTENTRY *) PG_GETARG_POINTER(0);
GBT_VARKEY *key = (GBT_VARKEY *) DatumGetPointer(entry->key);
void *query = (void *) DatumGetTextP(PG_GETARG_DATUM(1));
StrategyNumber strategy = (StrategyNumber) PG_GETARG_UINT16(2);
bool retval = FALSE;
GBT_VARKEY_R r = gbt_var_key_readable(key);
if (tinfo.eml == 0)
{
tinfo.eml = pg_database_encoding_max_length();
}
retval = gbt_var_consistent(&r, query, &strategy, GIST_LEAF(entry), &tinfo);
PG_RETURN_BOOL(retval);
}
开发者ID:CraigBryan,项目名称:PostgresqlFun,代码行数:19,代码来源:btree_text.c
示例20: pg_mbstrlen_with_len
/* returns the length (counted in wchars) of a multibyte string
* (not necessarily NULL terminated)
*/
int
pg_mbstrlen_with_len(const char *mbstr, int limit)
{
int len = 0;
/* optimization for single byte encoding */
if (pg_database_encoding_max_length() == 1)
return limit;
while (limit > 0 && *mbstr)
{
int l = pg_mblen(mbstr);
limit -= l;
mbstr += l;
len++;
}
return len;
}
开发者ID:MicroMirror,项目名称:gpdb,代码行数:22,代码来源:mbutils.c
注:本文中的pg_database_encoding_max_length函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论