Commit 5740be6d authored by Tom Lane's avatar Tom Lane

Some more FLEXIBLE_ARRAY_MEMBER hacking.

parent 9aa53bbd
...@@ -43,7 +43,7 @@ typedef struct RecordIOData ...@@ -43,7 +43,7 @@ typedef struct RecordIOData
Oid record_type; Oid record_type;
int32 record_typmod; int32 record_typmod;
int ncolumns; int ncolumns;
ColumnIOData columns[1]; /* VARIABLE LENGTH ARRAY */ ColumnIOData columns[FLEXIBLE_ARRAY_MEMBER];
} RecordIOData; } RecordIOData;
/* /*
...@@ -61,7 +61,7 @@ typedef struct RecordCompareData ...@@ -61,7 +61,7 @@ typedef struct RecordCompareData
int32 record1_typmod; int32 record1_typmod;
Oid record2_type; Oid record2_type;
int32 record2_typmod; int32 record2_typmod;
ColumnCompareData columns[1]; /* VARIABLE LENGTH ARRAY */ ColumnCompareData columns[FLEXIBLE_ARRAY_MEMBER];
} RecordCompareData; } RecordCompareData;
...@@ -120,8 +120,8 @@ record_in(PG_FUNCTION_ARGS) ...@@ -120,8 +120,8 @@ record_in(PG_FUNCTION_ARGS)
{ {
fcinfo->flinfo->fn_extra = fcinfo->flinfo->fn_extra =
MemoryContextAlloc(fcinfo->flinfo->fn_mcxt, MemoryContextAlloc(fcinfo->flinfo->fn_mcxt,
sizeof(RecordIOData) - sizeof(ColumnIOData) offsetof(RecordIOData, columns) +
+ ncolumns * sizeof(ColumnIOData)); ncolumns * sizeof(ColumnIOData));
my_extra = (RecordIOData *) fcinfo->flinfo->fn_extra; my_extra = (RecordIOData *) fcinfo->flinfo->fn_extra;
my_extra->record_type = InvalidOid; my_extra->record_type = InvalidOid;
my_extra->record_typmod = 0; my_extra->record_typmod = 0;
...@@ -131,8 +131,8 @@ record_in(PG_FUNCTION_ARGS) ...@@ -131,8 +131,8 @@ record_in(PG_FUNCTION_ARGS)
my_extra->record_typmod != tupTypmod) my_extra->record_typmod != tupTypmod)
{ {
MemSet(my_extra, 0, MemSet(my_extra, 0,
sizeof(RecordIOData) - sizeof(ColumnIOData) offsetof(RecordIOData, columns) +
+ ncolumns * sizeof(ColumnIOData)); ncolumns * sizeof(ColumnIOData));
my_extra->record_type = tupType; my_extra->record_type = tupType;
my_extra->record_typmod = tupTypmod; my_extra->record_typmod = tupTypmod;
my_extra->ncolumns = ncolumns; my_extra->ncolumns = ncolumns;
...@@ -334,8 +334,8 @@ record_out(PG_FUNCTION_ARGS) ...@@ -334,8 +334,8 @@ record_out(PG_FUNCTION_ARGS)
{ {
fcinfo->flinfo->fn_extra = fcinfo->flinfo->fn_extra =
MemoryContextAlloc(fcinfo->flinfo->fn_mcxt, MemoryContextAlloc(fcinfo->flinfo->fn_mcxt,
sizeof(RecordIOData) - sizeof(ColumnIOData) offsetof(RecordIOData, columns) +
+ ncolumns * sizeof(ColumnIOData)); ncolumns * sizeof(ColumnIOData));
my_extra = (RecordIOData *) fcinfo->flinfo->fn_extra; my_extra = (RecordIOData *) fcinfo->flinfo->fn_extra;
my_extra->record_type = InvalidOid; my_extra->record_type = InvalidOid;
my_extra->record_typmod = 0; my_extra->record_typmod = 0;
...@@ -345,8 +345,8 @@ record_out(PG_FUNCTION_ARGS) ...@@ -345,8 +345,8 @@ record_out(PG_FUNCTION_ARGS)
my_extra->record_typmod != tupTypmod) my_extra->record_typmod != tupTypmod)
{ {
MemSet(my_extra, 0, MemSet(my_extra, 0,
sizeof(RecordIOData) - sizeof(ColumnIOData) offsetof(RecordIOData, columns) +
+ ncolumns * sizeof(ColumnIOData)); ncolumns * sizeof(ColumnIOData));
my_extra->record_type = tupType; my_extra->record_type = tupType;
my_extra->record_typmod = tupTypmod; my_extra->record_typmod = tupTypmod;
my_extra->ncolumns = ncolumns; my_extra->ncolumns = ncolumns;
...@@ -489,8 +489,8 @@ record_recv(PG_FUNCTION_ARGS) ...@@ -489,8 +489,8 @@ record_recv(PG_FUNCTION_ARGS)
{ {
fcinfo->flinfo->fn_extra = fcinfo->flinfo->fn_extra =
MemoryContextAlloc(fcinfo->flinfo->fn_mcxt, MemoryContextAlloc(fcinfo->flinfo->fn_mcxt,
sizeof(RecordIOData) - sizeof(ColumnIOData) offsetof(RecordIOData, columns) +
+ ncolumns * sizeof(ColumnIOData)); ncolumns * sizeof(ColumnIOData));
my_extra = (RecordIOData *) fcinfo->flinfo->fn_extra; my_extra = (RecordIOData *) fcinfo->flinfo->fn_extra;
my_extra->record_type = InvalidOid; my_extra->record_type = InvalidOid;
my_extra->record_typmod = 0; my_extra->record_typmod = 0;
...@@ -500,8 +500,8 @@ record_recv(PG_FUNCTION_ARGS) ...@@ -500,8 +500,8 @@ record_recv(PG_FUNCTION_ARGS)
my_extra->record_typmod != tupTypmod) my_extra->record_typmod != tupTypmod)
{ {
MemSet(my_extra, 0, MemSet(my_extra, 0,
sizeof(RecordIOData) - sizeof(ColumnIOData) offsetof(RecordIOData, columns) +
+ ncolumns * sizeof(ColumnIOData)); ncolumns * sizeof(ColumnIOData));
my_extra->record_type = tupType; my_extra->record_type = tupType;
my_extra->record_typmod = tupTypmod; my_extra->record_typmod = tupTypmod;
my_extra->ncolumns = ncolumns; my_extra->ncolumns = ncolumns;
...@@ -677,8 +677,8 @@ record_send(PG_FUNCTION_ARGS) ...@@ -677,8 +677,8 @@ record_send(PG_FUNCTION_ARGS)
{ {
fcinfo->flinfo->fn_extra = fcinfo->flinfo->fn_extra =
MemoryContextAlloc(fcinfo->flinfo->fn_mcxt, MemoryContextAlloc(fcinfo->flinfo->fn_mcxt,
sizeof(RecordIOData) - sizeof(ColumnIOData) offsetof(RecordIOData, columns) +
+ ncolumns * sizeof(ColumnIOData)); ncolumns * sizeof(ColumnIOData));
my_extra = (RecordIOData *) fcinfo->flinfo->fn_extra; my_extra = (RecordIOData *) fcinfo->flinfo->fn_extra;
my_extra->record_type = InvalidOid; my_extra->record_type = InvalidOid;
my_extra->record_typmod = 0; my_extra->record_typmod = 0;
...@@ -688,8 +688,8 @@ record_send(PG_FUNCTION_ARGS) ...@@ -688,8 +688,8 @@ record_send(PG_FUNCTION_ARGS)
my_extra->record_typmod != tupTypmod) my_extra->record_typmod != tupTypmod)
{ {
MemSet(my_extra, 0, MemSet(my_extra, 0,
sizeof(RecordIOData) - sizeof(ColumnIOData) offsetof(RecordIOData, columns) +
+ ncolumns * sizeof(ColumnIOData)); ncolumns * sizeof(ColumnIOData));
my_extra->record_type = tupType; my_extra->record_type = tupType;
my_extra->record_typmod = tupTypmod; my_extra->record_typmod = tupTypmod;
my_extra->ncolumns = ncolumns; my_extra->ncolumns = ncolumns;
...@@ -829,8 +829,8 @@ record_cmp(FunctionCallInfo fcinfo) ...@@ -829,8 +829,8 @@ record_cmp(FunctionCallInfo fcinfo)
{ {
fcinfo->flinfo->fn_extra = fcinfo->flinfo->fn_extra =
MemoryContextAlloc(fcinfo->flinfo->fn_mcxt, MemoryContextAlloc(fcinfo->flinfo->fn_mcxt,
sizeof(RecordCompareData) - sizeof(ColumnCompareData) offsetof(RecordCompareData, columns) +
+ ncols * sizeof(ColumnCompareData)); ncols * sizeof(ColumnCompareData));
my_extra = (RecordCompareData *) fcinfo->flinfo->fn_extra; my_extra = (RecordCompareData *) fcinfo->flinfo->fn_extra;
my_extra->ncolumns = ncols; my_extra->ncolumns = ncols;
my_extra->record1_type = InvalidOid; my_extra->record1_type = InvalidOid;
...@@ -1065,8 +1065,8 @@ record_eq(PG_FUNCTION_ARGS) ...@@ -1065,8 +1065,8 @@ record_eq(PG_FUNCTION_ARGS)
{ {
fcinfo->flinfo->fn_extra = fcinfo->flinfo->fn_extra =
MemoryContextAlloc(fcinfo->flinfo->fn_mcxt, MemoryContextAlloc(fcinfo->flinfo->fn_mcxt,
sizeof(RecordCompareData) - sizeof(ColumnCompareData) offsetof(RecordCompareData, columns) +
+ ncols * sizeof(ColumnCompareData)); ncols * sizeof(ColumnCompareData));
my_extra = (RecordCompareData *) fcinfo->flinfo->fn_extra; my_extra = (RecordCompareData *) fcinfo->flinfo->fn_extra;
my_extra->ncolumns = ncols; my_extra->ncolumns = ncols;
my_extra->record1_type = InvalidOid; my_extra->record1_type = InvalidOid;
...@@ -1324,8 +1324,8 @@ record_image_cmp(FunctionCallInfo fcinfo) ...@@ -1324,8 +1324,8 @@ record_image_cmp(FunctionCallInfo fcinfo)
{ {
fcinfo->flinfo->fn_extra = fcinfo->flinfo->fn_extra =
MemoryContextAlloc(fcinfo->flinfo->fn_mcxt, MemoryContextAlloc(fcinfo->flinfo->fn_mcxt,
sizeof(RecordCompareData) - sizeof(ColumnCompareData) offsetof(RecordCompareData, columns) +
+ ncols * sizeof(ColumnCompareData)); ncols * sizeof(ColumnCompareData));
my_extra = (RecordCompareData *) fcinfo->flinfo->fn_extra; my_extra = (RecordCompareData *) fcinfo->flinfo->fn_extra;
my_extra->ncolumns = ncols; my_extra->ncolumns = ncols;
my_extra->record1_type = InvalidOid; my_extra->record1_type = InvalidOid;
...@@ -1601,8 +1601,8 @@ record_image_eq(PG_FUNCTION_ARGS) ...@@ -1601,8 +1601,8 @@ record_image_eq(PG_FUNCTION_ARGS)
{ {
fcinfo->flinfo->fn_extra = fcinfo->flinfo->fn_extra =
MemoryContextAlloc(fcinfo->flinfo->fn_mcxt, MemoryContextAlloc(fcinfo->flinfo->fn_mcxt,
sizeof(RecordCompareData) - sizeof(ColumnCompareData) offsetof(RecordCompareData, columns) +
+ ncols * sizeof(ColumnCompareData)); ncols * sizeof(ColumnCompareData));
my_extra = (RecordCompareData *) fcinfo->flinfo->fn_extra; my_extra = (RecordCompareData *) fcinfo->flinfo->fn_extra;
my_extra->ncolumns = ncols; my_extra->ncolumns = ncols;
my_extra->record1_type = InvalidOid; my_extra->record1_type = InvalidOid;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment