112 #define TEXTBUFLEN 1024
114 #define DatumGetUnknownP(X) ((unknown *) PG_DETOAST_DATUM(X))
115 #define DatumGetUnknownPCopy(X) ((unknown *) PG_DETOAST_DATUM_COPY(X))
116 #define PG_GETARG_UNKNOWN_P(n) DatumGetUnknownP(PG_GETARG_DATUM(n))
117 #define PG_GETARG_UNKNOWN_P_COPY(n) DatumGetUnknownPCopy(PG_GETARG_DATUM(n))
118 #define PG_RETURN_UNKNOWN_P(x) PG_RETURN_POINTER(x)
120 #define DatumGetVarStringP(X) ((VarString *) PG_DETOAST_DATUM(X))
121 #define DatumGetVarStringPP(X) ((VarString *) PG_DETOAST_DATUM_PACKED(X))
136 bool length_not_specified);
151 bool length_not_specified);
160 const char *fldsep,
const char *null_string);
166 int *argpos,
int *widthpos,
167 int *flags,
int *width);
171 int flags,
int width);
173 int flags,
int width);
261 if (dst_len >= src_len)
269 if (srcunpacked != src)
279 #define VAL(CH) ((CH) - '0')
280 #define DIG(VAL) ((VAL) + '0')
303 if (inputText[0] ==
'\\' && inputText[1] ==
'x')
305 size_t len = strlen(inputText);
316 for (bc = 0, tp = inputText; *tp !=
'\0'; bc++)
320 else if ((tp[0] ==
'\\') &&
321 (tp[1] >=
'0' && tp[1] <=
'3') &&
322 (tp[2] >=
'0' && tp[2] <=
'7') &&
323 (tp[3] >=
'0' && tp[3] <=
'7'))
325 else if ((tp[0] ==
'\\') &&
334 (
errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
335 errmsg(
"invalid input syntax for type %s",
"bytea")));
350 else if ((tp[0] ==
'\\') &&
351 (tp[1] >=
'0' && tp[1] <=
'3') &&
352 (tp[2] >=
'0' && tp[2] <=
'7') &&
353 (tp[3] >=
'0' && tp[3] <=
'7'))
359 *rp++ = bc +
VAL(tp[3]);
363 else if ((tp[0] ==
'\\') &&
375 (
errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
376 errmsg(
"invalid input syntax for type %s",
"bytea")));
417 else if ((
unsigned char) *vp < 0x20 || (
unsigned char) *vp > 0x7e)
430 (
errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
442 else if ((
unsigned char) *vp < 0x20 || (
unsigned char) *vp > 0x7e)
461 elog(
ERROR,
"unrecognized bytea_output setting: %d",
479 nbytes =
buf->len -
buf->cursor;
796 for (s = p; n > 0; n--)
881 if (length_not_specified)
888 (
errcode(ERRCODE_SUBSTRING_ERROR),
889 errmsg(
"negative substring length not allowed")));
944 if (length_not_specified)
946 slice_size = L1 = -1;
951 (
errcode(ERRCODE_SUBSTRING_ERROR),
952 errmsg(
"negative substring length not allowed")));
953 slice_size = L1 = -1;
961 slice_size = L1 = -1;
1014 if (S1 > slice_strlen)
1026 E1 =
Min(S1 + L1, slice_start + 1 + slice_strlen);
1028 E1 = slice_start + 1 + slice_strlen;
1034 for (
i = 0;
i < S1 - 1;
i++)
1044 for (
i = S1;
i < E1;
i++)
1049 memcpy(
VARDATA(ret), s, (p - s));
1057 elog(
ERROR,
"invalid backend encoding: encoding max length < 1");
1108 (
errcode(ERRCODE_SUBSTRING_ERROR),
1109 errmsg(
"negative substring length not allowed")));
1112 (
errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE),
1113 errmsg(
"integer out of range")));
1207 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
1208 errmsg(
"nondeterministic collations are not supported for substring searches")));
1223 state->is_multibyte_char_in_char =
false;
1225 state->is_multibyte_char_in_char =
false;
1227 state->is_multibyte_char_in_char =
true;
1233 state->last_match = NULL;
1247 if (len1 >= len2 && len2 > 1)
1249 int searchlength = len1 - len2;
1253 const char *str2 =
state->str2;
1267 if (searchlength < 16)
1269 else if (searchlength < 64)
1271 else if (searchlength < 128)
1273 else if (searchlength < 512)
1275 else if (searchlength < 2048)
1277 else if (searchlength < 4096)
1278 skiptablemask = 127;
1280 skiptablemask = 255;
1281 state->skiptablemask = skiptablemask;
1288 for (
i = 0;
i <= skiptablemask;
i++)
1289 state->skiptable[
i] = len2;
1300 for (
i = 0;
i < last;
i++)
1301 state->skiptable[(
unsigned char) str2[
i] & skiptablemask] = last -
i;
1316 int needle_len =
state->len2;
1320 if (needle_len <= 0)
1324 if (
state->last_match)
1325 start_ptr =
state->last_match + needle_len;
1327 start_ptr =
state->str1;
1341 if (
state->is_multibyte_char_in_char)
1348 while (
state->refpoint < matchptr)
1360 if (
state->refpoint > matchptr)
1362 start_ptr =
state->refpoint;
1368 state->last_match = matchptr;
1380 int haystack_len =
state->len1;
1381 int needle_len =
state->len2;
1382 int skiptablemask =
state->skiptablemask;
1383 const char *haystack =
state->str1;
1384 const char *needle =
state->str2;
1385 const char *haystack_end = &haystack[haystack_len];
1388 Assert(start_ptr >= haystack && start_ptr <= haystack_end);
1390 if (needle_len == 1)
1393 char nchar = *needle;
1396 while (hptr < haystack_end)
1399 return (
char *) hptr;
1405 const char *needle_last = &needle[needle_len - 1];
1408 hptr = start_ptr + needle_len - 1;
1409 while (hptr < haystack_end)
1433 hptr +=
state->skiptable[(
unsigned char) *hptr & skiptablemask];
1448 return state->last_match;
1463 return state->refpos + 1;
1475 state->last_match = NULL;
1497 (
errcode(ERRCODE_INDETERMINATE_COLLATION),
1498 errmsg(
"could not determine which collation to use for string comparison"),
1499 errhint(
"Use the COLLATE clause to set the collation explicitly.")));
1531 result = memcmp(arg1, arg2,
Min(len1, len2));
1532 if ((result == 0) && (len1 != len2))
1533 result = (len1 < len2) ? -1 : 1;
1554 if (len1 == len2 && memcmp(arg1, arg2, len1) == 0)
1560 && (!mylocale || mylocale->
provider == COLLPROVIDER_LIBC))
1568 a1len = len1 * 2 + 2;
1578 a2len = len2 * 2 + 2;
1592 r = MultiByteToWideChar(CP_UTF8, 0, arg1, len1,
1593 (LPWSTR) a1p, a1len / 2);
1596 (
errmsg(
"could not convert string to UTF-16: error code %lu",
1599 ((LPWSTR) a1p)[r] = 0;
1605 r = MultiByteToWideChar(CP_UTF8, 0, arg2, len2,
1606 (LPWSTR) a2p, a2len / 2);
1609 (
errmsg(
"could not convert string to UTF-16: error code %lu",
1612 ((LPWSTR) a2p)[r] = 0;
1615 #ifdef HAVE_LOCALE_T
1617 result =
wcscoll_l((LPWSTR) a1p, (LPWSTR) a2p, mylocale->
info.lt);
1620 result = wcscoll((LPWSTR) a1p, (LPWSTR) a2p);
1621 if (result == 2147483647)
1624 (
errmsg(
"could not compare Unicode strings: %m")));
1630 result = memcmp(arg1, arg2,
Min(len1, len2));
1631 if ((result == 0) && (len1 != len2))
1632 result = (len1 < len2) ? -1 : 1;
1645 a1p = (
char *)
palloc(len1 + 1);
1649 a2p = (
char *)
palloc(len2 + 1);
1653 memcpy(a1p, arg1, len1);
1655 memcpy(a2p, arg2, len2);
1660 if (mylocale->
provider == COLLPROVIDER_ICU)
1663 #ifdef HAVE_UCOL_STRCOLLUTF8
1669 result = ucol_strcollUTF8(mylocale->
info.icu.ucol,
1675 (
errmsg(
"collation failed: %s", u_errorName(
status))));
1685 ulen1 = icu_to_uchar(&uchar1, arg1, len1);
1686 ulen2 = icu_to_uchar(&uchar2, arg2, len2);
1688 result = ucol_strcoll(mylocale->
info.icu.ucol,
1702 #ifdef HAVE_LOCALE_T
1711 result = strcoll(a1p, a2p);
1716 result = strcmp(a1p, a2p);
1745 return varstr_cmp(a1p, len1, a2p, len2, collid);
1760 bool locale_is_c =
false;
1806 result = (
text_cmp(arg1, arg2, collid) == 0);
1819 bool locale_is_c =
false;
1859 result = (
text_cmp(arg1, arg2, collid) != 0);
1946 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
1947 errmsg(
"nondeterministic collations are not supported for substring searches")));
2014 bool collate_c =
false;
2035 if (typid == BPCHAROID)
2037 else if (typid == NAMEOID)
2074 if (typid == NAMEOID)
2105 #ifndef TRUST_STRXFRM
2106 if (!collate_c && !(
locale &&
locale->provider == COLLPROVIDER_ICU))
2117 if (abbreviate || !collate_c)
2188 result = memcmp(a1p, a2p,
Min(len1, len2));
2189 if ((result == 0) && (len1 != len2))
2190 result = (len1 < len2) ? -1 : 1;
2225 result = memcmp(a1p, a2p,
Min(len1, len2));
2226 if ((result == 0) && (len1 != len2))
2227 result = (len1 < len2) ? -1 : 1;
2306 if (len1 == len2 && memcmp(a1p, a2p, len1) == 0)
2324 if (sss->
typid == BPCHAROID)
2355 if (len1 != sss->
last_len1 || memcmp(sss->
buf1, a1p, len1) != 0)
2358 memcpy(sss->
buf1, a1p, len1);
2359 sss->
buf1[len1] =
'\0';
2369 if (len2 != sss->
last_len2 || memcmp(sss->
buf2, a2p, len2) != 0)
2371 memcpy(sss->
buf2, a2p, len2);
2372 sss->
buf2[len2] =
'\0';
2386 #ifdef HAVE_UCOL_STRCOLLUTF8
2392 result = ucol_strcollUTF8(sss->
locale->
info.icu.ucol,
2398 (
errmsg(
"collation failed: %s", u_errorName(
status))));
2408 ulen1 = icu_to_uchar(&uchar1, a1p, len1);
2409 ulen2 = icu_to_uchar(&uchar2, a2p, len2);
2411 result = ucol_strcoll(sss->
locale->
info.icu.ucol,
2425 #ifdef HAVE_LOCALE_T
2434 result = strcoll(sss->
buf1, sss->
buf2);
2439 result = strcmp(sss->
buf1, sss->
buf2);
2459 char *authoritative_data =
VARDATA_ANY(authoritative);
2467 pres = (
char *) &
res;
2469 memset(pres, 0,
sizeof(
Datum));
2473 if (sss->
typid == BPCHAROID)
2504 memcpy(pres, authoritative_data,
Min(
len,
sizeof(
Datum)));
2510 UChar *uchar = NULL;
2528 memcmp(sss->
buf1, authoritative_data,
len) == 0)
2535 memcpy(sss->
buf1, authoritative_data,
len);
2548 ulen = icu_to_uchar(&uchar, sss->
buf1,
len);
2574 uiter_setUTF8(&iter, sss->
buf1,
len);
2577 bsize = ucol_nextSortKeyPart(sss->
locale->
info.icu.ucol,
2580 (uint8_t *) sss->
buf2,
2585 (
errmsg(
"sort key generation failed: %s",
2589 bsize = ucol_getSortKey(sss->
locale->
info.icu.ucol,
2595 #ifdef HAVE_LOCALE_T
2604 if (bsize < sss->buflen2)
2653 #if SIZEOF_DATUM == 8
2680 res = DatumBigEndianToNative(
res);
2684 pfree(authoritative);
2698 double abbrev_distinct,
2704 if (memtupcount < 100)
2715 if (abbrev_distinct <= 1.0)
2716 abbrev_distinct = 1.0;
2718 if (key_distinct <= 1.0)
2729 double norm_abbrev_card = abbrev_distinct / (double) memtupcount;
2731 elog(
LOG,
"varstr_abbrev: abbrev_distinct after %d: %f "
2732 "(key_distinct: %f, norm_abbrev_card: %f, prop_card: %f)",
2733 memtupcount, abbrev_distinct, key_distinct, norm_abbrev_card,
2754 if (abbrev_distinct > key_distinct * sss->
prop_card)
2781 if (memtupcount > 10000)
2800 elog(
LOG,
"varstr_abbrev: aborted abbreviation at %d "
2801 "(abbrev_distinct: %f, key_distinct: %f, prop_card: %f)",
2802 memtupcount, abbrev_distinct, key_distinct, sss->
prop_card);
2821 collid == DEFAULT_COLLATION_OID ||
2862 size_t len1 = strlen(
NameStr(*arg1));
2869 if (collid == C_COLLATION_OID)
2870 result = (len1 == len2 &&
2888 size_t len2 = strlen(
NameStr(*arg2));
2894 if (collid == C_COLLATION_OID)
2895 result = (len1 == len2 &&
2912 size_t len1 = strlen(
NameStr(*arg1));
2919 if (collid == C_COLLATION_OID)
2920 result = !(len1 == len2 &&
2938 size_t len2 = strlen(
NameStr(*arg2));
2944 if (collid == C_COLLATION_OID)
2945 result = !(len1 == len2 &&
2989 #define CmpCall(cmpfunc) \
2990 DatumGetInt32(DirectFunctionCall2Coll(cmpfunc, \
2991 PG_GET_COLLATION(), \
2992 PG_GETARG_DATUM(0), \
2993 PG_GETARG_DATUM(1)))
3067 else if (len1 < len2)
3069 else if (len1 > len2)
3244 #define PG_STR_GET_BYTEA(str_) \
3245 DatumGetByteaPP(DirectFunctionCall1(byteain, CStringGetDatum(str_)))
3289 bool length_not_specified)
3300 if (length_not_specified)
3312 (
errcode(ERRCODE_SUBSTRING_ERROR),
3313 errmsg(
"negative substring length not allowed")));
3390 (
errcode(ERRCODE_SUBSTRING_ERROR),
3391 errmsg(
"negative substring length not allowed")));
3394 (
errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE),
3395 errmsg(
"integer out of range")));
3446 for (p = 0; p <=
px; p++)
3448 if ((*
p2 == *p1) && (memcmp(p1,
p2, len2) == 0))
3476 if (n < 0 || n >=
len)
3478 (
errcode(ERRCODE_ARRAY_SUBSCRIPT_ERROR),
3479 errmsg(
"index %d out of valid range, 0..%d",
3507 if (n < 0 || n >= (int64)
len * 8)
3509 (
errcode(ERRCODE_ARRAY_SUBSCRIPT_ERROR),
3510 errmsg(
"index %lld out of valid range, 0..%lld",
3511 (
long long) n, (
long long)
len * 8 - 1)));
3514 byteNo = (int) (n / 8);
3515 bitNo = (int) (n % 8);
3517 byte = ((
unsigned char *)
VARDATA_ANY(v))[byteNo];
3519 if (
byte & (1 << bitNo))
3543 if (n < 0 || n >=
len)
3545 (
errcode(ERRCODE_ARRAY_SUBSCRIPT_ERROR),
3546 errmsg(
"index %d out of valid range, 0..%d",
3552 ((
unsigned char *)
VARDATA(
res))[n] = newByte;
3579 if (n < 0 || n >= (int64)
len * 8)
3581 (
errcode(ERRCODE_ARRAY_SUBSCRIPT_ERROR),
3582 errmsg(
"index %lld out of valid range, 0..%lld",
3583 (
long long) n, (
long long)
len * 8 - 1)));
3586 byteNo = (int) (n / 8);
3587 bitNo = (int) (n % 8);
3592 if (newBit != 0 && newBit != 1)
3594 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
3595 errmsg(
"new bit must be 0 or 1")));
3600 oldByte = ((
unsigned char *)
VARDATA(
res))[byteNo];
3603 newByte = oldByte & (~(1 << bitNo));
3605 newByte = oldByte | (1 << bitNo);
3607 ((
unsigned char *)
VARDATA(
res))[byteNo] = newByte;
3670 (
errcode(ERRCODE_INVALID_NAME),
3671 errmsg(
"invalid name syntax")));
3673 if (namelist ==
NIL)
3675 (
errcode(ERRCODE_INVALID_NAME),
3676 errmsg(
"invalid name syntax")));
3678 foreach(l, namelist)
3680 char *curname = (
char *)
lfirst(l);
3718 char *nextp = rawstring;
3738 curname = nextp + 1;
3741 endp = strchr(nextp + 1,
'"');
3747 memmove(endp, endp + 1, strlen(endp));
3764 if (curname == nextp)
3776 len = endp - curname;
3779 strncpy(curname, downname,
len);
3793 else if (*nextp ==
'\0')
3807 *namelist =
lappend(*namelist, curname);
3845 char *nextp = rawstring;
3865 curname = nextp + 1;
3868 endp = strchr(nextp + 1,
'"');
3874 memmove(endp, endp + 1, strlen(endp));
3883 curname = endp = nextp;
3891 if (curname == endp)
3905 else if (*nextp ==
'\0')
3922 *namelist =
lappend(*namelist, curname);
3966 char *nextp = rawstring;
3986 curname = nextp + 1;
3989 endp = strchr(nextp + 1,
'"');
3995 memmove(endp, endp + 1, strlen(endp));
4009 if (curname == nextp)
4023 else if (*nextp ==
'\0')
4034 *namelist =
lappend(*namelist, curname);
4208 if ((
cmp == 0) && (len1 != len2))
4209 cmp = (len1 < len2) ? -1 : 1;
4260 int from_sub_text_len;
4273 if (src_text_len < 1 || from_sub_text_len < 1)
4298 chunk_len = curr_ptr - start_ptr;
4303 start_ptr = curr_ptr + from_sub_text_len;
4312 chunk_len = ((
char *) src_text +
VARSIZE_ANY(src_text)) - start_ptr;
4340 p = memchr(p,
'\\', p_end - p);
4347 if (*p >=
'1' && *p <=
'9')
4366 char *start_ptr,
int data_pos)
4373 const char *chunk_start = p;
4378 p = memchr(p,
'\\', p_end - p);
4383 if (p > chunk_start)
4398 if (*p >=
'1' && *p <=
'9')
4410 so = pmatch[0].
rm_so;
4411 eo = pmatch[0].
rm_eo;
4414 else if (*p ==
'\\')
4432 if (so >= 0 && eo >= 0)
4442 chunk_start = start_ptr;
4466 int cflags,
Oid collation,
4467 int search_start,
int n)
4492 if (escape_status < 2)
4506 while (search_start <= data_len)
4529 pg_regerror(regexec_result, re, errMsg,
sizeof(errMsg));
4531 (
errcode(ERRCODE_INVALID_REGULAR_EXPRESSION),
4532 errmsg(
"regular expression failed: %s", errMsg)));
4539 if (n > 0 && nmatches != n)
4546 search_start = pmatch[0].
rm_eo;
4547 if (pmatch[0].rm_so == pmatch[0].rm_eo)
4556 if (pmatch[0].rm_so - data_pos > 0)
4561 pmatch[0].rm_so - data_pos);
4568 start_ptr += chunk_len;
4569 data_pos = pmatch[0].
rm_so;
4575 if (escape_status > 0)
4577 start_ptr, data_pos);
4583 pmatch[0].rm_eo - data_pos);
4584 data_pos = pmatch[0].
rm_eo;
4598 search_start = data_pos;
4599 if (pmatch[0].rm_so == pmatch[0].rm_eo)
4606 if (data_pos < data_len)
4610 chunk_len = ((
char *) src_text +
VARSIZE_ANY(src_text)) - start_ptr;
4632 int inputstring_len;
4643 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
4644 errmsg(
"field position must not be zero")));
4650 if (inputstring_len < 1)
4657 if (fldnum == 1 || fldnum == -1)
4673 if (fldnum == 1 || fldnum == -1)
4695 end_ptr =
VARDATA_ANY(inputstring) + inputstring_len;
4698 end_ptr - start_ptr));
4702 fldnum += numfields + 1;
4721 while (found && --fldnum > 0)
4724 start_ptr = end_ptr + fldsep_len;
4738 int last_len = start_ptr -
VARDATA_ANY(inputstring);
4741 inputstring_len - last_len);
4778 memset(&tstate, 0,
sizeof(tstate));
4783 if (tstate.
astate == NULL)
4818 tstate.tupdesc = rsi->
setDesc;
4856 int inputstring_len;
4891 if (inputstring_len < 1)
4898 null_string, collation);
4918 chunk_len = ((
char *) inputstring +
VARSIZE_ANY(inputstring)) - start_ptr;
4925 chunk_len = end_ptr - start_ptr;
4933 null_string, collation);
4940 start_ptr = end_ptr + fldsep_len;
4956 while (inputstring_len > 0)
4958 int chunk_len =
pg_mblen(start_ptr);
4967 null_string, collation);
4971 start_ptr += chunk_len;
4972 inputstring_len -= chunk_len;
4991 bool is_null =
false;
4993 if (null_string &&
text_isequal(field_value, null_string, collation))
5068 const char *fldsep,
const char *null_string)
5079 bool printed =
false;
5103 if (my_extra == NULL)
5124 typlen = my_extra->
typlen;
5132 for (
i = 0;
i < nitems;
i++)
5138 if (bitmap && (*bitmap & bitmask) == 0)
5141 if (null_string != NULL)
5152 itemvalue =
fetch_att(p, typbyval, typlen);
5170 if (bitmask == 0x100)
5194 const char *
digits =
"0123456789abcdef";
5197 ptr =
buf +
sizeof(
buf) - 1;
5218 const char *
digits =
"0123456789abcdef";
5221 ptr =
buf +
sizeof(
buf) - 1;
5246 if (fcinfo->flinfo->fn_extra == NULL)
5253 elog(
ERROR,
"cache lookup failed for type %u", argtypeid);
5257 *((
int *) fcinfo->flinfo->fn_extra) = typlen;
5260 typlen = *((
int *) fcinfo->flinfo->fn_extra);
5267 else if (typlen == -2)
5293 if (fcinfo->flinfo->fn_extra == NULL)
5300 elog(
ERROR,
"cache lookup failed for type %u", argtypeid);
5304 *((
int *) fcinfo->flinfo->fn_extra) = typlen;
5307 typlen = *((
int *) fcinfo->flinfo->fn_extra);
5328 elog(
ERROR,
"invalid compression method id %d", cmid);
5355 elog(
ERROR,
"string_agg_transfn called in non-aggregate context");
5435 elog(
ERROR,
"could not determine data type of concat() input");
5462 bool first_arg =
true;
5505 if (foutcache == NULL)
5622 const char *endp = p +
len;
5657 #define TEXT_FORMAT_FLAG_MINUS 0x0001
5659 #define ADVANCE_PARSE_POINTER(ptr,end_ptr) \
5661 if (++(ptr) >= (end_ptr)) \
5663 (errcode(ERRCODE_INVALID_PARAMETER_VALUE), \
5664 errmsg("unterminated format() type specifier"), \
5665 errhint("For a single \"%%\" use \"%%%%\"."))); \
5677 const char *start_ptr;
5678 const char *end_ptr;
5683 Datum *elements = NULL;
5727 &elmlen, &elmbyval, &elmalign);
5731 &elements, &nulls, &nitems);
5735 funcvariadic =
true;
5741 funcvariadic =
false;
5752 for (cp = start_ptr; cp < end_ptr; cp++)
5794 if (strchr(
"sIL", *cp) == NULL)
5796 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
5797 errmsg(
"unrecognized format() type specifier \"%.*s\"",
5799 errhint(
"For a single \"%%\" use \"%%%%\".")));
5809 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
5810 errmsg(
"too few arguments for format()")));
5822 isNull = nulls[
arg - 1];
5823 typid = element_type;
5826 elog(
ERROR,
"could not determine data type of format() input");
5833 else if (typid == INT4OID)
5835 else if (typid == INT2OID)
5842 if (typid != prev_width_type)
5848 fmgr_info(typoutputfunc, &typoutputinfo_width);
5849 prev_width_type = typid;
5866 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
5867 errmsg(
"too few arguments for format()")));
5879 isNull = nulls[
arg - 1];
5880 typid = element_type;
5883 elog(
ERROR,
"could not determine data type of format() input");
5892 if (typid != prev_type)
5898 fmgr_info(typoutputfunc, &typoutputfinfo);
5917 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
5918 errmsg(
"unrecognized format() type specifier \"%.*s\"",
5920 errhint(
"For a single \"%%\" use \"%%%%\".")));
5926 if (elements != NULL)
5952 const char *cp = *ptr;
5955 while (*cp >=
'0' && *cp <=
'9')
5957 int8 digit = (*cp -
'0');
5962 (
errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE),
5963 errmsg(
"number is out of range")));
5999 int *argpos,
int *widthpos,
6000 int *flags,
int *width)
6002 const char *cp = start_ptr;
6025 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
6026 errmsg(
"format specifies argument 0, but arguments are numbered from 1")));