Remove 'msg' parameter from convert_tuples_by_name

The message was included as a parameter when this function was added in
dcb2bda9b7, but I don't think it has ever served any useful purpose.
Let's stop spreading it pointlessly.

Reviewed by Amit Langote and Peter Eisentraut.

Discussion: https://postgr.es/m/20190806224728.GA17233@alvherre.pgsql
This commit is contained in:
Alvaro Herrera 2019-09-03 14:47:29 -04:00
parent 10f5544896
commit fe66125974
10 changed files with 33 additions and 63 deletions

View File

@ -203,15 +203,14 @@ convert_tuples_by_position(TupleDesc indesc,
*/
TupleConversionMap *
convert_tuples_by_name(TupleDesc indesc,
TupleDesc outdesc,
const char *msg)
TupleDesc outdesc)
{
TupleConversionMap *map;
AttrNumber *attrMap;
int n = outdesc->natts;
/* Verify compatibility and prepare attribute-number map */
attrMap = convert_tuples_by_name_map_if_req(indesc, outdesc, msg);
attrMap = convert_tuples_by_name_map_if_req(indesc, outdesc);
if (attrMap == NULL)
{
@ -244,8 +243,7 @@ convert_tuples_by_name(TupleDesc indesc,
*/
AttrNumber *
convert_tuples_by_name_map(TupleDesc indesc,
TupleDesc outdesc,
const char *msg)
TupleDesc outdesc)
{
AttrNumber *attrMap;
int outnatts;
@ -299,7 +297,7 @@ convert_tuples_by_name_map(TupleDesc indesc,
if (atttypid != inatt->atttypid || atttypmod != inatt->atttypmod)
ereport(ERROR,
(errcode(ERRCODE_DATATYPE_MISMATCH),
errmsg_internal("%s", _(msg)),
errmsg("could not convert row type"),
errdetail("Attribute \"%s\" of type %s does not match corresponding attribute of type %s.",
attname,
format_type_be(outdesc->tdtypeid),
@ -311,7 +309,7 @@ convert_tuples_by_name_map(TupleDesc indesc,
if (attrMap[i] == 0)
ereport(ERROR,
(errcode(ERRCODE_DATATYPE_MISMATCH),
errmsg_internal("%s", _(msg)),
errmsg("could not convert row type"),
errdetail("Attribute \"%s\" of type %s does not exist in type %s.",
attname,
format_type_be(outdesc->tdtypeid),
@ -327,8 +325,7 @@ convert_tuples_by_name_map(TupleDesc indesc,
*/
AttrNumber *
convert_tuples_by_name_map_if_req(TupleDesc indesc,
TupleDesc outdesc,
const char *msg)
TupleDesc outdesc)
{
AttrNumber *attrMap;
int n = outdesc->natts;
@ -336,7 +333,7 @@ convert_tuples_by_name_map_if_req(TupleDesc indesc,
bool same;
/* Verify compatibility and prepare attribute-number map */
attrMap = convert_tuples_by_name_map(indesc, outdesc, msg);
attrMap = convert_tuples_by_name_map(indesc, outdesc);
/*
* Check to see if the map is one-to-one, in which case we need not do a

View File

@ -210,8 +210,7 @@ map_partition_varattnos(List *expr, int fromrel_varno,
AttrNumber *part_attnos;
part_attnos = convert_tuples_by_name_map(RelationGetDescr(to_rel),
RelationGetDescr(from_rel),
gettext_noop("could not convert row type"));
RelationGetDescr(from_rel));
expr = (List *) map_variable_attnos((Node *) expr,
fromrel_varno, 0,
part_attnos,

View File

@ -1356,8 +1356,7 @@ acquire_inherited_sample_rows(Relation onerel, int elevel,
TupleConversionMap *map;
map = convert_tuples_by_name(RelationGetDescr(childrel),
RelationGetDescr(onerel),
gettext_noop("could not convert row type"));
RelationGetDescr(onerel));
if (map != NULL)
{
int j;

View File

@ -1086,8 +1086,7 @@ DefineIndex(Oid relationId,
childidxs = RelationGetIndexList(childrel);
attmap =
convert_tuples_by_name_map(RelationGetDescr(childrel),
parentDesc,
gettext_noop("could not convert row type"));
parentDesc);
maplen = parentDesc->natts;
foreach(cell, childidxs)

View File

@ -1087,8 +1087,7 @@ DefineRelation(CreateStmt *stmt, char relkind, Oid ownerId,
}
attmap = convert_tuples_by_name_map(RelationGetDescr(rel),
RelationGetDescr(parent),
gettext_noop("could not convert row type"));
RelationGetDescr(parent));
idxstmt =
generateClonedIndexStmt(NULL, idxRel,
attmap, RelationGetDescr(rel)->natts,
@ -8171,8 +8170,7 @@ addFkRecurseReferenced(List **wqueue, Constraint *fkconstraint, Relation rel,
* definition to match the partition's column layout.
*/
map = convert_tuples_by_name_map_if_req(RelationGetDescr(partRel),
RelationGetDescr(pkrel),
gettext_noop("could not convert row type"));
RelationGetDescr(pkrel));
if (map)
{
mapped_pkattnum = palloc(sizeof(AttrNumber) * numfks);
@ -8314,8 +8312,7 @@ addFkRecurseReferencing(List **wqueue, Constraint *fkconstraint, Relation rel,
CheckTableNotInUse(partition, "ALTER TABLE");
attmap = convert_tuples_by_name_map(RelationGetDescr(partition),
RelationGetDescr(rel),
gettext_noop("could not convert row type"));
RelationGetDescr(rel));
for (int j = 0; j < numfks; j++)
mapped_fkattnum[j] = attmap[fkattnum[j] - 1];
@ -8505,8 +8502,7 @@ CloneFkReferenced(Relation parentRel, Relation partitionRel)
table_close(pg_constraint, RowShareLock);
attmap = convert_tuples_by_name_map(RelationGetDescr(partitionRel),
RelationGetDescr(parentRel),
gettext_noop("could not convert row type"));
RelationGetDescr(parentRel));
foreach(cell, clone)
{
Oid constrOid = lfirst_oid(cell);
@ -8642,8 +8638,7 @@ CloneFkReferencing(List **wqueue, Relation parentRel, Relation partRel)
* different. This map is used to convert them.
*/
attmap = convert_tuples_by_name_map(RelationGetDescr(partRel),
RelationGetDescr(parentRel),
gettext_noop("could not convert row type"));
RelationGetDescr(parentRel));
partFKs = copyObject(RelationGetFKeyList(partRel));
@ -10473,8 +10468,7 @@ ATPrepAlterColumnType(List **wqueue,
cmd = copyObject(cmd);
attmap = convert_tuples_by_name_map(RelationGetDescr(childrel),
RelationGetDescr(rel),
gettext_noop("could not convert row type"));
RelationGetDescr(rel));
((ColumnDef *) cmd->def)->cooked_default =
map_variable_attnos(def->cooked_default,
1, 0,
@ -15845,8 +15839,7 @@ AttachPartitionEnsureIndexes(Relation rel, Relation attachrel)
/* construct an indexinfo to compare existing indexes against */
info = BuildIndexInfo(idxRel);
attmap = convert_tuples_by_name_map(RelationGetDescr(attachrel),
RelationGetDescr(rel),
gettext_noop("could not convert row type"));
RelationGetDescr(rel));
constraintOid = get_relation_idx_constraint_oid(RelationGetRelid(rel), idx);
/*
@ -16422,8 +16415,7 @@ ATExecAttachPartitionIdx(List **wqueue, Relation parentIdx, RangeVar *name)
childInfo = BuildIndexInfo(partIdx);
parentInfo = BuildIndexInfo(parentIdx);
attmap = convert_tuples_by_name_map(RelationGetDescr(partTbl),
RelationGetDescr(parentTbl),
gettext_noop("could not convert row type"));
RelationGetDescr(parentTbl));
if (!CompareIndexInfo(childInfo, parentInfo,
partIdx->rd_indcollation,
parentIdx->rd_indcollation,

View File

@ -3299,9 +3299,7 @@ ExecEvalConvertRowtype(ExprState *state, ExprEvalStep *op, ExprContext *econtext
old_cxt = MemoryContextSwitchTo(econtext->ecxt_per_query_memory);
/* prepare map from old to new attribute numbers */
op->d.convert_rowtype.map =
convert_tuples_by_name(indesc, outdesc,
gettext_noop("could not convert row type"));
op->d.convert_rowtype.map = convert_tuples_by_name(indesc, outdesc);
op->d.convert_rowtype.initialized = true;
MemoryContextSwitchTo(old_cxt);

View File

@ -1861,8 +1861,7 @@ ExecPartitionCheckEmitError(ResultRelInfo *resultRelInfo,
old_tupdesc = RelationGetDescr(resultRelInfo->ri_RelationDesc);
/* a reverse map */
map = convert_tuples_by_name_map_if_req(old_tupdesc, tupdesc,
gettext_noop("could not convert row type"));
map = convert_tuples_by_name_map_if_req(old_tupdesc, tupdesc);
/*
* Partition-specific slot's tupdesc can't be changed, so allocate a
@ -1947,8 +1946,7 @@ ExecConstraints(ResultRelInfo *resultRelInfo,
tupdesc = RelationGetDescr(rel);
/* a reverse map */
map = convert_tuples_by_name_map_if_req(orig_tupdesc,
tupdesc,
gettext_noop("could not convert row type"));
tupdesc);
/*
* Partition-specific slot's tupdesc can't be changed, so
@ -1997,8 +1995,7 @@ ExecConstraints(ResultRelInfo *resultRelInfo,
tupdesc = RelationGetDescr(rel);
/* a reverse map */
map = convert_tuples_by_name_map_if_req(old_tupdesc,
tupdesc,
gettext_noop("could not convert row type"));
tupdesc);
/*
* Partition-specific slot's tupdesc can't be changed, so
@ -2105,8 +2102,7 @@ ExecWithCheckOptions(WCOKind kind, ResultRelInfo *resultRelInfo,
tupdesc = RelationGetDescr(rel);
/* a reverse map */
map = convert_tuples_by_name_map_if_req(old_tupdesc,
tupdesc,
gettext_noop("could not convert row type"));
tupdesc);
/*
* Partition-specific slot's tupdesc can't be changed,

View File

@ -586,8 +586,7 @@ ExecInitPartitionInfo(ModifyTableState *mtstate, EState *estate,
*/
part_attnos =
convert_tuples_by_name_map(RelationGetDescr(partrel),
RelationGetDescr(firstResultRel),
gettext_noop("could not convert row type"));
RelationGetDescr(firstResultRel));
wcoList = (List *)
map_variable_attnos((Node *) wcoList,
firstVarno, 0,
@ -646,8 +645,7 @@ ExecInitPartitionInfo(ModifyTableState *mtstate, EState *estate,
if (part_attnos == NULL)
part_attnos =
convert_tuples_by_name_map(RelationGetDescr(partrel),
RelationGetDescr(firstResultRel),
gettext_noop("could not convert row type"));
RelationGetDescr(firstResultRel));
returningList = (List *)
map_variable_attnos((Node *) returningList,
firstVarno, 0,
@ -790,8 +788,7 @@ ExecInitPartitionInfo(ModifyTableState *mtstate, EState *estate,
if (part_attnos == NULL)
part_attnos =
convert_tuples_by_name_map(RelationGetDescr(partrel),
RelationGetDescr(firstResultRel),
gettext_noop("could not convert row type"));
RelationGetDescr(firstResultRel));
onconflset = (List *)
map_variable_attnos((Node *) onconflset,
INNER_VAR, 0,
@ -904,8 +901,7 @@ ExecInitRoutingInfo(ModifyTableState *mtstate,
*/
partrouteinfo->pi_RootToPartitionMap =
convert_tuples_by_name(RelationGetDescr(partRelInfo->ri_PartitionRoot),
RelationGetDescr(partRelInfo->ri_RelationDesc),
gettext_noop("could not convert row type"));
RelationGetDescr(partRelInfo->ri_RelationDesc));
/*
* If a partition has a different rowtype than the root parent, initialize
@ -937,8 +933,7 @@ ExecInitRoutingInfo(ModifyTableState *mtstate,
{
partrouteinfo->pi_PartitionToRootMap =
convert_tuples_by_name(RelationGetDescr(partRelInfo->ri_RelationDesc),
RelationGetDescr(partRelInfo->ri_PartitionRoot),
gettext_noop("could not convert row type"));
RelationGetDescr(partRelInfo->ri_PartitionRoot));
}
else
partrouteinfo->pi_PartitionToRootMap = NULL;
@ -1042,8 +1037,7 @@ ExecInitPartitionDispatchInfo(EState *estate,
* routing.
*/
pd->tupmap = convert_tuples_by_name_map_if_req(RelationGetDescr(parent_pd->reldesc),
tupdesc,
gettext_noop("could not convert row type"));
tupdesc);
pd->tupslot = pd->tupmap ?
MakeSingleTupleTableSlot(tupdesc, &TTSOpsVirtual) : NULL;
}

View File

@ -1959,8 +1959,7 @@ ExecSetupChildParentMapForSubplan(ModifyTableState *mtstate)
{
mtstate->mt_per_subplan_tupconv_maps[i] =
convert_tuples_by_name(RelationGetDescr(resultRelInfos[i].ri_RelationDesc),
outdesc,
gettext_noop("could not convert row type"));
outdesc);
}
}

View File

@ -36,15 +36,12 @@ extern TupleConversionMap *convert_tuples_by_position(TupleDesc indesc,
const char *msg);
extern TupleConversionMap *convert_tuples_by_name(TupleDesc indesc,
TupleDesc outdesc,
const char *msg);
TupleDesc outdesc);
extern AttrNumber *convert_tuples_by_name_map(TupleDesc indesc,
TupleDesc outdesc,
const char *msg);
TupleDesc outdesc);
extern AttrNumber *convert_tuples_by_name_map_if_req(TupleDesc indesc,
TupleDesc outdesc,
const char *msg);
TupleDesc outdesc);
extern HeapTuple execute_attr_map_tuple(HeapTuple tuple, TupleConversionMap *map);
extern TupleTableSlot *execute_attr_map_slot(AttrNumber *attrMap,