Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Remove 'msg' parameter from convert_tuples_by_name
authorAlvaro Herrera <alvherre@alvh.no-ip.org>
Tue, 3 Sep 2019 18:47:29 +0000 (14:47 -0400)
committerAlvaro Herrera <alvherre@alvh.no-ip.org>
Tue, 3 Sep 2019 18:47:29 +0000 (14:47 -0400)
The message was included as a parameter when this function was added in
dcb2bda9b704, 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

src/backend/access/common/tupconvert.c
src/backend/catalog/partition.c
src/backend/commands/analyze.c
src/backend/commands/indexcmds.c
src/backend/commands/tablecmds.c
src/backend/executor/execExprInterp.c
src/backend/executor/execMain.c
src/backend/executor/execPartition.c
src/backend/executor/nodeModifyTable.c
src/include/access/tupconvert.h

index 8cda16431c1c7b443b9e8acec28712ff641b78cf..0ec9cd5870d4c7d2935fafbe6bae31fd44698992 100644 (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
index 07b82233486eef9964eaf08dc8e34f541ed0cbcd..53af14e939e988e7b195405c18598055c345cc46 100644 (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,
index 92285e848f539b2d77490439c9e9d95e94825906..d2fdf447b6559130c0b5420e2b2881ab97115b2e 100644 (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;
index ef9539537119bf1a1d740dc776864b16a6ee05d2..147775558c1390e6c6c18cd57b096010f646748b 100644 (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)
index cceefbdd49fa9214a45c191f2a2de5d768feb106..decd1bbeb8ceddd9397dc480fbd17771209c7e6f 100644 (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,
index d61f75bc3b6556a7f5920d81cf73ec950562a799..9731dd59ca5db70104831bcf42eb14904418ff18 100644 (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);
index 7f494abf14ab632908134ff950b5f7572dafc4de..f05fc37f378f384fb00ece7f3a58b932595c5073 100644 (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,
index 729dc396a94c103659feb7d83ddf2621a2016b54..d23f292cb08806511ad2cd5013d5c46e8168a182 100644 (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;
    }
index 9e0c8794c4026caae1db7ab8a29d577d01bba48e..01fe11aa6890b172ecea52a3281ec83eae550e62 100644 (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);
    }
 }
 
index 509e5c44efce2464e0c78430f362d72fb084f76b..6d095f8e0d137321d97c52af7c92e7115adea5c0 100644 (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,