Remove RangeIOData->typiofunc

We used to carry the I/O function OID in RangeIOData, but it's not used
for anything.  Since the struct is not exposed to the world anyway, we
can simplify it a bit.  Also, rename the FmgrInfo member to match
the accompanying 'typioparam' and put them in a more sensible order.

Reviewed by Tom Lane and Paul Jungwirth.

Discussion: https://postgr.es/m/20200304215711.GA8732@alvherre.pgsql
This commit is contained in:
Alvaro Herrera 2020-03-05 11:35:02 -03:00
parent 0065174324
commit a77315fdf2
No known key found for this signature in database
GPG Key ID: 1C20ACB9D5C564AE
1 changed files with 13 additions and 13 deletions

View File

@ -49,9 +49,8 @@
typedef struct RangeIOData typedef struct RangeIOData
{ {
TypeCacheEntry *typcache; /* range type's typcache entry */ TypeCacheEntry *typcache; /* range type's typcache entry */
Oid typiofunc; /* element type's I/O function */ FmgrInfo typioproc; /* element type's I/O function */
Oid typioparam; /* element type's I/O parameter */ Oid typioparam; /* element type's I/O parameter */
FmgrInfo proc; /* lookup result for typiofunc */
} RangeIOData; } RangeIOData;
@ -100,10 +99,10 @@ range_in(PG_FUNCTION_ARGS)
/* call element type's input function */ /* call element type's input function */
if (RANGE_HAS_LBOUND(flags)) if (RANGE_HAS_LBOUND(flags))
lower.val = InputFunctionCall(&cache->proc, lbound_str, lower.val = InputFunctionCall(&cache->typioproc, lbound_str,
cache->typioparam, typmod); cache->typioparam, typmod);
if (RANGE_HAS_UBOUND(flags)) if (RANGE_HAS_UBOUND(flags))
upper.val = InputFunctionCall(&cache->proc, ubound_str, upper.val = InputFunctionCall(&cache->typioproc, ubound_str,
cache->typioparam, typmod); cache->typioparam, typmod);
lower.infinite = (flags & RANGE_LB_INF) != 0; lower.infinite = (flags & RANGE_LB_INF) != 0;
@ -142,9 +141,9 @@ range_out(PG_FUNCTION_ARGS)
/* call element type's output function */ /* call element type's output function */
if (RANGE_HAS_LBOUND(flags)) if (RANGE_HAS_LBOUND(flags))
lbound_str = OutputFunctionCall(&cache->proc, lower.val); lbound_str = OutputFunctionCall(&cache->typioproc, lower.val);
if (RANGE_HAS_UBOUND(flags)) if (RANGE_HAS_UBOUND(flags))
ubound_str = OutputFunctionCall(&cache->proc, upper.val); ubound_str = OutputFunctionCall(&cache->typioproc, upper.val);
/* construct result string */ /* construct result string */
output_str = range_deparse(flags, lbound_str, ubound_str); output_str = range_deparse(flags, lbound_str, ubound_str);
@ -199,7 +198,7 @@ range_recv(PG_FUNCTION_ARGS)
initStringInfo(&bound_buf); initStringInfo(&bound_buf);
appendBinaryStringInfo(&bound_buf, bound_data, bound_len); appendBinaryStringInfo(&bound_buf, bound_data, bound_len);
lower.val = ReceiveFunctionCall(&cache->proc, lower.val = ReceiveFunctionCall(&cache->typioproc,
&bound_buf, &bound_buf,
cache->typioparam, cache->typioparam,
typmod); typmod);
@ -217,7 +216,7 @@ range_recv(PG_FUNCTION_ARGS)
initStringInfo(&bound_buf); initStringInfo(&bound_buf);
appendBinaryStringInfo(&bound_buf, bound_data, bound_len); appendBinaryStringInfo(&bound_buf, bound_data, bound_len);
upper.val = ReceiveFunctionCall(&cache->proc, upper.val = ReceiveFunctionCall(&cache->typioproc,
&bound_buf, &bound_buf,
cache->typioparam, cache->typioparam,
typmod); typmod);
@ -268,7 +267,7 @@ range_send(PG_FUNCTION_ARGS)
if (RANGE_HAS_LBOUND(flags)) if (RANGE_HAS_LBOUND(flags))
{ {
Datum bound = PointerGetDatum(SendFunctionCall(&cache->proc, Datum bound = PointerGetDatum(SendFunctionCall(&cache->typioproc,
lower.val)); lower.val));
uint32 bound_len = VARSIZE(bound) - VARHDRSZ; uint32 bound_len = VARSIZE(bound) - VARHDRSZ;
char *bound_data = VARDATA(bound); char *bound_data = VARDATA(bound);
@ -279,7 +278,7 @@ range_send(PG_FUNCTION_ARGS)
if (RANGE_HAS_UBOUND(flags)) if (RANGE_HAS_UBOUND(flags))
{ {
Datum bound = PointerGetDatum(SendFunctionCall(&cache->proc, Datum bound = PointerGetDatum(SendFunctionCall(&cache->typioproc,
upper.val)); upper.val));
uint32 bound_len = VARSIZE(bound) - VARHDRSZ; uint32 bound_len = VARSIZE(bound) - VARHDRSZ;
char *bound_data = VARDATA(bound); char *bound_data = VARDATA(bound);
@ -309,6 +308,7 @@ get_range_io_data(FunctionCallInfo fcinfo, Oid rngtypid, IOFuncSelector func)
bool typbyval; bool typbyval;
char typalign; char typalign;
char typdelim; char typdelim;
Oid typiofunc;
cache = (RangeIOData *) MemoryContextAlloc(fcinfo->flinfo->fn_mcxt, cache = (RangeIOData *) MemoryContextAlloc(fcinfo->flinfo->fn_mcxt,
sizeof(RangeIOData)); sizeof(RangeIOData));
@ -324,9 +324,9 @@ get_range_io_data(FunctionCallInfo fcinfo, Oid rngtypid, IOFuncSelector func)
&typalign, &typalign,
&typdelim, &typdelim,
&cache->typioparam, &cache->typioparam,
&cache->typiofunc); &typiofunc);
if (!OidIsValid(cache->typiofunc)) if (!OidIsValid(typiofunc))
{ {
/* this could only happen for receive or send */ /* this could only happen for receive or send */
if (func == IOFunc_receive) if (func == IOFunc_receive)
@ -340,7 +340,7 @@ get_range_io_data(FunctionCallInfo fcinfo, Oid rngtypid, IOFuncSelector func)
errmsg("no binary output function available for type %s", errmsg("no binary output function available for type %s",
format_type_be(cache->typcache->rngelemtype->type_id)))); format_type_be(cache->typcache->rngelemtype->type_id))));
} }
fmgr_info_cxt(cache->typiofunc, &cache->proc, fmgr_info_cxt(typiofunc, &cache->typioproc,
fcinfo->flinfo->fn_mcxt); fcinfo->flinfo->fn_mcxt);
fcinfo->flinfo->fn_extra = (void *) cache; fcinfo->flinfo->fn_extra = (void *) cache;