PostgreSQL Source Code git master
Loading...
Searching...
No Matches
json.h File Reference
#include "lib/stringinfo.h"
Include dependency graph for json.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

void composite_to_json (Datum composite, StringInfo result, bool use_line_feeds)
 
void escape_json (StringInfo buf, const char *str)
 
void escape_json_with_len (StringInfo buf, const char *str, int len)
 
void escape_json_text (StringInfo buf, const text *txt)
 
charJsonEncodeDateTime (char *buf, Datum value, Oid typid, const int *tzp)
 
bool to_json_is_immutable (Oid typoid)
 
Datum json_build_object_worker (int nargs, const Datum *args, const bool *nulls, const Oid *types, bool absent_on_null, bool unique_keys)
 
Datum json_build_array_worker (int nargs, const Datum *args, const bool *nulls, const Oid *types, bool absent_on_null)
 
bool json_validate (text *json, bool check_unique_keys, bool throw_error)
 

Function Documentation

◆ composite_to_json()

void composite_to_json ( Datum  composite,
StringInfo  result,
bool  use_line_feeds 
)
extern

Definition at line 521 of file json.c.

522{
524 Oid tupType;
526 TupleDesc tupdesc;
528 *tuple;
529 int i;
530 bool needsep = false;
531 const char *sep;
532 int seplen;
533
534 /*
535 * We can avoid expensive strlen() calls by precalculating the separator
536 * length.
537 */
538 sep = use_line_feeds ? ",\n " : ",";
539 seplen = use_line_feeds ? strlen(",\n ") : strlen(",");
540
541 td = DatumGetHeapTupleHeader(composite);
542
543 /* Extract rowtype info and find a tupdesc */
547
548 /* Build a temporary HeapTuple control structure */
550 tmptup.t_data = td;
551 tuple = &tmptup;
552
553 appendStringInfoChar(result, '{');
554
555 for (i = 0; i < tupdesc->natts; i++)
556 {
557 Datum val;
558 bool isnull;
559 char *attname;
563
564 if (att->attisdropped)
565 continue;
566
567 if (needsep)
569 needsep = true;
570
571 attname = NameStr(att->attname);
572 escape_json(result, attname);
573 appendStringInfoChar(result, ':');
574
575 val = heap_getattr(tuple, i + 1, tupdesc, &isnull);
576
577 if (isnull)
578 {
581 }
582 else
583 json_categorize_type(att->atttypid, false, &tcategory,
584 &outfuncoid);
585
587 false);
588 }
589
590 appendStringInfoChar(result, '}');
591 ReleaseTupleDesc(tupdesc);
592}
#define NameStr(name)
Definition c.h:837
int32_t int32
Definition c.h:614
#define DatumGetHeapTupleHeader(X)
Definition fmgr.h:296
static Datum heap_getattr(HeapTuple tup, int attnum, TupleDesc tupleDesc, bool *isnull)
static int32 HeapTupleHeaderGetTypMod(const HeapTupleHeaderData *tup)
static uint32 HeapTupleHeaderGetDatumLength(const HeapTupleHeaderData *tup)
static Oid HeapTupleHeaderGetTypeId(const HeapTupleHeaderData *tup)
long val
Definition informix.c:689
int i
Definition isn.c:77
static void datum_to_json_internal(Datum val, bool is_null, StringInfo result, JsonTypeCategory tcategory, Oid outfuncoid, bool key_scalar)
Definition json.c:178
void escape_json(StringInfo buf, const char *str)
Definition json.c:1572
void json_categorize_type(Oid typoid, bool is_jsonb, JsonTypeCategory *tcategory, Oid *outfuncoid)
Definition jsonfuncs.c:5967
JsonTypeCategory
Definition jsonfuncs.h:69
@ JSONTYPE_NULL
Definition jsonfuncs.h:70
NameData attname
FormData_pg_attribute * Form_pg_attribute
uint64_t Datum
Definition postgres.h:70
#define InvalidOid
unsigned int Oid
static int fb(int x)
void appendBinaryStringInfo(StringInfo str, const void *data, int datalen)
Definition stringinfo.c:281
void appendStringInfoChar(StringInfo str, char ch)
Definition stringinfo.c:242
#define ReleaseTupleDesc(tupdesc)
Definition tupdesc.h:238
static FormData_pg_attribute * TupleDescAttr(TupleDesc tupdesc, int i)
Definition tupdesc.h:178
TupleDesc lookup_rowtype_tupdesc(Oid type_id, int32 typmod)
Definition typcache.c:1947

