80 Node *escontext = fcinfo->context;
85 bool needComma =
false;
103 if (tupType == RECORDOID && tupTypmod < 0)
105 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
106 errmsg(
"input of anonymous composite types is not implemented")));
114 ncolumns = tupdesc->
natts;
121 if (my_extra == NULL ||
124 fcinfo->flinfo->fn_extra =
145 nulls = (
bool *)
palloc(ncolumns *
sizeof(
bool));
153 while (*ptr && isspace((
unsigned char) *ptr))
158 (
errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
159 errmsg(
"malformed record literal: \"%s\"",
string),
160 errdetail(
"Missing left parenthesis.")));
166 for (
i = 0;
i < ncolumns;
i++)
170 Oid column_type = att->atttypid;
174 if (att->attisdropped)
190 (
errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
191 errmsg(
"malformed record literal: \"%s\"",
string),
198 if (*ptr ==
',' || *ptr ==
')')
206 bool inquote =
false;
209 while (inquote || !(*ptr ==
',' || *ptr ==
')'))
216 (
errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
217 errmsg(
"malformed record literal: \"%s\"",
227 (
errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
228 errmsg(
"malformed record literal: \"%s\"",
239 else if (*ptr ==
'"')
251 column_data =
buf.data;
285 (
errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
286 errmsg(
"malformed record literal: \"%s\"",
string),
291 while (*ptr && isspace((
unsigned char) *ptr))
296 (
errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
297 errmsg(
"malformed record literal: \"%s\"",
string),
298 errdetail(
"Junk after right parenthesis.")));
338 bool needComma =
false;
351 ncolumns = tupdesc->
natts;
364 if (my_extra == NULL ||
367 fcinfo->flinfo->fn_extra =
388 nulls = (
bool *)
palloc(ncolumns *
sizeof(
bool));
398 for (
i = 0;
i < ncolumns;
i++)
402 Oid column_type = att->atttypid;
409 if (att->attisdropped)
439 nq = (
value[0] ==
'\0');
440 for (tmp =
value; *tmp; tmp++)
444 if (ch ==
'"' || ch ==
'\\' ||
445 ch ==
'(' || ch ==
')' || ch ==
',' ||
446 isspace((
unsigned char) ch))
456 for (tmp =
value; *tmp; tmp++)
460 if (ch ==
'"' || ch ==
'\\')
507 if (tupType == RECORDOID && tupTypmod < 0)
509 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
510 errmsg(
"input of anonymous composite types is not implemented")));
513 ncolumns = tupdesc->
natts;
520 if (my_extra == NULL ||
523 fcinfo->flinfo->fn_extra =
544 nulls = (
bool *)
palloc(ncolumns *
sizeof(
bool));
551 for (
i = 0;
i < ncolumns;
i++)
556 if (usercols != validcols)
558 (
errcode(ERRCODE_DATATYPE_MISMATCH),
559 errmsg(
"wrong number of columns: %d, expected %d",
560 usercols, validcols)));
563 for (
i = 0;
i < ncolumns;
i++)
567 Oid column_type = att->atttypid;
575 if (att->attisdropped)
596 if (coltypoid != column_type &&
600 (
errcode(ERRCODE_DATATYPE_MISMATCH),
601 errmsg(
"binary data has type %u (%s) instead of expected %u (%s) in record column %d",
612 if (itemlen < -1 || itemlen > (
buf->len -
buf->cursor))
614 (
errcode(ERRCODE_INVALID_BINARY_REPRESENTATION),
615 errmsg(
"insufficient data left in message")));
633 item_buf.
maxlen = itemlen + 1;
634 item_buf.
len = itemlen;
637 buf->cursor += itemlen;
639 csave =
buf->data[
buf->cursor];
640 buf->data[
buf->cursor] =
'\0';
665 if (item_buf.
cursor != itemlen)
667 (
errcode(ERRCODE_INVALID_BINARY_REPRESENTATION),
668 errmsg(
"improper binary format in record column %d",
671 buf->data[
buf->cursor] = csave;
718 ncolumns = tupdesc->
natts;
731 if (my_extra == NULL ||
734 fcinfo->flinfo->fn_extra =
755 nulls = (
bool *)
palloc(ncolumns *
sizeof(
bool));
765 for (
i = 0;
i < ncolumns;
i++)
772 for (
i = 0;
i < ncolumns;
i++)
776 Oid column_type = att->atttypid;
781 if (att->attisdropped)
864 ncolumns1 = tupdesc1->
natts;
868 ncolumns2 = tupdesc2->
natts;
884 ncols =
Max(ncolumns1, ncolumns2);
886 if (my_extra == NULL ||
915 nulls1 = (
bool *)
palloc(ncolumns1 *
sizeof(
bool));
918 nulls2 = (
bool *)
palloc(ncolumns2 *
sizeof(
bool));
927 while (i1 < ncolumns1 || i2 < ncolumns2)
937 if (i1 < ncolumns1 &&
TupleDescAttr(tupdesc1, i1)->attisdropped)
942 if (i2 < ncolumns2 &&
TupleDescAttr(tupdesc2, i2)->attisdropped)
947 if (i1 >= ncolumns1 || i2 >= ncolumns2)
956 if (att1->atttypid != att2->atttypid)
958 (
errcode(ERRCODE_DATATYPE_MISMATCH),
959 errmsg(
"cannot compare dissimilar column types %s and %s at record column %d",
968 collation = att1->attcollation;
969 if (collation != att2->attcollation)
976 if (typentry == NULL ||
977 typentry->
type_id != att1->atttypid)
983 (
errcode(ERRCODE_UNDEFINED_FUNCTION),
984 errmsg(
"could not identify a comparison function for type %s",
992 if (!nulls1[i1] || !nulls2[i2])
1012 collation, NULL, NULL);
1013 locfcinfo->args[0].value = values1[i1];
1014 locfcinfo->args[0].isnull =
false;
1015 locfcinfo->args[1].value = values2[i2];
1016 locfcinfo->args[1].isnull =
false;
1020 Assert(!locfcinfo->isnull);
1028 else if (cmpresult > 0)
1047 if (i1 != ncolumns1 || i2 != ncolumns2)
1049 (
errcode(ERRCODE_DATATYPE_MISMATCH),
1050 errmsg(
"cannot compare record types with different numbers of columns")));
1108 ncolumns1 = tupdesc1->
natts;
1112 ncolumns2 = tupdesc2->
natts;
1128 ncols =
Max(ncolumns1, ncolumns2);
1130 if (my_extra == NULL ||
1133 fcinfo->flinfo->fn_extra =
1159 nulls1 = (
bool *)
palloc(ncolumns1 *
sizeof(
bool));
1162 nulls2 = (
bool *)
palloc(ncolumns2 *
sizeof(
bool));
1171 while (i1 < ncolumns1 || i2 < ncolumns2)
1183 if (i1 < ncolumns1 &&
TupleDescAttr(tupdesc1, i1)->attisdropped)
1188 if (i2 < ncolumns2 &&
TupleDescAttr(tupdesc2, i2)->attisdropped)
1193 if (i1 >= ncolumns1 || i2 >= ncolumns2)
1202 if (att1->atttypid != att2->atttypid)
1204 (
errcode(ERRCODE_DATATYPE_MISMATCH),
1205 errmsg(
"cannot compare dissimilar column types %s and %s at record column %d",
1214 collation = att1->attcollation;
1215 if (collation != att2->attcollation)
1222 if (typentry == NULL ||
1223 typentry->
type_id != att1->atttypid)
1229 (
errcode(ERRCODE_UNDEFINED_FUNCTION),
1230 errmsg(
"could not identify an equality operator for type %s",
1238 if (!nulls1[i1] || !nulls2[i2])
1240 if (nulls1[i1] || nulls2[i2])
1248 collation, NULL, NULL);
1249 locfcinfo->args[0].value = values1[i1];
1250 locfcinfo->args[0].isnull =
false;
1251 locfcinfo->args[1].value = values2[i2];
1252 locfcinfo->args[1].isnull =
false;
1254 if (locfcinfo->isnull || !oprresult)
1272 if (i1 != ncolumns1 || i2 != ncolumns2)
1274 (
errcode(ERRCODE_DATATYPE_MISMATCH),
1275 errmsg(
"cannot compare record types with different numbers of columns")));
1370 ncolumns1 = tupdesc1->
natts;
1374 ncolumns2 = tupdesc2->
natts;
1390 ncols =
Max(ncolumns1, ncolumns2);
1392 if (my_extra == NULL ||
1421 nulls1 = (
bool *)
palloc(ncolumns1 *
sizeof(
bool));
1424 nulls2 = (
bool *)
palloc(ncolumns2 *
sizeof(
bool));
1433 while (i1 < ncolumns1 || i2 < ncolumns2)
1441 if (i1 < ncolumns1 &&
TupleDescAttr(tupdesc1, i1)->attisdropped)
1446 if (i2 < ncolumns2 &&
TupleDescAttr(tupdesc2, i2)->attisdropped)
1451 if (i1 >= ncolumns1 || i2 >= ncolumns2)
1460 if (att1->atttypid != att2->atttypid)
1462 (
errcode(ERRCODE_DATATYPE_MISMATCH),
1463 errmsg(
"cannot compare dissimilar column types %s and %s at record column %d",
1472 Assert(att1->attlen == att2->attlen);
1477 if (!nulls1[i1] || !nulls2[i2])
1497 if (values1[i1] != values2[i2])
1498 cmpresult = (values1[i1] < values2[i2]) ? -1 : 1;
1500 else if (att1->attlen > 0)
1506 else if (att1->attlen == -1)
1521 if ((cmpresult == 0) && (len1 != len2))
1522 cmpresult = (len1 < len2) ? -1 : 1;
1530 elog(
ERROR,
"unexpected attlen: %d", att1->attlen);
1538 else if (cmpresult > 0)
1557 if (i1 != ncolumns1 || i2 != ncolumns2)
1559 (
errcode(ERRCODE_DATATYPE_MISMATCH),
1560 errmsg(
"cannot compare record types with different numbers of columns")));
1616 ncolumns1 = tupdesc1->
natts;
1620 ncolumns2 = tupdesc2->
natts;
1636 ncols =
Max(ncolumns1, ncolumns2);
1638 if (my_extra == NULL ||
1641 fcinfo->flinfo->fn_extra =
1667 nulls1 = (
bool *)
palloc(ncolumns1 *
sizeof(
bool));
1670 nulls2 = (
bool *)
palloc(ncolumns2 *
sizeof(
bool));
1679 while (i1 < ncolumns1 || i2 < ncolumns2)
1687 if (i1 < ncolumns1 &&
TupleDescAttr(tupdesc1, i1)->attisdropped)
1692 if (i2 < ncolumns2 &&
TupleDescAttr(tupdesc2, i2)->attisdropped)
1697 if (i1 >= ncolumns1 || i2 >= ncolumns2)
1706 if (att1->atttypid != att2->atttypid)
1708 (
errcode(ERRCODE_DATATYPE_MISMATCH),
1709 errmsg(
"cannot compare dissimilar column types %s and %s at record column %d",
1717 if (!nulls1[i1] || !nulls2[i2])
1719 if (nulls1[i1] || nulls2[i2])
1726 result =
datum_image_eq(values1[i1], values2[i2], att1->attbyval, att2->attlen);
1742 if (i1 != ncolumns1 || i2 != ncolumns2)
1744 (
errcode(ERRCODE_DATATYPE_MISMATCH),
1745 errmsg(
"cannot compare record types with different numbers of columns")));
1823 ncolumns = tupdesc->
natts;
1836 if (my_extra == NULL ||
1839 fcinfo->flinfo->fn_extra =
1859 nulls = (
bool *)
palloc(ncolumns *
sizeof(
bool));
1862 for (
int i = 0;
i < ncolumns;
i++)
1870 if (att->attisdropped)
1877 if (typentry == NULL ||
1878 typentry->
type_id != att->atttypid)
1884 (
errcode(ERRCODE_UNDEFINED_FUNCTION),
1885 errmsg(
"could not identify a hash function for type %s",
1900 att->attcollation, NULL, NULL);
1901 locfcinfo->args[0].value =
values[
i];
1902 locfcinfo->args[0].isnull =
false;
1906 Assert(!locfcinfo->isnull);
1944 ncolumns = tupdesc->
natts;
1957 if (my_extra == NULL ||
1960 fcinfo->flinfo->fn_extra =
1980 nulls = (
bool *)
palloc(ncolumns *
sizeof(
bool));
1983 for (
int i = 0;
i < ncolumns;
i++)
1991 if (att->attisdropped)
1998 if (typentry == NULL ||
1999 typentry->
type_id != att->atttypid)
2005 (
errcode(ERRCODE_UNDEFINED_FUNCTION),
2006 errmsg(
"could not identify an extended hash function for type %s",
2021 att->attcollation, NULL, NULL);
2022 locfcinfo->args[0].value =
values[
i];
2023 locfcinfo->args[0].isnull =
false;
2025 locfcinfo->args[0].isnull =
false;
2029 Assert(!locfcinfo->isnull);
static uint32 element_hash(const void *key, Size keysize)
static Datum values[MAXATTR]
#define FORMAT_TYPE_ALLOW_INVALID
#define FLEXIBLE_ARRAY_MEMBER
#define MemSet(start, val, len)
#define OidIsValid(objectId)
bool datum_image_eq(Datum value1, Datum value2, bool typByVal, int typLen)
elog(ERROR, "%s: %s", p2, msg)
Size toast_raw_datum_size(Datum value)
int errdetail(const char *fmt,...)
int errcode(int sqlerrcode)
int errmsg(const char *fmt,...)
#define ereturn(context, dummy_value,...)
#define errsave(context,...)
#define ereport(elevel,...)
void fmgr_info_cxt(Oid functionId, FmgrInfo *finfo, MemoryContext mcxt)
Datum Int64GetDatum(int64 X)
bool InputFunctionCallSafe(FmgrInfo *flinfo, char *str, Oid typioparam, int32 typmod, fmNodePtr escontext, Datum *result)
bytea * SendFunctionCall(FmgrInfo *flinfo, Datum val)
char * OutputFunctionCall(FmgrInfo *flinfo, Datum val)
Datum ReceiveFunctionCall(FmgrInfo *flinfo, StringInfo buf, Oid typioparam, int32 typmod)
#define PG_FREE_IF_COPY(ptr, n)
#define PG_RETURN_UINT32(x)
#define PG_RETURN_BYTEA_P(x)
#define PG_GETARG_POINTER(n)
#define InitFunctionCallInfoData(Fcinfo, Flinfo, Nargs, Collation, Context, Resultinfo)
#define PG_RETURN_CSTRING(x)
#define LOCAL_FCINFO(name, nargs)
#define PG_GETARG_CSTRING(n)
#define PG_GETARG_INT64(n)
#define PG_DETOAST_DATUM_PACKED(datum)
#define PG_RETURN_UINT64(x)
#define PG_GETARG_HEAPTUPLEHEADER(n)
#define FunctionCallInvoke(fcinfo)
#define PG_RETURN_INT32(x)
#define PG_RETURN_HEAPTUPLEHEADER(x)
#define PG_GETARG_INT32(n)
#define PG_RETURN_BOOL(x)
HeapTuple heap_form_tuple(TupleDesc tupleDescriptor, Datum *values, bool *isnull)
void heap_deform_tuple(HeapTuple tuple, TupleDesc tupleDesc, Datum *values, bool *isnull)
void heap_freetuple(HeapTuple htup)
HeapTupleHeaderData * HeapTupleHeader
#define HeapTupleHeaderGetTypMod(tup)
#define HeapTupleHeaderGetTypeId(tup)
#define HeapTupleHeaderGetDatumLength(tup)
if(TABLE==NULL||TABLE_index==NULL)
static void ItemPointerSetInvalid(ItemPointerData *pointer)
Assert(fmt[strlen(fmt) - 1] !='\n')
void getTypeBinaryOutputInfo(Oid type, Oid *typSend, bool *typIsVarlena)
void getTypeOutputInfo(Oid type, Oid *typOutput, bool *typIsVarlena)
void getTypeInputInfo(Oid type, Oid *typInput, Oid *typIOParam)
void getTypeBinaryInputInfo(Oid type, Oid *typReceive, Oid *typIOParam)
void pfree(void *pointer)
void * MemoryContextAlloc(MemoryContext context, Size size)
FormData_pg_attribute * Form_pg_attribute
void check_stack_depth(void)
static uint32 DatumGetUInt32(Datum X)
static uint64 DatumGetUInt64(Datum X)
static bool DatumGetBool(Datum X)
static Pointer DatumGetPointer(Datum X)
static int32 DatumGetInt32(Datum X)
Datum record_eq(PG_FUNCTION_ARGS)
static int record_cmp(FunctionCallInfo fcinfo)
Datum record_image_ne(PG_FUNCTION_ARGS)
Datum record_image_ge(PG_FUNCTION_ARGS)
Datum hash_record_extended(PG_FUNCTION_ARGS)
Datum record_out(PG_FUNCTION_ARGS)
Datum record_ge(PG_FUNCTION_ARGS)
Datum btrecordcmp(PG_FUNCTION_ARGS)
Datum record_recv(PG_FUNCTION_ARGS)
Datum record_image_lt(PG_FUNCTION_ARGS)
struct ColumnIOData ColumnIOData
Datum hash_record(PG_FUNCTION_ARGS)
Datum record_image_gt(PG_FUNCTION_ARGS)
Datum btrecordimagecmp(PG_FUNCTION_ARGS)
Datum record_in(PG_FUNCTION_ARGS)
Datum record_send(PG_FUNCTION_ARGS)
Datum record_image_le(PG_FUNCTION_ARGS)
Datum record_ne(PG_FUNCTION_ARGS)
struct RecordCompareData RecordCompareData
struct ColumnCompareData ColumnCompareData
Datum record_le(PG_FUNCTION_ARGS)
Datum record_image_eq(PG_FUNCTION_ARGS)
static int record_image_cmp(FunctionCallInfo fcinfo)
struct RecordIOData RecordIOData
Datum record_lt(PG_FUNCTION_ARGS)
Datum record_gt(PG_FUNCTION_ARGS)
void resetStringInfo(StringInfo str)
void appendStringInfoChar(StringInfo str, char ch)
void initStringInfo(StringInfo str)
StringInfoData * StringInfo
#define appendStringInfoCharMacro(str, ch)
TypeCacheEntry * typentry
ColumnCompareData columns[FLEXIBLE_ARRAY_MEMBER]
ColumnIOData columns[FLEXIBLE_ARRAY_MEMBER]
FmgrInfo hash_extended_proc_finfo
#define FirstGenbkiObjectId
#define ReleaseTupleDesc(tupdesc)
#define TupleDescAttr(tupdesc, i)
TupleDesc lookup_rowtype_tupdesc(Oid type_id, int32 typmod)
TypeCacheEntry * lookup_type_cache(Oid type_id, int flags)
#define TYPECACHE_HASH_PROC_FINFO
#define TYPECACHE_EQ_OPR_FINFO
#define TYPECACHE_HASH_EXTENDED_PROC_FINFO
#define TYPECACHE_CMP_PROC_FINFO