mirror of
https://github.com/postgres/postgres.git
synced 2025-04-21 12:05:57 +03:00
Switch some system functions to use get_call_result_type()
This shaves some code by replacing the combinations of CreateTemplateTupleDesc()/TupleDescInitEntry() hardcoding a mapping of the attributes listed in pg_proc.dat by get_call_result_type() to build the TupleDesc needed for the rows generated. get_call_result_type() is more expensive than the former style, but this removes some duplication with the lists of OUT parameters (pg_proc.dat and the attributes hardcoded in these code paths). This is applied to functions that are not considered as critical (aka that could be called repeatedly for monitoring purposes). Author: Bharath Rupireddy Reviewed-by: Robert Haas, Álvaro Herrera, Tom Lane, Michael Paquier Discussion: https://postgr.es/m/CALj2ACV23HW5HP5hFjd89FNS-z5X8r2jNXdMXcpN2BgTtKd87w@mail.gmail.com
This commit is contained in:
parent
f03bd5717e
commit
22e3b55805
@ -38,7 +38,6 @@ PG_MODULE_MAGIC;
|
|||||||
PG_FUNCTION_INFO_V1(pg_old_snapshot_time_mapping);
|
PG_FUNCTION_INFO_V1(pg_old_snapshot_time_mapping);
|
||||||
|
|
||||||
static OldSnapshotTimeMapping *GetOldSnapshotTimeMapping(void);
|
static OldSnapshotTimeMapping *GetOldSnapshotTimeMapping(void);
|
||||||
static TupleDesc MakeOldSnapshotTimeMappingTupleDesc(void);
|
|
||||||
static HeapTuple MakeOldSnapshotTimeMappingTuple(TupleDesc tupdesc,
|
static HeapTuple MakeOldSnapshotTimeMappingTuple(TupleDesc tupdesc,
|
||||||
OldSnapshotTimeMapping *mapping);
|
OldSnapshotTimeMapping *mapping);
|
||||||
|
|
||||||
@ -54,12 +53,15 @@ pg_old_snapshot_time_mapping(PG_FUNCTION_ARGS)
|
|||||||
if (SRF_IS_FIRSTCALL())
|
if (SRF_IS_FIRSTCALL())
|
||||||
{
|
{
|
||||||
MemoryContext oldcontext;
|
MemoryContext oldcontext;
|
||||||
|
TupleDesc tupdesc;
|
||||||
|
|
||||||
funcctx = SRF_FIRSTCALL_INIT();
|
funcctx = SRF_FIRSTCALL_INIT();
|
||||||
oldcontext = MemoryContextSwitchTo(funcctx->multi_call_memory_ctx);
|
oldcontext = MemoryContextSwitchTo(funcctx->multi_call_memory_ctx);
|
||||||
mapping = GetOldSnapshotTimeMapping();
|
mapping = GetOldSnapshotTimeMapping();
|
||||||
funcctx->user_fctx = mapping;
|
funcctx->user_fctx = mapping;
|
||||||
funcctx->tuple_desc = MakeOldSnapshotTimeMappingTupleDesc();
|
if (get_call_result_type(fcinfo, NULL, &tupdesc) != TYPEFUNC_COMPOSITE)
|
||||||
|
elog(ERROR, "return type must be a row type");
|
||||||
|
funcctx->tuple_desc = tupdesc;
|
||||||
MemoryContextSwitchTo(oldcontext);
|
MemoryContextSwitchTo(oldcontext);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -101,26 +103,6 @@ GetOldSnapshotTimeMapping(void)
|
|||||||
return mapping;
|
return mapping;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* Build a tuple descriptor for the pg_old_snapshot_time_mapping() SRF.
|
|
||||||
*/
|
|
||||||
static TupleDesc
|
|
||||||
MakeOldSnapshotTimeMappingTupleDesc(void)
|
|
||||||
{
|
|
||||||
TupleDesc tupdesc;
|
|
||||||
|
|
||||||
tupdesc = CreateTemplateTupleDesc(NUM_TIME_MAPPING_COLUMNS);
|
|
||||||
|
|
||||||
TupleDescInitEntry(tupdesc, (AttrNumber) 1, "array_offset",
|
|
||||||
INT4OID, -1, 0);
|
|
||||||
TupleDescInitEntry(tupdesc, (AttrNumber) 2, "end_timestamp",
|
|
||||||
TIMESTAMPTZOID, -1, 0);
|
|
||||||
TupleDescInitEntry(tupdesc, (AttrNumber) 3, "newest_xmin",
|
|
||||||
XIDOID, -1, 0);
|
|
||||||
|
|
||||||
return BlessTupleDesc(tupdesc);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Convert one entry from the old snapshot time mapping to a HeapTuple.
|
* Convert one entry from the old snapshot time mapping to a HeapTuple.
|
||||||
*/
|
*/
|
||||||
|
@ -291,10 +291,8 @@ pg_visibility_map_summary(PG_FUNCTION_ARGS)
|
|||||||
ReleaseBuffer(vmbuffer);
|
ReleaseBuffer(vmbuffer);
|
||||||
relation_close(rel, AccessShareLock);
|
relation_close(rel, AccessShareLock);
|
||||||
|
|
||||||
tupdesc = CreateTemplateTupleDesc(2);
|
if (get_call_result_type(fcinfo, NULL, &tupdesc) != TYPEFUNC_COMPOSITE)
|
||||||
TupleDescInitEntry(tupdesc, (AttrNumber) 1, "all_visible", INT8OID, -1, 0);
|
elog(ERROR, "return type must be a row type");
|
||||||
TupleDescInitEntry(tupdesc, (AttrNumber) 2, "all_frozen", INT8OID, -1, 0);
|
|
||||||
tupdesc = BlessTupleDesc(tupdesc);
|
|
||||||
|
|
||||||
values[0] = Int64GetDatum(all_visible);
|
values[0] = Int64GetDatum(all_visible);
|
||||||
values[1] = Int64GetDatum(all_frozen);
|
values[1] = Int64GetDatum(all_frozen);
|
||||||
|
@ -422,18 +422,8 @@ pg_last_committed_xact(PG_FUNCTION_ARGS)
|
|||||||
/* and construct a tuple with our data */
|
/* and construct a tuple with our data */
|
||||||
xid = GetLatestCommitTsData(&ts, &nodeid);
|
xid = GetLatestCommitTsData(&ts, &nodeid);
|
||||||
|
|
||||||
/*
|
if (get_call_result_type(fcinfo, NULL, &tupdesc) != TYPEFUNC_COMPOSITE)
|
||||||
* Construct a tuple descriptor for the result row. This must match this
|
elog(ERROR, "return type must be a row type");
|
||||||
* function's pg_proc entry!
|
|
||||||
*/
|
|
||||||
tupdesc = CreateTemplateTupleDesc(3);
|
|
||||||
TupleDescInitEntry(tupdesc, (AttrNumber) 1, "xid",
|
|
||||||
XIDOID, -1, 0);
|
|
||||||
TupleDescInitEntry(tupdesc, (AttrNumber) 2, "timestamp",
|
|
||||||
TIMESTAMPTZOID, -1, 0);
|
|
||||||
TupleDescInitEntry(tupdesc, (AttrNumber) 3, "roident",
|
|
||||||
OIDOID, -1, 0);
|
|
||||||
tupdesc = BlessTupleDesc(tupdesc);
|
|
||||||
|
|
||||||
if (!TransactionIdIsNormal(xid))
|
if (!TransactionIdIsNormal(xid))
|
||||||
{
|
{
|
||||||
@ -476,16 +466,8 @@ pg_xact_commit_timestamp_origin(PG_FUNCTION_ARGS)
|
|||||||
|
|
||||||
found = TransactionIdGetCommitTsData(xid, &ts, &nodeid);
|
found = TransactionIdGetCommitTsData(xid, &ts, &nodeid);
|
||||||
|
|
||||||
/*
|
if (get_call_result_type(fcinfo, NULL, &tupdesc) != TYPEFUNC_COMPOSITE)
|
||||||
* Construct a tuple descriptor for the result row. This must match this
|
elog(ERROR, "return type must be a row type");
|
||||||
* function's pg_proc entry!
|
|
||||||
*/
|
|
||||||
tupdesc = CreateTemplateTupleDesc(2);
|
|
||||||
TupleDescInitEntry(tupdesc, (AttrNumber) 1, "timestamp",
|
|
||||||
TIMESTAMPTZOID, -1, 0);
|
|
||||||
TupleDescInitEntry(tupdesc, (AttrNumber) 2, "roident",
|
|
||||||
OIDOID, -1, 0);
|
|
||||||
tupdesc = BlessTupleDesc(tupdesc);
|
|
||||||
|
|
||||||
if (!found)
|
if (!found)
|
||||||
{
|
{
|
||||||
|
@ -3373,12 +3373,9 @@ pg_get_multixact_members(PG_FUNCTION_ARGS)
|
|||||||
false);
|
false);
|
||||||
multi->iter = 0;
|
multi->iter = 0;
|
||||||
|
|
||||||
tupdesc = CreateTemplateTupleDesc(2);
|
if (get_call_result_type(fcinfo, NULL, &tupdesc) != TYPEFUNC_COMPOSITE)
|
||||||
TupleDescInitEntry(tupdesc, (AttrNumber) 1, "xid",
|
elog(ERROR, "return type must be a row type");
|
||||||
XIDOID, -1, 0);
|
funccxt->tuple_desc = tupdesc;
|
||||||
TupleDescInitEntry(tupdesc, (AttrNumber) 2, "mode",
|
|
||||||
TEXTOID, -1, 0);
|
|
||||||
|
|
||||||
funccxt->attinmeta = TupleDescGetAttInMetadata(tupdesc);
|
funccxt->attinmeta = TupleDescGetAttInMetadata(tupdesc);
|
||||||
funccxt->user_fctx = multi;
|
funccxt->user_fctx = multi;
|
||||||
|
|
||||||
|
@ -2397,14 +2397,8 @@ pg_get_object_address(PG_FUNCTION_ARGS)
|
|||||||
if (relation)
|
if (relation)
|
||||||
relation_close(relation, AccessShareLock);
|
relation_close(relation, AccessShareLock);
|
||||||
|
|
||||||
tupdesc = CreateTemplateTupleDesc(3);
|
if (get_call_result_type(fcinfo, NULL, &tupdesc) != TYPEFUNC_COMPOSITE)
|
||||||
TupleDescInitEntry(tupdesc, (AttrNumber) 1, "classid",
|
elog(ERROR, "return type must be a row type");
|
||||||
OIDOID, -1, 0);
|
|
||||||
TupleDescInitEntry(tupdesc, (AttrNumber) 2, "objid",
|
|
||||||
OIDOID, -1, 0);
|
|
||||||
TupleDescInitEntry(tupdesc, (AttrNumber) 3, "objsubid",
|
|
||||||
INT4OID, -1, 0);
|
|
||||||
tupdesc = BlessTupleDesc(tupdesc);
|
|
||||||
|
|
||||||
values[0] = ObjectIdGetDatum(addr.classId);
|
values[0] = ObjectIdGetDatum(addr.classId);
|
||||||
values[1] = ObjectIdGetDatum(addr.objectId);
|
values[1] = ObjectIdGetDatum(addr.objectId);
|
||||||
@ -4244,21 +4238,8 @@ pg_identify_object(PG_FUNCTION_ARGS)
|
|||||||
address.objectId = objid;
|
address.objectId = objid;
|
||||||
address.objectSubId = objsubid;
|
address.objectSubId = objsubid;
|
||||||
|
|
||||||
/*
|
if (get_call_result_type(fcinfo, NULL, &tupdesc) != TYPEFUNC_COMPOSITE)
|
||||||
* Construct a tuple descriptor for the result row. This must match this
|
elog(ERROR, "return type must be a row type");
|
||||||
* function's pg_proc entry!
|
|
||||||
*/
|
|
||||||
tupdesc = CreateTemplateTupleDesc(4);
|
|
||||||
TupleDescInitEntry(tupdesc, (AttrNumber) 1, "type",
|
|
||||||
TEXTOID, -1, 0);
|
|
||||||
TupleDescInitEntry(tupdesc, (AttrNumber) 2, "schema",
|
|
||||||
TEXTOID, -1, 0);
|
|
||||||
TupleDescInitEntry(tupdesc, (AttrNumber) 3, "name",
|
|
||||||
TEXTOID, -1, 0);
|
|
||||||
TupleDescInitEntry(tupdesc, (AttrNumber) 4, "identity",
|
|
||||||
TEXTOID, -1, 0);
|
|
||||||
|
|
||||||
tupdesc = BlessTupleDesc(tupdesc);
|
|
||||||
|
|
||||||
if (is_objectclass_supported(address.classId))
|
if (is_objectclass_supported(address.classId))
|
||||||
{
|
{
|
||||||
@ -4374,19 +4355,8 @@ pg_identify_object_as_address(PG_FUNCTION_ARGS)
|
|||||||
address.objectId = objid;
|
address.objectId = objid;
|
||||||
address.objectSubId = objsubid;
|
address.objectSubId = objsubid;
|
||||||
|
|
||||||
/*
|
if (get_call_result_type(fcinfo, NULL, &tupdesc) != TYPEFUNC_COMPOSITE)
|
||||||
* Construct a tuple descriptor for the result row. This must match this
|
elog(ERROR, "return type must be a row type");
|
||||||
* function's pg_proc entry!
|
|
||||||
*/
|
|
||||||
tupdesc = CreateTemplateTupleDesc(3);
|
|
||||||
TupleDescInitEntry(tupdesc, (AttrNumber) 1, "type",
|
|
||||||
TEXTOID, -1, 0);
|
|
||||||
TupleDescInitEntry(tupdesc, (AttrNumber) 2, "object_names",
|
|
||||||
TEXTARRAYOID, -1, 0);
|
|
||||||
TupleDescInitEntry(tupdesc, (AttrNumber) 3, "object_args",
|
|
||||||
TEXTARRAYOID, -1, 0);
|
|
||||||
|
|
||||||
tupdesc = BlessTupleDesc(tupdesc);
|
|
||||||
|
|
||||||
/* object type, which can never be NULL */
|
/* object type, which can never be NULL */
|
||||||
values[0] = CStringGetTextDatum(getObjectTypeDescription(&address, true));
|
values[0] = CStringGetTextDatum(getObjectTypeDescription(&address, true));
|
||||||
|
@ -1762,23 +1762,8 @@ pg_sequence_parameters(PG_FUNCTION_ARGS)
|
|||||||
errmsg("permission denied for sequence %s",
|
errmsg("permission denied for sequence %s",
|
||||||
get_rel_name(relid))));
|
get_rel_name(relid))));
|
||||||
|
|
||||||
tupdesc = CreateTemplateTupleDesc(7);
|
if (get_call_result_type(fcinfo, NULL, &tupdesc) != TYPEFUNC_COMPOSITE)
|
||||||
TupleDescInitEntry(tupdesc, (AttrNumber) 1, "start_value",
|
elog(ERROR, "return type must be a row type");
|
||||||
INT8OID, -1, 0);
|
|
||||||
TupleDescInitEntry(tupdesc, (AttrNumber) 2, "minimum_value",
|
|
||||||
INT8OID, -1, 0);
|
|
||||||
TupleDescInitEntry(tupdesc, (AttrNumber) 3, "maximum_value",
|
|
||||||
INT8OID, -1, 0);
|
|
||||||
TupleDescInitEntry(tupdesc, (AttrNumber) 4, "increment",
|
|
||||||
INT8OID, -1, 0);
|
|
||||||
TupleDescInitEntry(tupdesc, (AttrNumber) 5, "cycle_option",
|
|
||||||
BOOLOID, -1, 0);
|
|
||||||
TupleDescInitEntry(tupdesc, (AttrNumber) 6, "cache_size",
|
|
||||||
INT8OID, -1, 0);
|
|
||||||
TupleDescInitEntry(tupdesc, (AttrNumber) 7, "data_type",
|
|
||||||
OIDOID, -1, 0);
|
|
||||||
|
|
||||||
BlessTupleDesc(tupdesc);
|
|
||||||
|
|
||||||
memset(isnull, 0, sizeof(isnull));
|
memset(isnull, 0, sizeof(isnull));
|
||||||
|
|
||||||
|
@ -46,7 +46,8 @@ typedef struct HeadlineJsonState
|
|||||||
static text *headline_json_value(void *_state, char *elem_value, int elem_len);
|
static text *headline_json_value(void *_state, char *elem_value, int elem_len);
|
||||||
|
|
||||||
static void
|
static void
|
||||||
tt_setup_firstcall(FuncCallContext *funcctx, Oid prsid)
|
tt_setup_firstcall(FuncCallContext *funcctx, FunctionCallInfo fcinfo,
|
||||||
|
Oid prsid)
|
||||||
{
|
{
|
||||||
TupleDesc tupdesc;
|
TupleDesc tupdesc;
|
||||||
MemoryContext oldcontext;
|
MemoryContext oldcontext;
|
||||||
@ -66,15 +67,11 @@ tt_setup_firstcall(FuncCallContext *funcctx, Oid prsid)
|
|||||||
(Datum) 0));
|
(Datum) 0));
|
||||||
funcctx->user_fctx = (void *) st;
|
funcctx->user_fctx = (void *) st;
|
||||||
|
|
||||||
tupdesc = CreateTemplateTupleDesc(3);
|
if (get_call_result_type(fcinfo, NULL, &tupdesc) != TYPEFUNC_COMPOSITE)
|
||||||
TupleDescInitEntry(tupdesc, (AttrNumber) 1, "tokid",
|
elog(ERROR, "return type must be a row type");
|
||||||
INT4OID, -1, 0);
|
funcctx->tuple_desc = tupdesc;
|
||||||
TupleDescInitEntry(tupdesc, (AttrNumber) 2, "alias",
|
|
||||||
TEXTOID, -1, 0);
|
|
||||||
TupleDescInitEntry(tupdesc, (AttrNumber) 3, "description",
|
|
||||||
TEXTOID, -1, 0);
|
|
||||||
|
|
||||||
funcctx->attinmeta = TupleDescGetAttInMetadata(tupdesc);
|
funcctx->attinmeta = TupleDescGetAttInMetadata(tupdesc);
|
||||||
|
|
||||||
MemoryContextSwitchTo(oldcontext);
|
MemoryContextSwitchTo(oldcontext);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -116,7 +113,7 @@ ts_token_type_byid(PG_FUNCTION_ARGS)
|
|||||||
if (SRF_IS_FIRSTCALL())
|
if (SRF_IS_FIRSTCALL())
|
||||||
{
|
{
|
||||||
funcctx = SRF_FIRSTCALL_INIT();
|
funcctx = SRF_FIRSTCALL_INIT();
|
||||||
tt_setup_firstcall(funcctx, PG_GETARG_OID(0));
|
tt_setup_firstcall(funcctx, fcinfo, PG_GETARG_OID(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
funcctx = SRF_PERCALL_SETUP();
|
funcctx = SRF_PERCALL_SETUP();
|
||||||
@ -139,7 +136,7 @@ ts_token_type_byname(PG_FUNCTION_ARGS)
|
|||||||
|
|
||||||
funcctx = SRF_FIRSTCALL_INIT();
|
funcctx = SRF_FIRSTCALL_INIT();
|
||||||
prsId = get_ts_parser_oid(textToQualifiedNameList(prsname), false);
|
prsId = get_ts_parser_oid(textToQualifiedNameList(prsname), false);
|
||||||
tt_setup_firstcall(funcctx, prsId);
|
tt_setup_firstcall(funcctx, fcinfo, prsId);
|
||||||
}
|
}
|
||||||
|
|
||||||
funcctx = SRF_PERCALL_SETUP();
|
funcctx = SRF_PERCALL_SETUP();
|
||||||
@ -164,7 +161,8 @@ typedef struct
|
|||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
prs_setup_firstcall(FuncCallContext *funcctx, Oid prsid, text *txt)
|
prs_setup_firstcall(FuncCallContext *funcctx, FunctionCallInfo fcinfo,
|
||||||
|
Oid prsid, text *txt)
|
||||||
{
|
{
|
||||||
TupleDesc tupdesc;
|
TupleDesc tupdesc;
|
||||||
MemoryContext oldcontext;
|
MemoryContext oldcontext;
|
||||||
@ -209,12 +207,9 @@ prs_setup_firstcall(FuncCallContext *funcctx, Oid prsid, text *txt)
|
|||||||
st->cur = 0;
|
st->cur = 0;
|
||||||
|
|
||||||
funcctx->user_fctx = (void *) st;
|
funcctx->user_fctx = (void *) st;
|
||||||
tupdesc = CreateTemplateTupleDesc(2);
|
if (get_call_result_type(fcinfo, NULL, &tupdesc) != TYPEFUNC_COMPOSITE)
|
||||||
TupleDescInitEntry(tupdesc, (AttrNumber) 1, "tokid",
|
elog(ERROR, "return type must be a row type");
|
||||||
INT4OID, -1, 0);
|
funcctx->tuple_desc = tupdesc;
|
||||||
TupleDescInitEntry(tupdesc, (AttrNumber) 2, "token",
|
|
||||||
TEXTOID, -1, 0);
|
|
||||||
|
|
||||||
funcctx->attinmeta = TupleDescGetAttInMetadata(tupdesc);
|
funcctx->attinmeta = TupleDescGetAttInMetadata(tupdesc);
|
||||||
MemoryContextSwitchTo(oldcontext);
|
MemoryContextSwitchTo(oldcontext);
|
||||||
}
|
}
|
||||||
@ -256,7 +251,7 @@ ts_parse_byid(PG_FUNCTION_ARGS)
|
|||||||
text *txt = PG_GETARG_TEXT_PP(1);
|
text *txt = PG_GETARG_TEXT_PP(1);
|
||||||
|
|
||||||
funcctx = SRF_FIRSTCALL_INIT();
|
funcctx = SRF_FIRSTCALL_INIT();
|
||||||
prs_setup_firstcall(funcctx, PG_GETARG_OID(0), txt);
|
prs_setup_firstcall(funcctx, fcinfo, PG_GETARG_OID(0), txt);
|
||||||
PG_FREE_IF_COPY(txt, 1);
|
PG_FREE_IF_COPY(txt, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -281,7 +276,7 @@ ts_parse_byname(PG_FUNCTION_ARGS)
|
|||||||
|
|
||||||
funcctx = SRF_FIRSTCALL_INIT();
|
funcctx = SRF_FIRSTCALL_INIT();
|
||||||
prsId = get_ts_parser_oid(textToQualifiedNameList(prsname), false);
|
prsId = get_ts_parser_oid(textToQualifiedNameList(prsname), false);
|
||||||
prs_setup_firstcall(funcctx, prsId, txt);
|
prs_setup_firstcall(funcctx, fcinfo, prsId, txt);
|
||||||
}
|
}
|
||||||
|
|
||||||
funcctx = SRF_PERCALL_SETUP();
|
funcctx = SRF_PERCALL_SETUP();
|
||||||
|
@ -4983,19 +4983,10 @@ pg_timezone_abbrevs(PG_FUNCTION_ARGS)
|
|||||||
*pindex = 0;
|
*pindex = 0;
|
||||||
funcctx->user_fctx = (void *) pindex;
|
funcctx->user_fctx = (void *) pindex;
|
||||||
|
|
||||||
/*
|
if (get_call_result_type(fcinfo, NULL, &tupdesc) != TYPEFUNC_COMPOSITE)
|
||||||
* build tupdesc for result tuples. This must match this function's
|
elog(ERROR, "return type must be a row type");
|
||||||
* pg_proc entry!
|
funcctx->tuple_desc = tupdesc;
|
||||||
*/
|
|
||||||
tupdesc = CreateTemplateTupleDesc(3);
|
|
||||||
TupleDescInitEntry(tupdesc, (AttrNumber) 1, "abbrev",
|
|
||||||
TEXTOID, -1, 0);
|
|
||||||
TupleDescInitEntry(tupdesc, (AttrNumber) 2, "utc_offset",
|
|
||||||
INTERVALOID, -1, 0);
|
|
||||||
TupleDescInitEntry(tupdesc, (AttrNumber) 3, "is_dst",
|
|
||||||
BOOLOID, -1, 0);
|
|
||||||
|
|
||||||
funcctx->tuple_desc = BlessTupleDesc(tupdesc);
|
|
||||||
MemoryContextSwitchTo(oldcontext);
|
MemoryContextSwitchTo(oldcontext);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -427,18 +427,9 @@ pg_get_keywords(PG_FUNCTION_ARGS)
|
|||||||
funcctx = SRF_FIRSTCALL_INIT();
|
funcctx = SRF_FIRSTCALL_INIT();
|
||||||
oldcontext = MemoryContextSwitchTo(funcctx->multi_call_memory_ctx);
|
oldcontext = MemoryContextSwitchTo(funcctx->multi_call_memory_ctx);
|
||||||
|
|
||||||
tupdesc = CreateTemplateTupleDesc(5);
|
if (get_call_result_type(fcinfo, NULL, &tupdesc) != TYPEFUNC_COMPOSITE)
|
||||||
TupleDescInitEntry(tupdesc, (AttrNumber) 1, "word",
|
elog(ERROR, "return type must be a row type");
|
||||||
TEXTOID, -1, 0);
|
funcctx->tuple_desc = tupdesc;
|
||||||
TupleDescInitEntry(tupdesc, (AttrNumber) 2, "catcode",
|
|
||||||
CHAROID, -1, 0);
|
|
||||||
TupleDescInitEntry(tupdesc, (AttrNumber) 3, "barelabel",
|
|
||||||
BOOLOID, -1, 0);
|
|
||||||
TupleDescInitEntry(tupdesc, (AttrNumber) 4, "catdesc",
|
|
||||||
TEXTOID, -1, 0);
|
|
||||||
TupleDescInitEntry(tupdesc, (AttrNumber) 5, "baredesc",
|
|
||||||
TEXTOID, -1, 0);
|
|
||||||
|
|
||||||
funcctx->attinmeta = TupleDescGetAttInMetadata(tupdesc);
|
funcctx->attinmeta = TupleDescGetAttInMetadata(tupdesc);
|
||||||
|
|
||||||
MemoryContextSwitchTo(oldcontext);
|
MemoryContextSwitchTo(oldcontext);
|
||||||
@ -515,20 +506,8 @@ pg_get_catalog_foreign_keys(PG_FUNCTION_ARGS)
|
|||||||
funcctx = SRF_FIRSTCALL_INIT();
|
funcctx = SRF_FIRSTCALL_INIT();
|
||||||
oldcontext = MemoryContextSwitchTo(funcctx->multi_call_memory_ctx);
|
oldcontext = MemoryContextSwitchTo(funcctx->multi_call_memory_ctx);
|
||||||
|
|
||||||
tupdesc = CreateTemplateTupleDesc(6);
|
if (get_call_result_type(fcinfo, NULL, &tupdesc) != TYPEFUNC_COMPOSITE)
|
||||||
TupleDescInitEntry(tupdesc, (AttrNumber) 1, "fktable",
|
elog(ERROR, "return type must be a row type");
|
||||||
REGCLASSOID, -1, 0);
|
|
||||||
TupleDescInitEntry(tupdesc, (AttrNumber) 2, "fkcols",
|
|
||||||
TEXTARRAYOID, -1, 0);
|
|
||||||
TupleDescInitEntry(tupdesc, (AttrNumber) 3, "pktable",
|
|
||||||
REGCLASSOID, -1, 0);
|
|
||||||
TupleDescInitEntry(tupdesc, (AttrNumber) 4, "pkcols",
|
|
||||||
TEXTARRAYOID, -1, 0);
|
|
||||||
TupleDescInitEntry(tupdesc, (AttrNumber) 5, "is_array",
|
|
||||||
BOOLOID, -1, 0);
|
|
||||||
TupleDescInitEntry(tupdesc, (AttrNumber) 6, "is_opt",
|
|
||||||
BOOLOID, -1, 0);
|
|
||||||
|
|
||||||
funcctx->tuple_desc = BlessTupleDesc(tupdesc);
|
funcctx->tuple_desc = BlessTupleDesc(tupdesc);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -88,17 +88,9 @@ pg_partition_tree(PG_FUNCTION_ARGS)
|
|||||||
*/
|
*/
|
||||||
partitions = find_all_inheritors(rootrelid, AccessShareLock, NULL);
|
partitions = find_all_inheritors(rootrelid, AccessShareLock, NULL);
|
||||||
|
|
||||||
tupdesc = CreateTemplateTupleDesc(PG_PARTITION_TREE_COLS);
|
if (get_call_result_type(fcinfo, NULL, &tupdesc) != TYPEFUNC_COMPOSITE)
|
||||||
TupleDescInitEntry(tupdesc, (AttrNumber) 1, "relid",
|
elog(ERROR, "return type must be a row type");
|
||||||
REGCLASSOID, -1, 0);
|
funcctx->tuple_desc = tupdesc;
|
||||||
TupleDescInitEntry(tupdesc, (AttrNumber) 2, "parentid",
|
|
||||||
REGCLASSOID, -1, 0);
|
|
||||||
TupleDescInitEntry(tupdesc, (AttrNumber) 3, "isleaf",
|
|
||||||
BOOLOID, -1, 0);
|
|
||||||
TupleDescInitEntry(tupdesc, (AttrNumber) 4, "level",
|
|
||||||
INT4OID, -1, 0);
|
|
||||||
|
|
||||||
funcctx->tuple_desc = BlessTupleDesc(tupdesc);
|
|
||||||
|
|
||||||
/* The only state we need is the partition list */
|
/* The only state we need is the partition list */
|
||||||
funcctx->user_fctx = (void *) partitions;
|
funcctx->user_fctx = (void *) partitions;
|
||||||
|
@ -647,7 +647,9 @@ tsvector_unnest(PG_FUNCTION_ARGS)
|
|||||||
INT2ARRAYOID, -1, 0);
|
INT2ARRAYOID, -1, 0);
|
||||||
TupleDescInitEntry(tupdesc, (AttrNumber) 3, "weights",
|
TupleDescInitEntry(tupdesc, (AttrNumber) 3, "weights",
|
||||||
TEXTARRAYOID, -1, 0);
|
TEXTARRAYOID, -1, 0);
|
||||||
funcctx->tuple_desc = BlessTupleDesc(tupdesc);
|
if (get_call_result_type(fcinfo, NULL, &tupdesc) != TYPEFUNC_COMPOSITE)
|
||||||
|
elog(ERROR, "return type must be a row type");
|
||||||
|
funcctx->tuple_desc = tupdesc;
|
||||||
|
|
||||||
funcctx->user_fctx = PG_GETARG_TSVECTOR_COPY(0);
|
funcctx->user_fctx = PG_GETARG_TSVECTOR_COPY(0);
|
||||||
|
|
||||||
@ -2302,14 +2304,9 @@ ts_setup_firstcall(FunctionCallInfo fcinfo, FuncCallContext *funcctx,
|
|||||||
}
|
}
|
||||||
Assert(stat->stackpos <= stat->maxdepth);
|
Assert(stat->stackpos <= stat->maxdepth);
|
||||||
|
|
||||||
tupdesc = CreateTemplateTupleDesc(3);
|
if (get_call_result_type(fcinfo, NULL, &tupdesc) != TYPEFUNC_COMPOSITE)
|
||||||
TupleDescInitEntry(tupdesc, (AttrNumber) 1, "word",
|
elog(ERROR, "return type must be a row type");
|
||||||
TEXTOID, -1, 0);
|
funcctx->tuple_desc = tupdesc;
|
||||||
TupleDescInitEntry(tupdesc, (AttrNumber) 2, "ndoc",
|
|
||||||
INT4OID, -1, 0);
|
|
||||||
TupleDescInitEntry(tupdesc, (AttrNumber) 3, "nentry",
|
|
||||||
INT4OID, -1, 0);
|
|
||||||
funcctx->tuple_desc = BlessTupleDesc(tupdesc);
|
|
||||||
funcctx->attinmeta = TupleDescGetAttInMetadata(tupdesc);
|
funcctx->attinmeta = TupleDescGetAttInMetadata(tupdesc);
|
||||||
|
|
||||||
MemoryContextSwitchTo(oldcontext);
|
MemoryContextSwitchTo(oldcontext);
|
||||||
|
@ -38,20 +38,8 @@ pg_control_system(PG_FUNCTION_ARGS)
|
|||||||
ControlFileData *ControlFile;
|
ControlFileData *ControlFile;
|
||||||
bool crc_ok;
|
bool crc_ok;
|
||||||
|
|
||||||
/*
|
if (get_call_result_type(fcinfo, NULL, &tupdesc) != TYPEFUNC_COMPOSITE)
|
||||||
* Construct a tuple descriptor for the result row. This must match this
|
elog(ERROR, "return type must be a row type");
|
||||||
* function's pg_proc entry!
|
|
||||||
*/
|
|
||||||
tupdesc = CreateTemplateTupleDesc(4);
|
|
||||||
TupleDescInitEntry(tupdesc, (AttrNumber) 1, "pg_control_version",
|
|
||||||
INT4OID, -1, 0);
|
|
||||||
TupleDescInitEntry(tupdesc, (AttrNumber) 2, "catalog_version_no",
|
|
||||||
INT4OID, -1, 0);
|
|
||||||
TupleDescInitEntry(tupdesc, (AttrNumber) 3, "system_identifier",
|
|
||||||
INT8OID, -1, 0);
|
|
||||||
TupleDescInitEntry(tupdesc, (AttrNumber) 4, "pg_control_last_modified",
|
|
||||||
TIMESTAMPTZOID, -1, 0);
|
|
||||||
tupdesc = BlessTupleDesc(tupdesc);
|
|
||||||
|
|
||||||
/* read the control file */
|
/* read the control file */
|
||||||
ControlFile = get_controlfile(DataDir, &crc_ok);
|
ControlFile = get_controlfile(DataDir, &crc_ok);
|
||||||
@ -88,48 +76,8 @@ pg_control_checkpoint(PG_FUNCTION_ARGS)
|
|||||||
char xlogfilename[MAXFNAMELEN];
|
char xlogfilename[MAXFNAMELEN];
|
||||||
bool crc_ok;
|
bool crc_ok;
|
||||||
|
|
||||||
/*
|
if (get_call_result_type(fcinfo, NULL, &tupdesc) != TYPEFUNC_COMPOSITE)
|
||||||
* Construct a tuple descriptor for the result row. This must match this
|
elog(ERROR, "return type must be a row type");
|
||||||
* function's pg_proc entry!
|
|
||||||
*/
|
|
||||||
tupdesc = CreateTemplateTupleDesc(18);
|
|
||||||
TupleDescInitEntry(tupdesc, (AttrNumber) 1, "checkpoint_lsn",
|
|
||||||
PG_LSNOID, -1, 0);
|
|
||||||
TupleDescInitEntry(tupdesc, (AttrNumber) 2, "redo_lsn",
|
|
||||||
PG_LSNOID, -1, 0);
|
|
||||||
TupleDescInitEntry(tupdesc, (AttrNumber) 3, "redo_wal_file",
|
|
||||||
TEXTOID, -1, 0);
|
|
||||||
TupleDescInitEntry(tupdesc, (AttrNumber) 4, "timeline_id",
|
|
||||||
INT4OID, -1, 0);
|
|
||||||
TupleDescInitEntry(tupdesc, (AttrNumber) 5, "prev_timeline_id",
|
|
||||||
INT4OID, -1, 0);
|
|
||||||
TupleDescInitEntry(tupdesc, (AttrNumber) 6, "full_page_writes",
|
|
||||||
BOOLOID, -1, 0);
|
|
||||||
TupleDescInitEntry(tupdesc, (AttrNumber) 7, "next_xid",
|
|
||||||
TEXTOID, -1, 0);
|
|
||||||
TupleDescInitEntry(tupdesc, (AttrNumber) 8, "next_oid",
|
|
||||||
OIDOID, -1, 0);
|
|
||||||
TupleDescInitEntry(tupdesc, (AttrNumber) 9, "next_multixact_id",
|
|
||||||
XIDOID, -1, 0);
|
|
||||||
TupleDescInitEntry(tupdesc, (AttrNumber) 10, "next_multi_offset",
|
|
||||||
XIDOID, -1, 0);
|
|
||||||
TupleDescInitEntry(tupdesc, (AttrNumber) 11, "oldest_xid",
|
|
||||||
XIDOID, -1, 0);
|
|
||||||
TupleDescInitEntry(tupdesc, (AttrNumber) 12, "oldest_xid_dbid",
|
|
||||||
OIDOID, -1, 0);
|
|
||||||
TupleDescInitEntry(tupdesc, (AttrNumber) 13, "oldest_active_xid",
|
|
||||||
XIDOID, -1, 0);
|
|
||||||
TupleDescInitEntry(tupdesc, (AttrNumber) 14, "oldest_multi_xid",
|
|
||||||
XIDOID, -1, 0);
|
|
||||||
TupleDescInitEntry(tupdesc, (AttrNumber) 15, "oldest_multi_dbid",
|
|
||||||
OIDOID, -1, 0);
|
|
||||||
TupleDescInitEntry(tupdesc, (AttrNumber) 16, "oldest_commit_ts_xid",
|
|
||||||
XIDOID, -1, 0);
|
|
||||||
TupleDescInitEntry(tupdesc, (AttrNumber) 17, "newest_commit_ts_xid",
|
|
||||||
XIDOID, -1, 0);
|
|
||||||
TupleDescInitEntry(tupdesc, (AttrNumber) 18, "checkpoint_time",
|
|
||||||
TIMESTAMPTZOID, -1, 0);
|
|
||||||
tupdesc = BlessTupleDesc(tupdesc);
|
|
||||||
|
|
||||||
/* Read the control file. */
|
/* Read the control file. */
|
||||||
ControlFile = get_controlfile(DataDir, &crc_ok);
|
ControlFile = get_controlfile(DataDir, &crc_ok);
|
||||||
@ -217,22 +165,8 @@ pg_control_recovery(PG_FUNCTION_ARGS)
|
|||||||
ControlFileData *ControlFile;
|
ControlFileData *ControlFile;
|
||||||
bool crc_ok;
|
bool crc_ok;
|
||||||
|
|
||||||
/*
|
if (get_call_result_type(fcinfo, NULL, &tupdesc) != TYPEFUNC_COMPOSITE)
|
||||||
* Construct a tuple descriptor for the result row. This must match this
|
elog(ERROR, "return type must be a row type");
|
||||||
* function's pg_proc entry!
|
|
||||||
*/
|
|
||||||
tupdesc = CreateTemplateTupleDesc(5);
|
|
||||||
TupleDescInitEntry(tupdesc, (AttrNumber) 1, "min_recovery_end_lsn",
|
|
||||||
PG_LSNOID, -1, 0);
|
|
||||||
TupleDescInitEntry(tupdesc, (AttrNumber) 2, "min_recovery_end_timeline",
|
|
||||||
INT4OID, -1, 0);
|
|
||||||
TupleDescInitEntry(tupdesc, (AttrNumber) 3, "backup_start_lsn",
|
|
||||||
PG_LSNOID, -1, 0);
|
|
||||||
TupleDescInitEntry(tupdesc, (AttrNumber) 4, "backup_end_lsn",
|
|
||||||
PG_LSNOID, -1, 0);
|
|
||||||
TupleDescInitEntry(tupdesc, (AttrNumber) 5, "end_of_backup_record_required",
|
|
||||||
BOOLOID, -1, 0);
|
|
||||||
tupdesc = BlessTupleDesc(tupdesc);
|
|
||||||
|
|
||||||
/* read the control file */
|
/* read the control file */
|
||||||
ControlFile = get_controlfile(DataDir, &crc_ok);
|
ControlFile = get_controlfile(DataDir, &crc_ok);
|
||||||
@ -270,34 +204,8 @@ pg_control_init(PG_FUNCTION_ARGS)
|
|||||||
ControlFileData *ControlFile;
|
ControlFileData *ControlFile;
|
||||||
bool crc_ok;
|
bool crc_ok;
|
||||||
|
|
||||||
/*
|
if (get_call_result_type(fcinfo, NULL, &tupdesc) != TYPEFUNC_COMPOSITE)
|
||||||
* Construct a tuple descriptor for the result row. This must match this
|
elog(ERROR, "return type must be a row type");
|
||||||
* function's pg_proc entry!
|
|
||||||
*/
|
|
||||||
tupdesc = CreateTemplateTupleDesc(11);
|
|
||||||
TupleDescInitEntry(tupdesc, (AttrNumber) 1, "max_data_alignment",
|
|
||||||
INT4OID, -1, 0);
|
|
||||||
TupleDescInitEntry(tupdesc, (AttrNumber) 2, "database_block_size",
|
|
||||||
INT4OID, -1, 0);
|
|
||||||
TupleDescInitEntry(tupdesc, (AttrNumber) 3, "blocks_per_segment",
|
|
||||||
INT4OID, -1, 0);
|
|
||||||
TupleDescInitEntry(tupdesc, (AttrNumber) 4, "wal_block_size",
|
|
||||||
INT4OID, -1, 0);
|
|
||||||
TupleDescInitEntry(tupdesc, (AttrNumber) 5, "bytes_per_wal_segment",
|
|
||||||
INT4OID, -1, 0);
|
|
||||||
TupleDescInitEntry(tupdesc, (AttrNumber) 6, "max_identifier_length",
|
|
||||||
INT4OID, -1, 0);
|
|
||||||
TupleDescInitEntry(tupdesc, (AttrNumber) 7, "max_index_columns",
|
|
||||||
INT4OID, -1, 0);
|
|
||||||
TupleDescInitEntry(tupdesc, (AttrNumber) 8, "max_toast_chunk_size",
|
|
||||||
INT4OID, -1, 0);
|
|
||||||
TupleDescInitEntry(tupdesc, (AttrNumber) 9, "large_object_chunk_size",
|
|
||||||
INT4OID, -1, 0);
|
|
||||||
TupleDescInitEntry(tupdesc, (AttrNumber) 10, "float8_pass_by_value",
|
|
||||||
BOOLOID, -1, 0);
|
|
||||||
TupleDescInitEntry(tupdesc, (AttrNumber) 11, "data_page_checksum_version",
|
|
||||||
INT4OID, -1, 0);
|
|
||||||
tupdesc = BlessTupleDesc(tupdesc);
|
|
||||||
|
|
||||||
/* read the control file */
|
/* read the control file */
|
||||||
ControlFile = get_controlfile(DataDir, &crc_ok);
|
ControlFile = get_controlfile(DataDir, &crc_ok);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user