References appendBinaryStringInfo(), appendStringInfoChar(), attname, datum_to_json_internal(), DatumGetHeapTupleHeader, escape_json(), fb(), heap_getattr(), HeapTupleHeaderGetDatumLength(), HeapTupleHeaderGetTypeId(), HeapTupleHeaderGetTypMod(), i, InvalidOid, json_categorize_type(), JSONTYPE_NULL, lookup_rowtype_tupdesc(), NameStr, TupleDescData::natts, ReleaseTupleDesc, TupleDescAttr(), and val.

Referenced by CopyToJsonOneRow(), datum_to_json_internal(), row_to_json(), and row_to_json_pretty().

◆ escape_json()

void escape_json ( StringInfo  buf,
const char str 
)
extern

Definition at line 1572 of file json.c.

1573{
1575
1576 for (; *str != '\0'; str++)
1578
1580}
const char * str
static pg_attribute_always_inline void escape_json_char(StringInfo buf, char c)
Definition json.c:1532
static char buf[DEFAULT_XLOG_SEG_SIZE]
#define appendStringInfoCharMacro(str, ch)
Definition stringinfo.h:231

References appendStringInfoCharMacro, buf, escape_json_char(), and str.

Referenced by appendJSONKeyValue(), composite_to_json(), datum_to_json_internal(), escape_yaml(), ExplainDummyGroup(), ExplainOpenGroup(), ExplainProperty(), ExplainPropertyList(), ExplainPropertyListNested(), generate_error_response(), populate_scalar(), sn_object_field_start(), sn_scalar(), transform_string_values_object_field_start(), transformJsonTableColumn(), and write_jsonlog().

◆ escape_json_text()

void escape_json_text ( StringInfo  buf,
const text txt 
)
extern

Definition at line 1706 of file json.c.

1707{
1708 /* must cast away the const, unfortunately */
1711 char *str;
1712
1714
1716
1717 /* pfree any detoasted values */
1718 if (tunpacked != txt)
1720}
#define unconstify(underlying_type, expr)
Definition c.h:1327
varlena * pg_detoast_datum_packed(varlena *datum)
Definition fmgr.c:1830
void escape_json_with_len(StringInfo buf, const char *str, int len)
Definition json.c:1601
void pfree(void *pointer)
Definition mcxt.c:1616
const void size_t len
Definition c.h:778
static Size VARSIZE_ANY_EXHDR(const void *PTR)
Definition varatt.h:472
static char * VARDATA_ANY(const void *PTR)
Definition varatt.h:486

References buf, escape_json_with_len(), fb(), len, pfree(), pg_detoast_datum_packed(), str, unconstify, VARDATA_ANY(), and VARSIZE_ANY_EXHDR().

Referenced by datum_to_json_internal(), json_object(), json_object_two_arg(), and transform_string_values_scalar().

◆ escape_json_with_len()

void escape_json_with_len ( StringInfo  buf,
const char str,
int  len 
)
extern

Definition at line 1601 of file json.c.

