Commit fe661259 authored by Alvaro Herrera's avatar Alvaro Herrera

Remove 'msg' parameter from convert_tuples_by_name

The message was included as a parameter when this function was added in
dcb2bda9, 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
parent 10f55448
...@@ -203,15 +203,14 @@ convert_tuples_by_position(TupleDesc indesc, ...@@ -203,15 +203,14 @@ convert_tuples_by_position(TupleDesc indesc,
*/ */
TupleConversionMap * TupleConversionMap *
convert_tuples_by_name(TupleDesc indesc, convert_tuples_by_name(TupleDesc indesc,
TupleDesc outdesc, TupleDesc outdesc)
const char *msg)
{ {
TupleConversionMap *map; TupleConversionMap *map;
AttrNumber *attrMap; AttrNumber *attrMap;
int n = outdesc->natts; int n = outdesc->natts;
/* Verify compatibility and prepare attribute-number map */ /* 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) if (attrMap == NULL)
{ {
...@@ -244,8 +243,7 @@ convert_tuples_by_name(TupleDesc indesc, ...@@ -244,8 +243,7 @@ convert_tuples_by_name(TupleDesc indesc,
*/ */
AttrNumber * AttrNumber *
convert_tuples_by_name_map(TupleDesc indesc, convert_tuples_by_name_map(TupleDesc indesc,
TupleDesc outdesc, TupleDesc outdesc)
const char *msg)
{ {
AttrNumber *attrMap; AttrNumber *attrMap;
int outnatts; int outnatts;
...@@ -299,7 +297,7 @@ convert_tuples_by_name_map(TupleDesc indesc, ...@@ -299,7 +297,7 @@ convert_tuples_by_name_map(TupleDesc indesc,
if (atttypid != inatt->atttypid || atttypmod != inatt->atttypmod) if (atttypid != inatt->atttypid || atttypmod != inatt->atttypmod)
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_DATATYPE_MISMATCH), (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.", errdetail("Attribute \"%s\" of type %s does not match corresponding attribute of type %s.",
attname, attname,
format_type_be(outdesc->tdtypeid), format_type_be(outdesc->tdtypeid),
...@@ -311,7 +309,7 @@ convert_tuples_by_name_map(TupleDesc indesc, ...@@ -311,7 +309,7 @@ convert_tuples_by_name_map(TupleDesc indesc,
if (attrMap[i] == 0) if (attrMap[i] == 0)
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_DATATYPE_MISMATCH), (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.", errdetail("Attribute \"%s\" of type %s does not exist in type %s.",
attname, attname,
format_type_be(outdesc->tdtypeid), format_type_be(outdesc->tdtypeid),
...@@ -327,8 +325,7 @@ convert_tuples_by_name_map(TupleDesc indesc, ...@@ -327,8 +325,7 @@ convert_tuples_by_name_map(TupleDesc indesc,
*/ */
AttrNumber * AttrNumber *
convert_tuples_by_name_map_if_req(TupleDesc indesc, convert_tuples_by_name_map_if_req(TupleDesc indesc,
TupleDesc outdesc, TupleDesc outdesc)
const char *msg)
{ {
AttrNumber *attrMap; AttrNumber *attrMap;
int n = outdesc->natts; int n = outdesc->natts;
...@@ -336,7 +333,7 @@ convert_tuples_by_name_map_if_req(TupleDesc indesc, ...@@ -336,7 +333,7 @@ convert_tuples_by_name_map_if_req(TupleDesc indesc,
bool same; bool same;
/* Verify compatibility and prepare attribute-number map */ /* 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 * Check to see if the map is one-to-one, in which case we need not do a
......
...@@ -210,8 +210,7 @@ map_partition_varattnos(List *expr, int fromrel_varno, ...@@ -210,8 +210,7 @@ map_partition_varattnos(List *expr, int fromrel_varno,
AttrNumber *part_attnos; AttrNumber *part_attnos;
part_attnos = convert_tuples_by_name_map(RelationGetDescr(to_rel), part_attnos = convert_tuples_by_name_map(RelationGetDescr(to_rel),
RelationGetDescr(from_rel), RelationGetDescr(from_rel));
gettext_noop("could not convert row type"));
expr = (List *) map_variable_attnos((Node *) expr, expr = (List *) map_variable_attnos((Node *) expr,
fromrel_varno, 0, fromrel_varno, 0,
part_attnos, part_attnos,
......
...@@ -1356,8 +1356,7 @@ acquire_inherited_sample_rows(Relation onerel, int elevel, ...@@ -1356,8 +1356,7 @@ acquire_inherited_sample_rows(Relation onerel, int elevel,
TupleConversionMap *map; TupleConversionMap *map;
map = convert_tuples_by_name(RelationGetDescr(childrel), map = convert_tuples_by_name(RelationGetDescr(childrel),
RelationGetDescr(onerel), RelationGetDescr(onerel));
gettext_noop("could not convert row type"));
if (map != NULL) if (map != NULL)
{ {
int j; int j;
......
...@@ -1086,8 +1086,7 @@ DefineIndex(Oid relationId, ...@@ -1086,8 +1086,7 @@ DefineIndex(Oid relationId,
childidxs = RelationGetIndexList(childrel); childidxs = RelationGetIndexList(childrel);
attmap = attmap =
convert_tuples_by_name_map(RelationGetDescr(childrel), convert_tuples_by_name_map(RelationGetDescr(childrel),
parentDesc, parentDesc);
gettext_noop("could not convert row type"));
maplen = parentDesc->natts; maplen = parentDesc->natts;
foreach(cell, childidxs) foreach(cell, childidxs)
......
...@@ -1087,8 +1087,7 @@ DefineRelation(CreateStmt *stmt, char relkind, Oid ownerId, ...@@ -1087,8 +1087,7 @@ DefineRelation(CreateStmt *stmt, char relkind, Oid ownerId,
} }
attmap = convert_tuples_by_name_map(RelationGetDescr(rel), attmap = convert_tuples_by_name_map(RelationGetDescr(rel),
RelationGetDescr(parent), RelationGetDescr(parent));
gettext_noop("could not convert row type"));
idxstmt = idxstmt =
generateClonedIndexStmt(NULL, idxRel, generateClonedIndexStmt(NULL, idxRel,
attmap, RelationGetDescr(rel)->natts, attmap, RelationGetDescr(rel)->natts,
...@@ -8171,8 +8170,7 @@ addFkRecurseReferenced(List **wqueue, Constraint *fkconstraint, Relation rel, ...@@ -8171,8 +8170,7 @@ addFkRecurseReferenced(List **wqueue, Constraint *fkconstraint, Relation rel,
* definition to match the partition's column layout. * definition to match the partition's column layout.
*/ */
map = convert_tuples_by_name_map_if_req(RelationGetDescr(partRel), map = convert_tuples_by_name_map_if_req(RelationGetDescr(partRel),
RelationGetDescr(pkrel), RelationGetDescr(pkrel));
gettext_noop("could not convert row type"));
if (map) if (map)
{ {
mapped_pkattnum = palloc(sizeof(AttrNumber) * numfks); mapped_pkattnum = palloc(sizeof(AttrNumber) * numfks);
...@@ -8314,8 +8312,7 @@ addFkRecurseReferencing(List **wqueue, Constraint *fkconstraint, Relation rel, ...@@ -8314,8 +8312,7 @@ addFkRecurseReferencing(List **wqueue, Constraint *fkconstraint, Relation rel,
CheckTableNotInUse(partition, "ALTER TABLE"); CheckTableNotInUse(partition, "ALTER TABLE");
attmap = convert_tuples_by_name_map(RelationGetDescr(partition), attmap = convert_tuples_by_name_map(RelationGetDescr(partition),
RelationGetDescr(rel), RelationGetDescr(rel));
gettext_noop("could not convert row type"));
for (int j = 0; j < numfks; j++) for (int j = 0; j < numfks; j++)
mapped_fkattnum[j] = attmap[fkattnum[j] - 1]; mapped_fkattnum[j] = attmap[fkattnum[j] - 1];
...@@ -8505,8 +8502,7 @@ CloneFkReferenced(Relation parentRel, Relation partitionRel) ...@@ -8505,8 +8502,7 @@ CloneFkReferenced(Relation parentRel, Relation partitionRel)
table_close(pg_constraint, RowShareLock); table_close(pg_constraint, RowShareLock);
attmap = convert_tuples_by_name_map(RelationGetDescr(partitionRel), attmap = convert_tuples_by_name_map(RelationGetDescr(partitionRel),
RelationGetDescr(parentRel), RelationGetDescr(parentRel));
gettext_noop("could not convert row type"));
foreach(cell, clone) foreach(cell, clone)
{ {
Oid constrOid = lfirst_oid(cell); Oid constrOid = lfirst_oid(cell);
...@@ -8642,8 +8638,7 @@ CloneFkReferencing(List **wqueue, Relation parentRel, Relation partRel) ...@@ -8642,8 +8638,7 @@ CloneFkReferencing(List **wqueue, Relation parentRel, Relation partRel)
* different. This map is used to convert them. * different. This map is used to convert them.
*/ */
attmap = convert_tuples_by_name_map(RelationGetDescr(partRel), attmap = convert_tuples_by_name_map(RelationGetDescr(partRel),
RelationGetDescr(parentRel), RelationGetDescr(parentRel));
gettext_noop("could not convert row type"));
partFKs = copyObject(RelationGetFKeyList(partRel)); partFKs = copyObject(RelationGetFKeyList(partRel));
...@@ -10473,8 +10468,7 @@ ATPrepAlterColumnType(List **wqueue, ...@@ -10473,8 +10468,7 @@ ATPrepAlterColumnType(List **wqueue,
cmd = copyObject(cmd); cmd = copyObject(cmd);
attmap = convert_tuples_by_name_map(RelationGetDescr(childrel), attmap = convert_tuples_by_name_map(RelationGetDescr(childrel),
RelationGetDescr(rel), RelationGetDescr(rel));
gettext_noop("could not convert row type"));
((ColumnDef *) cmd->def)->cooked_default = ((ColumnDef *) cmd->def)->cooked_default =
map_variable_attnos(def->cooked_default, map_variable_attnos(def->cooked_default,
1, 0, 1, 0,
...@@ -15845,8 +15839,7 @@ AttachPartitionEnsureIndexes(Relation rel, Relation attachrel) ...@@ -15845,8 +15839,7 @@ AttachPartitionEnsureIndexes(Relation rel, Relation attachrel)
/* construct an indexinfo to compare existing indexes against */ /* construct an indexinfo to compare existing indexes against */
info = BuildIndexInfo(idxRel); info = BuildIndexInfo(idxRel);
attmap = convert_tuples_by_name_map(RelationGetDescr(attachrel), attmap = convert_tuples_by_name_map(RelationGetDescr(attachrel),
RelationGetDescr(rel), RelationGetDescr(rel));
gettext_noop("could not convert row type"));
constraintOid = get_relation_idx_constraint_oid(RelationGetRelid(rel), idx); constraintOid = get_relation_idx_constraint_oid(RelationGetRelid(rel), idx);
/* /*
...@@ -16422,8 +16415,7 @@ ATExecAttachPartitionIdx(List **wqueue, Relation parentIdx, RangeVar *name) ...@@ -16422,8 +16415,7 @@ ATExecAttachPartitionIdx(List **wqueue, Relation parentIdx, RangeVar *name)
childInfo = BuildIndexInfo(partIdx); childInfo = BuildIndexInfo(partIdx);
parentInfo = BuildIndexInfo(parentIdx); parentInfo = BuildIndexInfo(parentIdx);
attmap = convert_tuples_by_name_map(RelationGetDescr(partTbl), attmap = convert_tuples_by_name_map(RelationGetDescr(partTbl),
RelationGetDescr(parentTbl), RelationGetDescr(parentTbl));
gettext_noop("could not convert row type"));
if (!CompareIndexInfo(childInfo, parentInfo, if (!CompareIndexInfo(childInfo, parentInfo,
partIdx->rd_indcollation, partIdx->rd_indcollation,
parentIdx->rd_indcollation, parentIdx->rd_indcollation,
......
...@@ -3299,9 +3299,7 @@ ExecEvalConvertRowtype(ExprState *state, ExprEvalStep *op, ExprContext *econtext ...@@ -3299,9 +3299,7 @@ ExecEvalConvertRowtype(ExprState *state, ExprEvalStep *op, ExprContext *econtext
old_cxt = MemoryContextSwitchTo(econtext->ecxt_per_query_memory); old_cxt = MemoryContextSwitchTo(econtext->ecxt_per_query_memory);
/* prepare map from old to new attribute numbers */ /* prepare map from old to new attribute numbers */
op->d.convert_rowtype.map = op->d.convert_rowtype.map = convert_tuples_by_name(indesc, outdesc);
convert_tuples_by_name(indesc, outdesc,
gettext_noop("could not convert row type"));
op->d.convert_rowtype.initialized = true; op->d.convert_rowtype.initialized = true;
MemoryContextSwitchTo(old_cxt); MemoryContextSwitchTo(old_cxt);
......
...@@ -1861,8 +1861,7 @@ ExecPartitionCheckEmitError(ResultRelInfo *resultRelInfo, ...@@ -1861,8 +1861,7 @@ ExecPartitionCheckEmitError(ResultRelInfo *resultRelInfo,
old_tupdesc = RelationGetDescr(resultRelInfo->ri_RelationDesc); old_tupdesc = RelationGetDescr(resultRelInfo->ri_RelationDesc);
/* a reverse map */ /* a reverse map */
map = convert_tuples_by_name_map_if_req(old_tupdesc, tupdesc, map = convert_tuples_by_name_map_if_req(old_tupdesc, tupdesc);
gettext_noop("could not convert row type"));
/* /*
* Partition-specific slot's tupdesc can't be changed, so allocate a * Partition-specific slot's tupdesc can't be changed, so allocate a
...@@ -1947,8 +1946,7 @@ ExecConstraints(ResultRelInfo *resultRelInfo, ...@@ -1947,8 +1946,7 @@ ExecConstraints(ResultRelInfo *resultRelInfo,
tupdesc = RelationGetDescr(rel); tupdesc = RelationGetDescr(rel);
/* a reverse map */ /* a reverse map */
map = convert_tuples_by_name_map_if_req(orig_tupdesc, map = convert_tuples_by_name_map_if_req(orig_tupdesc,
tupdesc, tupdesc);
gettext_noop("could not convert row type"));
/* /*
* Partition-specific slot's tupdesc can't be changed, so * Partition-specific slot's tupdesc can't be changed, so
...@@ -1997,8 +1995,7 @@ ExecConstraints(ResultRelInfo *resultRelInfo, ...@@ -1997,8 +1995,7 @@ ExecConstraints(ResultRelInfo *resultRelInfo,
tupdesc = RelationGetDescr(rel); tupdesc = RelationGetDescr(rel);
/* a reverse map */ /* a reverse map */
map = convert_tuples_by_name_map_if_req(old_tupdesc, map = convert_tuples_by_name_map_if_req(old_tupdesc,
tupdesc, tupdesc);
gettext_noop("could not convert row type"));
/* /*
* Partition-specific slot's tupdesc can't be changed, so * Partition-specific slot's tupdesc can't be changed, so
...@@ -2105,8 +2102,7 @@ ExecWithCheckOptions(WCOKind kind, ResultRelInfo *resultRelInfo, ...@@ -2105,8 +2102,7 @@ ExecWithCheckOptions(WCOKind kind, ResultRelInfo *resultRelInfo,
tupdesc = RelationGetDescr(rel); tupdesc = RelationGetDescr(rel);
/* a reverse map */ /* a reverse map */
map = convert_tuples_by_name_map_if_req(old_tupdesc, map = convert_tuples_by_name_map_if_req(old_tupdesc,
tupdesc, tupdesc);
gettext_noop("could not convert row type"));
/* /*
* Partition-specific slot's tupdesc can't be changed, * Partition-specific slot's tupdesc can't be changed,
......
...@@ -586,8 +586,7 @@ ExecInitPartitionInfo(ModifyTableState *mtstate, EState *estate, ...@@ -586,8 +586,7 @@ ExecInitPartitionInfo(ModifyTableState *mtstate, EState *estate,
*/ */
part_attnos = part_attnos =
convert_tuples_by_name_map(RelationGetDescr(partrel), convert_tuples_by_name_map(RelationGetDescr(partrel),
RelationGetDescr(firstResultRel), RelationGetDescr(firstResultRel));
gettext_noop("could not convert row type"));
wcoList = (List *) wcoList = (List *)
map_variable_attnos((Node *) wcoList, map_variable_attnos((Node *) wcoList,
firstVarno, 0, firstVarno, 0,
...@@ -646,8 +645,7 @@ ExecInitPartitionInfo(ModifyTableState *mtstate, EState *estate, ...@@ -646,8 +645,7 @@ ExecInitPartitionInfo(ModifyTableState *mtstate, EState *estate,
if (part_attnos == NULL) if (part_attnos == NULL)
part_attnos = part_attnos =
convert_tuples_by_name_map(RelationGetDescr(partrel), convert_tuples_by_name_map(RelationGetDescr(partrel),
RelationGetDescr(firstResultRel), RelationGetDescr(firstResultRel));
gettext_noop("could not convert row type"));
returningList = (List *) returningList = (List *)
map_variable_attnos((Node *) returningList, map_variable_attnos((Node *) returningList,
firstVarno, 0, firstVarno, 0,
...@@ -790,8 +788,7 @@ ExecInitPartitionInfo(ModifyTableState *mtstate, EState *estate, ...@@ -790,8 +788,7 @@ ExecInitPartitionInfo(ModifyTableState *mtstate, EState *estate,
if (part_attnos == NULL) if (part_attnos == NULL)
part_attnos = part_attnos =
convert_tuples_by_name_map(RelationGetDescr(partrel), convert_tuples_by_name_map(RelationGetDescr(partrel),
RelationGetDescr(firstResultRel), RelationGetDescr(firstResultRel));
gettext_noop("could not convert row type"));
onconflset = (List *) onconflset = (List *)
map_variable_attnos((Node *) onconflset, map_variable_attnos((Node *) onconflset,
INNER_VAR, 0, INNER_VAR, 0,
...@@ -904,8 +901,7 @@ ExecInitRoutingInfo(ModifyTableState *mtstate, ...@@ -904,8 +901,7 @@ ExecInitRoutingInfo(ModifyTableState *mtstate,
*/ */
partrouteinfo->pi_RootToPartitionMap = partrouteinfo->pi_RootToPartitionMap =
convert_tuples_by_name(RelationGetDescr(partRelInfo->ri_PartitionRoot), convert_tuples_by_name(RelationGetDescr(partRelInfo->ri_PartitionRoot),
RelationGetDescr(partRelInfo->ri_RelationDesc), RelationGetDescr(partRelInfo->ri_RelationDesc));
gettext_noop("could not convert row type"));
/* /*
* If a partition has a different rowtype than the root parent, initialize * If a partition has a different rowtype than the root parent, initialize
...@@ -937,8 +933,7 @@ ExecInitRoutingInfo(ModifyTableState *mtstate, ...@@ -937,8 +933,7 @@ ExecInitRoutingInfo(ModifyTableState *mtstate,
{ {
partrouteinfo->pi_PartitionToRootMap = partrouteinfo->pi_PartitionToRootMap =
convert_tuples_by_name(RelationGetDescr(partRelInfo->ri_RelationDesc), convert_tuples_by_name(RelationGetDescr(partRelInfo->ri_RelationDesc),
RelationGetDescr(partRelInfo->ri_PartitionRoot), RelationGetDescr(partRelInfo->ri_PartitionRoot));
gettext_noop("could not convert row type"));
} }
else else
partrouteinfo->pi_PartitionToRootMap = NULL; partrouteinfo->pi_PartitionToRootMap = NULL;
...@@ -1042,8 +1037,7 @@ ExecInitPartitionDispatchInfo(EState *estate, ...@@ -1042,8 +1037,7 @@ ExecInitPartitionDispatchInfo(EState *estate,
* routing. * routing.
*/ */
pd->tupmap = convert_tuples_by_name_map_if_req(RelationGetDescr(parent_pd->reldesc), pd->tupmap = convert_tuples_by_name_map_if_req(RelationGetDescr(parent_pd->reldesc),
tupdesc, tupdesc);
gettext_noop("could not convert row type"));
pd->tupslot = pd->tupmap ? pd->tupslot = pd->tupmap ?
MakeSingleTupleTableSlot(tupdesc, &TTSOpsVirtual) : NULL; MakeSingleTupleTableSlot(tupdesc, &TTSOpsVirtual) : NULL;
} }
......
...@@ -1959,8 +1959,7 @@ ExecSetupChildParentMapForSubplan(ModifyTableState *mtstate) ...@@ -1959,8 +1959,7 @@ ExecSetupChildParentMapForSubplan(ModifyTableState *mtstate)
{ {
mtstate->mt_per_subplan_tupconv_maps[i] = mtstate->mt_per_subplan_tupconv_maps[i] =
convert_tuples_by_name(RelationGetDescr(resultRelInfos[i].ri_RelationDesc), convert_tuples_by_name(RelationGetDescr(resultRelInfos[i].ri_RelationDesc),
outdesc, outdesc);
gettext_noop("could not convert row type"));
} }
} }
......
...@@ -36,15 +36,12 @@ extern TupleConversionMap *convert_tuples_by_position(TupleDesc indesc, ...@@ -36,15 +36,12 @@ extern TupleConversionMap *convert_tuples_by_position(TupleDesc indesc,
const char *msg); const char *msg);
extern TupleConversionMap *convert_tuples_by_name(TupleDesc indesc, extern TupleConversionMap *convert_tuples_by_name(TupleDesc indesc,
TupleDesc outdesc, TupleDesc outdesc);
const char *msg);
extern AttrNumber *convert_tuples_by_name_map(TupleDesc indesc, extern AttrNumber *convert_tuples_by_name_map(TupleDesc indesc,
TupleDesc outdesc, TupleDesc outdesc);
const char *msg);
extern AttrNumber *convert_tuples_by_name_map_if_req(TupleDesc indesc, extern AttrNumber *convert_tuples_by_name_map_if_req(TupleDesc indesc,
TupleDesc outdesc, TupleDesc outdesc);
const char *msg);
extern HeapTuple execute_attr_map_tuple(HeapTuple tuple, TupleConversionMap *map); extern HeapTuple execute_attr_map_tuple(HeapTuple tuple, TupleConversionMap *map);
extern TupleTableSlot *execute_attr_map_slot(AttrNumber *attrMap, extern TupleTableSlot *execute_attr_map_slot(AttrNumber *attrMap,
......
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