79 Node *escontext = fcinfo->context;
84 bool needComma =
false;
102 if (tupType == RECORDOID && tupTypmod < 0)
104 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
105 errmsg(
"input of anonymous composite types is not implemented")));
113 ncolumns = tupdesc->
natts;
120 if (my_extra == NULL ||
123 fcinfo->flinfo->fn_extra =
144 nulls = (
bool *)
palloc(ncolumns *
sizeof(
bool));
152 while (*ptr && isspace((
unsigned char) *ptr))
157 (
errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
158 errmsg(
"malformed record literal: \"%s\"",
string),
159 errdetail(
"Missing left parenthesis.")));
165 for (
i = 0;
i < ncolumns;
i++)
169 Oid column_type = att->atttypid;
173 if (att->attisdropped)
189 (
errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
190 errmsg(
"malformed record literal: \"%s\"",
string),
197 if (*ptr ==
',' || *ptr ==
')')
205 bool inquote =
false;
208 while (inquote || !(*ptr ==
',' || *ptr ==
')'))
215 (
errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
216 errmsg(
"malformed record literal: \"%s\"",
226 (
errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
227 errmsg(
"malformed record literal: \"%s\"",
238 else if (*ptr ==
'"')
250 column_data =
buf.data;
284 (
errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
285 errmsg(
"malformed record literal: \"%s\"",
string),
290 while (*ptr && isspace((
unsigned char) *ptr))
295 (
errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
296 errmsg(
"malformed record literal: \"%s\"",
string),
297 errdetail(
"Junk after right parenthesis.")));
337 bool needComma =
false;
350 ncolumns = tupdesc->
natts;
363 if (my_extra == NULL ||
366 fcinfo->flinfo->fn_extra =
387 nulls = (
bool *)
palloc(ncolumns *
sizeof(
bool));
397 for (
i = 0;
i < ncolumns;
i++)
401 Oid column_type = att->atttypid;
408 if (att->attisdropped)
438 nq = (
value[0] ==
'\0');
439 for (tmp =
value; *tmp; tmp++)
443 if (ch ==
'"' || ch ==
'\\' ||
444 ch ==
'(' || ch ==
')' || ch ==
',' ||
445 isspace((
unsigned char) ch))
455 for (tmp =
value; *tmp; tmp++)
459 if (ch ==
'"' || ch ==
'\\')
506 if (tupType == RECORDOID && tupTypmod < 0)
508 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
509 errmsg(
"input of anonymous composite types is not implemented")));
512 ncolumns = tupdesc->
natts;
519 if (my_extra == NULL ||
522 fcinfo->flinfo->fn_extra =
543 nulls = (
bool *)
palloc(ncolumns *
sizeof(
bool));
550 for (
i = 0;
i < ncolumns;
i++)
555 if (usercols != validcols)
557 (
errcode(ERRCODE_DATATYPE_MISMATCH),
558 errmsg(
"wrong number of columns: %d, expected %d",
559 usercols, validcols)));
562 for (
i = 0;
i < ncolumns;
i++)
566 Oid column_type = att->atttypid;
573 if (att->attisdropped)
594 if (coltypoid != column_type &&
598 (
errcode(ERRCODE_DATATYPE_MISMATCH),
599 errmsg(
"binary data has type %u (%s) instead of expected %u (%s) in record column %d",
610 if (itemlen < -1 || itemlen > (
buf->len -
buf->cursor))
612 (
errcode(ERRCODE_INVALID_BINARY_REPRESENTATION),
613 errmsg(
"insufficient data left in message")));
630 strbuff = &
buf->data[
buf->cursor];
631 buf->cursor += itemlen;
657 if (item_buf.
cursor != itemlen)
659 (
errcode(ERRCODE_INVALID_BINARY_REPRESENTATION),
660 errmsg(
"improper binary format in record column %d",
708 ncolumns = tupdesc->
natts;
721 if (my_extra == NULL ||
724 fcinfo->flinfo->fn_extra =
745 nulls = (
bool *)
palloc(ncolumns *
sizeof(
bool));
755 for (
i = 0;
i < ncolumns;
i++)
762 for (
i = 0;
i < ncolumns;
i++)
766 Oid column_type = att->atttypid;
771 if (att->attisdropped)
854 ncolumns1 = tupdesc1->
natts;
858 ncolumns2 = tupdesc2->
natts;
874 ncols =
Max(ncolumns1, ncolumns2);
876 if (my_extra == NULL ||
905 nulls1 = (
bool *)
palloc(ncolumns1 *
sizeof(
bool));
908 nulls2 = (
bool *)
palloc(ncolumns2 *
sizeof(
bool));
917 while (i1 < ncolumns1 || i2 < ncolumns2)
927 if (i1 < ncolumns1 &&
TupleDescAttr(tupdesc1, i1)->attisdropped)
932 if (i2 < ncolumns2 &&
TupleDescAttr(tupdesc2, i2)->attisdropped)
937 if (i1 >= ncolumns1 || i2 >= ncolumns2)
946 if (att1->atttypid != att2->atttypid)
948 (
errcode(ERRCODE_DATATYPE_MISMATCH),
949 errmsg(
"cannot compare dissimilar column types %s and %s at record column %d",
958 collation = att1->attcollation;
959 if (collation != att2->attcollation)
966 if (typentry == NULL ||
967 typentry->
type_id != att1->atttypid)
973 (
errcode(ERRCODE_UNDEFINED_FUNCTION),
974 errmsg(
"could not identify a comparison function for type %s",
982 if (!nulls1[i1] || !nulls2[i2])
1002 collation, NULL, NULL);
1003 locfcinfo->args[0].value = values1[i1];
1004 locfcinfo->args[0].isnull =
false;
1005 locfcinfo->args[1].value = values2[i2];
1006 locfcinfo->args[1].isnull =
false;
1010 Assert(!locfcinfo->isnull);
1018 else if (cmpresult > 0)
1037 if (i1 != ncolumns1 || i2 != ncolumns2)
1039 (
errcode(ERRCODE_DATATYPE_MISMATCH),
1040 errmsg(
"cannot compare record types with different numbers of columns")));
1098 ncolumns1 = tupdesc1->
natts;
1102 ncolumns2 = tupdesc2->
natts;
1118 ncols =
Max(ncolumns1, ncolumns2);
1120 if (my_extra == NULL ||
1123 fcinfo->flinfo->fn_extra =
1149 nulls1 = (
bool *)
palloc(ncolumns1 *
sizeof(
bool));
1152 nulls2 = (
bool *)
palloc(ncolumns2 *
sizeof(
bool));
1161 while (i1 < ncolumns1 || i2 < ncolumns2)
1173 if (i1 < ncolumns1 &&
TupleDescAttr(tupdesc1, i1)->attisdropped)
1178 if (i2 < ncolumns2 &&
TupleDescAttr(tupdesc2, i2)->attisdropped)
1183 if (i1 >= ncolumns1 || i2 >= ncolumns2)
1192 if (att1->atttypid != att2->atttypid)
1194 (
errcode(ERRCODE_DATATYPE_MISMATCH),
1195 errmsg(
"cannot compare dissimilar column types %s and %s at record column %d",
1204 collation = att1->attcollation;
1205 if (collation != att2->attcollation)
1212 if (typentry == NULL ||
1213 typentry->
type_id != att1->atttypid)
1219 (
errcode(ERRCODE_UNDEFINED_FUNCTION),
1220 errmsg(
"could not identify an equality operator for type %s",
1228 if (!nulls1[i1] || !nulls2[i2])
1230 if (nulls1[i1] || nulls2[i2])
1238 collation, NULL, NULL);
1239 locfcinfo->args[0].value = values1[i1];
1240 locfcinfo->args[0].isnull =
false;
1241 locfcinfo->args[1].value = values2[i2];
1242 locfcinfo->args[1].isnull =
false;
1244 if (locfcinfo->isnull || !oprresult)
1262 if (i1 != ncolumns1 || i2 != ncolumns2)
1264 (
errcode(ERRCODE_DATATYPE_MISMATCH),
1265 errmsg(
"cannot compare record types with different numbers of columns")));
1378 ncolumns1 = tupdesc1->
natts;
1382 ncolumns2 = tupdesc2->
natts;
1398 ncols =
Max(ncolumns1, ncolumns2);
1400 if (my_extra == NULL ||
1429 nulls1 = (
bool *)
palloc(ncolumns1 *
sizeof(
bool));
1432 nulls2 = (
bool *)
palloc(ncolumns2 *
sizeof(
bool));
1441 while (i1 < ncolumns1 || i2 < ncolumns2)
1449 if (i1 < ncolumns1 &&
TupleDescAttr(tupdesc1, i1)->attisdropped)
1454 if (i2 < ncolumns2 &&
TupleDescAttr(tupdesc2, i2)->attisdropped)
1459 if (i1 >= ncolumns1 || i2 >= ncolumns2)
1468 if (att1->atttypid != att2->atttypid)
1470 (
errcode(ERRCODE_DATATYPE_MISMATCH),
1471 errmsg(
"cannot compare dissimilar column types %s and %s at record column %d",
1480 Assert(att1->attlen == att2->attlen);
1485 if (!nulls1[i1] || !nulls2[i2])
1505 if (values1[i1] != values2[i2])
1506 cmpresult = (values1[i1] < values2[i2]) ? -1 : 1;
1508 else if (att1->attlen > 0)
1514 else if (att1->attlen == -1)
1529 if ((cmpresult == 0) && (len1 != len2))
1530 cmpresult = (len1 < len2) ? -1 : 1;
1538 elog(
ERROR,
"unexpected attlen: %d", att1->attlen);
1546 else if (cmpresult > 0)
1565 if (i1 != ncolumns1 || i2 != ncolumns2)
1567 (
errcode(ERRCODE_DATATYPE_MISMATCH),
1568 errmsg(
"cannot compare record types with different numbers of columns")));
1624 ncolumns1 = tupdesc1->
natts;
1628 ncolumns2 = tupdesc2->
natts;
1644 ncols =
Max(ncolumns1, ncolumns2);
1646 if (my_extra == NULL ||
1649 fcinfo->flinfo->fn_extra =
1675 nulls1 = (
bool *)
palloc(ncolumns1 *
sizeof(
bool));
1678 nulls2 = (
bool *)
palloc(ncolumns2 *
sizeof(
bool));
1687 while (i1 < ncolumns1 || i2 < ncolumns2)
1695 if (i1 < ncolumns1 &&
TupleDescAttr(tupdesc1, i1)->attisdropped)
1700 if (i2 < ncolumns2 &&
TupleDescAttr(tupdesc2, i2)->attisdropped)
1705 if (i1 >= ncolumns1 || i2 >= ncolumns2)
1714 if (att1->atttypid != att2->atttypid)
1716 (
errcode(ERRCODE_DATATYPE_MISMATCH),
1717 errmsg(
"cannot compare dissimilar column types %s and %s at record column %d",
1725 if (!nulls1[i1] || !nulls2[i2])
1727 if (nulls1[i1] || nulls2[i2])
1734 result =
datum_image_eq(values1[i1], values2[i2], att1->attbyval, att2->attlen);
1750 if (i1 != ncolumns1 || i2 != ncolumns2)
1752 (
errcode(ERRCODE_DATATYPE_MISMATCH),
1753 errmsg(
"cannot compare record types with different numbers of columns")));
1831 ncolumns = tupdesc->
natts;
1844 if (my_extra == NULL ||
1847 fcinfo->flinfo->fn_extra =
1867 nulls = (
bool *)
palloc(ncolumns *
sizeof(
bool));
1870 for (
int i = 0;
i < ncolumns;
i++)
1878 if (att->attisdropped)
1885 if (typentry == NULL ||
1886 typentry->
type_id != att->atttypid)
1892 (
errcode(ERRCODE_UNDEFINED_FUNCTION),
1893 errmsg(
"could not identify a hash function for type %s",
1908 att->attcollation, NULL, NULL);
1909 locfcinfo->args[0].value =
values[
i];
1910 locfcinfo->args[0].isnull =
false;
1914 Assert(!locfcinfo->isnull);
1952 ncolumns = tupdesc->
natts;
1965 if (my_extra == NULL ||
1968 fcinfo->flinfo->fn_extra =
1988 nulls = (
bool *)
palloc(ncolumns *
sizeof(
bool));
1991 for (
int i = 0;
i < ncolumns;
i++)
1999 if (att->attisdropped)
2006 if (typentry == NULL ||
2007 typentry->
type_id != att->atttypid)
2013 (
errcode(ERRCODE_UNDEFINED_FUNCTION),
2014 errmsg(
"could not identify an extended hash function for type %s",
2029 att->attcollation, NULL, NULL);
2030 locfcinfo->args[0].value =
values[
i];
2031 locfcinfo->args[0].isnull =
false;
2033 locfcinfo->args[0].isnull =
false;
2037 Assert(!locfcinfo->isnull);
static uint32 element_hash(const void *key, Size keysize)
static Datum values[MAXATTR]
#define FORMAT_TYPE_ALLOW_INVALID
#define Assert(condition)
#define FLEXIBLE_ARRAY_MEMBER
#define MemSet(start, val, len)
#define OidIsValid(objectId)
bool datum_image_eq(Datum value1, Datum value2, bool typByVal, int typLen)
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 PG_GETARG_DATUM(n)
#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_DATUM(x)
#define PG_RETURN_BOOL(x)
HeapTuple heap_form_tuple(TupleDesc tupleDescriptor, const Datum *values, const 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)
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_larger(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_smaller(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)
static void initReadOnlyStringInfo(StringInfo str, char *data, int len)
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