1602{
1603 int vlen;
1604
1605 Assert(len >= 0);
1606
1607 /*
1608 * Since we know the minimum length we'll need to append, let's just
1609 * enlarge the buffer now rather than incrementally making more space when
1610 * we run out. Add two extra bytes for the enclosing quotes.
1611 */
1613
1614 /*
1615 * Figure out how many bytes to process using SIMD. Round 'len' down to
1616 * the previous multiple of sizeof(Vector8), assuming that's a power-of-2.
1617 */
1618 vlen = len & (int) (~(sizeof(Vector8) - 1));
1619
1621
1622 for (int i = 0, copypos = 0;;)
1623 {
1624 /*
1625 * To speed this up, try searching sizeof(Vector8) bytes at once for
1626 * special characters that we need to escape. When we find one, we
1627 * fall out of the Vector8 loop and copy the portion we've vector
1628 * searched and then we process sizeof(Vector8) bytes one byte at a
1629 * time. Once done, come back and try doing vector searching again.
1630 * We'll also process any remaining bytes at the tail end of the
1631 * string byte-by-byte. This optimization assumes that most chunks of
1632 * sizeof(Vector8) bytes won't contain any special characters.
1633 */
1634 for (; i < vlen; i += sizeof(Vector8))
1635 {
1636 Vector8 chunk;
1637
1638 vector8_load(&chunk, (const uint8 *) &str[i]);
1639
1640 /*
1641 * Break on anything less than ' ' or if we find a '"' or '\\'.
1642 * Those need special handling. That's done in the per-byte loop.
1643 */
1644 if (vector8_has_le(chunk, (unsigned char) 0x1F) ||
1645 vector8_has(chunk, (unsigned char) '"') ||
1646 vector8_has(chunk, (unsigned char) '\\'))
1647 break;
1648
1649#ifdef ESCAPE_JSON_FLUSH_AFTER
1650
1651 /*
1652 * Flush what's been checked so far out to the destination buffer
1653 * every so often to avoid having to re-read cachelines when
1654 * escaping large strings.
1655 */
1657 {
1659 copypos = i;
1660 }
1661#endif
1662 }
1663
1664 /*
1665 * Write to the destination up to the point that we've vector searched
1666 * so far. Do this only when switching into per-byte mode rather than
1667 * once every sizeof(Vector8) bytes.
1668 */
1669 if (copypos < i)
1670 {
1672 copypos = i;
1673 }
1674
1675 /*
1676 * Per-byte loop for Vector8s containing special chars and for
1677 * processing the tail of the string.
1678 */
1679 for (int b = 0; b < sizeof(Vector8); b++)
1680 {
1681 /* check if we've finished */
1682 if (i == len)
1683 goto done;
1684
1685 Assert(i < len);
1686
1688 }
1689
1690 copypos = i;
1691 /* We're not done yet. Try the vector search again. */
1692 }
1693
1694done:
1696}
uint8_t uint8
Definition c.h:616
#define Assert(condition)
Definition c.h:945
int b
Definition isn.c:74
#define ESCAPE_JSON_FLUSH_AFTER
Definition json.c:1592
static bool vector8_has_le(const Vector8 v, const uint8 c)
Definition simd.h:214
static void vector8_load(Vector8 *v, const uint8 *s)
Definition simd.h:94
uint64 Vector8
Definition simd.h:47
static bool vector8_has(const Vector8 v, const uint8 c)
Definition simd.h:163
void enlargeStringInfo(StringInfo str, int needed)
Definition stringinfo.c:337

References appendBinaryStringInfo(), appendStringInfoCharMacro, Assert, b, buf, enlargeStringInfo(), escape_json_char(), ESCAPE_JSON_FLUSH_AFTER, fb(), i, len, str, vector8_has(), vector8_has_le(), and vector8_load().

Referenced by AddFileToBackupManifest(), escape_json_text(), hstore_to_json(), hstore_to_json_loose(), jsonb_put_escaped_value(), populate_scalar(), and printJsonPathItem().

◆ json_build_array_worker()

Datum json_build_array_worker ( int  nargs,
const Datum args,
const bool nulls,
const Oid types,
bool  absent_on_null 
)
extern

Definition at line 1314 of file json.c.

1316{
1317 int i;
1318 const char *sep = "";
1319 StringInfoData result;
1320
1321 initStringInfo(&result);
1322
1323 appendStringInfoChar(&result, '[');
1324
1325 for (i = 0; i < nargs; i++)
1326 {
1327 if (absent_on_null && nulls[i])
1328 continue;
1329
1330 appendStringInfoString(&result, sep);
1331 sep = ", ";
1332 add_json(args[i], nulls[i], &result, types[i], false);
1333 }
1334
1335 appendStringInfoChar(&result, ']');
1336
1337 return PointerGetDatum(cstring_to_text_with_len(result.data, result.len));
1338}
struct typedefs * types
Definition ecpg.c:30
static void add_json(Datum val, bool is_null, StringInfo result, Oid val_type, bool key_scalar)
Definition json.c:602
static Datum PointerGetDatum(const void *X)
Definition postgres.h:342
void appendStringInfoString(StringInfo str, const char *s)
Definition stringinfo.c:230
void initStringInfo(StringInfo str)
Definition stringinfo.c:97
text * cstring_to_text_with_len(const char *s, int len)
Definition varlena.c:196

References add_json(), appendStringInfoChar(), appendStringInfoString(), cstring_to_text_with_len(), StringInfoData::data, fb(), i, initStringInfo(), StringInfoData::len, PointerGetDatum(), and types.

Referenced by ExecEvalJsonConstructor(), and json_build_array().

◆ json_build_object_worker()

Datum json_build_object_worker ( int  nargs,
const Datum args,
const bool nulls,
const Oid types,
bool  absent_on_null,
bool  unique_keys 
)
extern

Definition at line 1194 of file json.c.

1196{
1197 int i;
1198 const char *sep = "";
1199 StringInfo result;
1200 JsonUniqueBuilderState unique_check;
1201
1202 if (nargs % 2 != 0)
1203 ereport(ERROR,
1205 errmsg("argument list must have even number of elements"),
1206 /* translator: %s is a SQL function name */
1207 errhint("The arguments of %s must consist of alternating keys and values.",
1208 "json_build_object()")));
1209
1210 result = makeStringInfo();
1211
1212 appendStringInfoChar(result, '{');
1213
1214 if (unique_keys)
1215 json_unique_builder_init(&unique_check);
1216
1217 for (i = 0; i < nargs; i += 2)
1218 {
1219 StringInfo out;
1220 bool skip;
1221 int key_offset;
1222
1223 /* Skip null values if absent_on_null */
1224 skip = absent_on_null && nulls[i + 1];
1225
1226 if (skip)
1227 {
1228 /* If key uniqueness check is needed we must save skipped keys */
1229 if (!unique_keys)
1230 continue;
1231
1232 out = json_unique_builder_get_throwawaybuf(&unique_check);
1233 }
1234 else
1235 {
1236 appendStringInfoString(result, sep);
1237 sep = ", ";
1238 out = result;
1239 }
1240
1241 /* process key */
1242 if (nulls[i])
1243 ereport(ERROR,
1245 errmsg("null value not allowed for object key")));
1246
1247 /* save key offset before appending it */
1248 key_offset = out->len;
1249
1250 add_json(args[i], false, out, types[i], true);
1251
1252 if (unique_keys)
1253 {
1254 /*
1255 * check key uniqueness after key appending
1256 *
1257 * Copy the key first, instead of pointing into the buffer. It
1258 * will be added to the hash table, but the buffer may get
1259 * reallocated as we're appending more data to it. That would
1260 * invalidate pointers to keys in the current buffer.
1261 */
1262 const char *key = pstrdup(&out->data[key_offset]);
1263
1264 if (!json_unique_check_key(&unique_check.check, key, 0))
1265 ereport(ERROR,
1267 errmsg("duplicate JSON object key value: %s", key));
1268
1269 if (skip)
1270 continue;
1271 }
1272
1273 appendStringInfoString(result, " : ");
1274
1275 /* process value */
1276 add_json(args[i + 1], nulls[i + 1], result, types[i + 1], false);
1277 }
1278
1279 appendStringInfoChar(result, '}');
1280
1281 return PointerGetDatum(cstring_to_text_with_len(result->data, result->len));
1282}
int errcode(int sqlerrcode)
Definition elog.c:874
int errhint(const char *fmt,...) pg_attribute_printf(1
#define ERROR
Definition elog.h:39
#define ereport(elevel,...)
Definition elog.h:150
static StringInfo json_unique_builder_get_throwawaybuf(JsonUniqueBuilderState *cxt)
Definition json.c:948
static bool json_unique_check_key(JsonUniqueCheckState *cxt, const char *key, int object_id)
Definition json.c:928
static void json_unique_builder_init(JsonUniqueBuilderState *cxt)
Definition json.c:920
char * pstrdup(const char *in)
Definition mcxt.c:1781
static char * errmsg
static const struct exclude_list_item skip[]
StringInfo makeStringInfo(void)
Definition stringinfo.c:72
JsonUniqueCheckState check
Definition json.c:72

References add_json(), appendStringInfoChar(), appendStringInfoString(), JsonUniqueBuilderState::check, cstring_to_text_with_len(), StringInfoData::data, ereport, errcode(), errhint(), errmsg, ERROR, fb(), i, json_unique_builder_get_throwawaybuf(), json_unique_builder_init(), json_unique_check_key(), StringInfoData::len, makeStringInfo(), PointerGetDatum(), pstrdup(), skip, and types.

Referenced by ExecEvalJsonConstructor(), and json_build_object().

◆ json_validate()

bool json_validate ( text json,
bool  check_unique_keys,
bool  throw_error 
)
extern

Definition at line 1782 of file json.c.

1783{
1784 JsonLexContext lex;
1787 JsonParseErrorType result;
1788
1790
1792 {
1793 state.lex = &lex;
1794 state.stack = NULL;
1795 state.id_counter = 0;
1796 state.unique = true;
1798
1799 uniqueSemAction.semstate = &state;
1803 }
1804
1806
1807 if (result != JSON_SUCCESS)
1808 {
1809 if (throw_error)
1810 json_errsave_error(result, &lex, NULL);
1811
1812 return false; /* invalid json */
1813 }
1814
1815 if (check_unique_keys && !state.unique)
1816 {
1817 if (throw_error)
1818 ereport(ERROR,
1820 errmsg("duplicate JSON object key value")));
1821
1822 return false; /* not unique keys */
1823 }
1824
1826 freeJsonLexContext(&lex);
1827
1828 return true; /* ok */
1829}
static JsonParseErrorType json_unique_object_start(void *_state)
Definition json.c:1724
static void json_unique_check_init(JsonUniqueCheckState *cxt)
Definition json.c:902
static JsonParseErrorType json_unique_object_field_start(void *_state, char *field, bool isnull)
Definition json.c:1757
static JsonParseErrorType json_unique_object_end(void *_state)
Definition json.c:1742
JsonParseErrorType pg_parse_json(JsonLexContext *lex, const JsonSemAction *sem)
Definition jsonapi.c:744
const JsonSemAction nullSemAction
Definition jsonapi.c:287
void freeJsonLexContext(JsonLexContext *lex)
Definition jsonapi.c:687
JsonParseErrorType
Definition jsonapi.h:35
@ JSON_SUCCESS
Definition jsonapi.h:36
JsonLexContext * makeJsonLexContext(JsonLexContext *lex, text *json, bool need_escapes)
Definition jsonfuncs.c:543
void json_errsave_error(JsonParseErrorType error, JsonLexContext *lex, Node *escontext)
Definition jsonfuncs.c:644

References ereport, errcode(), errmsg, ERROR, fb(), freeJsonLexContext(), json_errsave_error(), JSON_SUCCESS, json_unique_check_init(), json_unique_object_end(), json_unique_object_field_start(), json_unique_object_start(), makeJsonLexContext(), nullSemAction, and pg_parse_json().

Referenced by ExecEvalJsonConstructor(), and ExecEvalJsonIsPredicate().

◆ JsonEncodeDateTime()

char * JsonEncodeDateTime ( char buf,
Datum  value,
Oid  typid,
const int tzp 
)
extern

Definition at line 309 of file json.c.

310{
311 if (!buf)
312 buf = palloc(MAXDATELEN + 1);
313
314 switch (typid)
315 {
316 case DATEOID:
317 {
319 struct pg_tm tm;
320
322
323 /* Same as date_out(), but forcing DateStyle */
326 else
327 {
329 &(tm.tm_year), &(tm.tm_mon), &(tm.tm_mday));
331 }
332 }
333 break;
334 case TIMEOID:
335 {
337 struct pg_tm tt,
338 *tm = &tt;
339 fsec_t fsec;
340
341 /* Same as time_out(), but forcing DateStyle */
342 time2tm(time, tm, &fsec);
343 EncodeTimeOnly(tm, fsec, false, 0, USE_XSD_DATES, buf);
344 }
345 break;
346 case TIMETZOID:
347 {
349 struct pg_tm tt,
350 *tm = &tt;
351 fsec_t fsec;
352 int tz;
353
354 /* Same as timetz_out(), but forcing DateStyle */
355 timetz2tm(time, tm, &fsec, &tz);
356 EncodeTimeOnly(tm, fsec, true, tz, USE_XSD_DATES, buf);
357 }
358 break;
359 case TIMESTAMPOID:
360 {
362 struct pg_tm tm;
363 fsec_t fsec;
364
366 /* Same as timestamp_out(), but forcing DateStyle */
369 else if (timestamp2tm(timestamp, NULL, &tm, &fsec, NULL, NULL) == 0)
370 EncodeDateTime(&tm, fsec, false, 0, NULL, USE_XSD_DATES, buf);
371 else
374 errmsg("timestamp out of range")));
375 }
376 break;
377 case TIMESTAMPTZOID:
378 {
380 struct pg_tm tm;
381 int tz;
382 fsec_t fsec;
383 const char *tzn = NULL;
384
386
387 /*
388 * If a time zone is specified, we apply the time-zone shift,
389 * convert timestamptz to pg_tm as if it were without a time
390 * zone, and then use the specified time zone for converting
391 * the timestamp into a string.
392 */
393 if (tzp)
394 {
395 tz = *tzp;
397 }
398
399 /* Same as timestamptz_out(), but forcing DateStyle */
402 else if (timestamp2tm(timestamp, tzp ? NULL : &tz, &tm, &fsec,
403 tzp ? NULL : &tzn, NULL) == 0)
404 {
405 if (tzp)
406 tm.tm_isdst = 1; /* set time-zone presence flag */
407
408 EncodeDateTime(&tm, fsec, true, tz, tzn, USE_XSD_DATES, buf);
409 }
410 else
413 errmsg("timestamp out of range")));
414 }
415 break;
416 default:
417 elog(ERROR, "unknown jsonb value datetime type oid %u", typid);
418 return NULL;
419 }
420
421 return buf;
422}
void EncodeTimeOnly(struct pg_tm *tm, fsec_t fsec, bool print_tz, int tz, int style, char *str)
Definition datetime.c:4435
void j2date(int jd, int *year, int *month, int *day)
Definition datetime.c:322
void EncodeDateTime(struct pg_tm *tm, fsec_t fsec, bool print_tz, int tz, const char *tzn, int style, char *str)
Definition datetime.c:4465
void EncodeDateOnly(struct pg_tm *tm, int style, char *str)
Definition datetime.c:4350
void EncodeSpecialTimestamp(Timestamp dt, char *str)
Definition timestamp.c:1578
int timestamp2tm(Timestamp dt, int *tzp, struct pg_tm *tm, fsec_t *fsec, const char **tzn, pg_tz *attimezone)
Definition timestamp.c:1901
int64 Timestamp
Definition timestamp.h:38
int64 TimestampTz
Definition timestamp.h:39
int32 fsec_t
Definition timestamp.h:41
#define USECS_PER_SEC
Definition timestamp.h:134
#define TIMESTAMP_NOT_FINITE(j)
Definition timestamp.h:169
#define POSTGRES_EPOCH_JDATE
Definition timestamp.h:235
int timetz2tm(TimeTzADT *time, struct pg_tm *tm, fsec_t *fsec, int *tzp)
Definition date.c:2491
int time2tm(TimeADT time, struct pg_tm *tm, fsec_t *fsec)
Definition date.c:1576
void EncodeSpecialDate(DateADT dt, char *str)
Definition date.c:295
#define DATE_NOT_FINITE(j)
Definition date.h:49
static TimeTzADT * DatumGetTimeTzADTP(Datum X)
Definition date.h:72
int32 DateADT
Definition date.h:21
static DateADT DatumGetDateADT(Datum X)
Definition date.h:60
static TimeADT DatumGetTimeADT(Datum X)
Definition date.h:66
int64 TimeADT
Definition date.h:23
#define elog(elevel,...)
Definition elog.h:226
#define MAXDATELEN
Definition datetime.h:200
static struct @174 value
static struct pg_tm tm
Definition localtime.c:104
void * palloc(Size size)
Definition mcxt.c:1387
#define USE_XSD_DATES
Definition miscadmin.h:240
long date
Definition pgtypes_date.h:9
int64 timestamp
Definition pgtime.h:35
int tm_mday
Definition pgtime.h:39
int tm_mon
Definition pgtime.h:40
int tm_isdst
Definition pgtime.h:44
int tm_year
Definition pgtime.h:41
static Timestamp DatumGetTimestamp(Datum X)
Definition timestamp.h:28
static TimestampTz DatumGetTimestampTz(Datum X)
Definition timestamp.h:34

References buf, DATE_NOT_FINITE, DatumGetDateADT(), DatumGetTimeADT(), DatumGetTimestamp(), DatumGetTimestampTz(), DatumGetTimeTzADTP(), elog, EncodeDateOnly(), EncodeDateTime(), EncodeSpecialDate(), EncodeSpecialTimestamp(), EncodeTimeOnly(), ereport, errcode(), errmsg, ERROR, fb(), j2date(), MAXDATELEN, palloc(), POSTGRES_EPOCH_JDATE, time2tm(), timestamp2tm(), TIMESTAMP_NOT_FINITE, timetz2tm(), tm, pg_tm::tm_isdst, pg_tm::tm_mday, pg_tm::tm_mon, pg_tm::tm_year, USE_XSD_DATES, USECS_PER_SEC, and value.

Referenced by convertJsonbScalar(), datum_to_json_internal(), datum_to_jsonb_internal(), and executeItemOptUnwrapTarget().

◆ to_json_is_immutable()

bool to_json_is_immutable ( Oid  typoid)
extern

Definition at line 696 of file json.c.

697{
698 bool has_mutable = false;
699
700 json_check_mutability(typoid, false, &has_mutable);
701 return !has_mutable;
702}
void json_check_mutability(Oid typoid, bool is_jsonb, bool *has_mutable)
Definition jsonfuncs.c:6078

References fb(), and json_check_mutability().

Referenced by contain_mutable_functions_walker().