Remove some more useless assignments.
authorTom Lane <tgl@sss.pgh.pa.us>
Fri, 4 Sep 2020 18:32:10 +0000 (14:32 -0400)
committerTom Lane <tgl@sss.pgh.pa.us>
Fri, 4 Sep 2020 18:32:19 +0000 (14:32 -0400)
Found with clang's scan-build tool.  It also whines about a lot of
other dead stores that we should *not* change IMO, either as a matter
of style or future-proofing.  But these places seem like clear
oversights.

Discussion: https://postgr.es/m/CAEudQAo1+AcGppxDSg8k+zF4+Kv+eJyqzEDdbpDg58-=MQcerQ@mail.gmail.com

src/backend/access/brin/brin_tuple.c
src/backend/access/gin/ginbtree.c
src/backend/catalog/pg_depend.c
src/backend/optimizer/plan/planner.c
src/backend/parser/parse_utilcmd.c
src/backend/partitioning/partbounds.c
src/backend/statistics/extended_stats.c
src/backend/tsearch/spell.c

index 6cb7c26b39f2b844acb1564d74610a72eab929e1..46e6b23c87421fdbd9f754c414a9744b54dd4546 100644 (file)
@@ -243,7 +243,6 @@ brin_form_tuple(BrinDesc *brdesc, BlockNumber blkno, BrinMemTuple *tuple,
 
                        *bitP |= bitmask;
                }
-               bitP = ((bits8 *) (rettuple + SizeOfBrinTuple)) - 1;
        }
 
        if (tuple->bt_placeholder)
index 8d08b05f5156ec08302ffac211a0ec028c88a722..82788a5c367a9ea9b43ef68c906b6b031fe36408 100644 (file)
@@ -241,7 +241,6 @@ ginFindParents(GinBtree btree, GinBtreeStack *stack)
 
        blkno = root->blkno;
        buffer = root->buffer;
-       offset = InvalidOffsetNumber;
 
        ptr = (GinBtreeStack *) palloc(sizeof(GinBtreeStack));
 
index 70baf03178f7bb804a237419c92522ca0856b107..f263ff13e55c530f80cfcabbd28fd041e9290273 100644 (file)
@@ -478,7 +478,7 @@ changeDependenciesOf(Oid classId, Oid oldObjectId,
 
        while (HeapTupleIsValid((tup = systable_getnext(scan))))
        {
-               Form_pg_depend depform = (Form_pg_depend) GETSTRUCT(tup);
+               Form_pg_depend depform;
 
                /* make a modifiable copy */
                tup = heap_copytuple(tup);
@@ -561,12 +561,12 @@ changeDependenciesOn(Oid refClassId, Oid oldRefObjectId,
 
        while (HeapTupleIsValid((tup = systable_getnext(scan))))
        {
-               Form_pg_depend depform = (Form_pg_depend) GETSTRUCT(tup);
-
                if (newIsPinned)
                        CatalogTupleDelete(depRel, &tup->t_self);
                else
                {
+                       Form_pg_depend depform;
+
                        /* make a modifiable copy */
                        tup = heap_copytuple(tup);
                        depform = (Form_pg_depend) GETSTRUCT(tup);
index b40a112c25b2324a0530c187756be1cc9feb6be2..139c5e3dc245fd51152f7c05de3680d02c3444a8 100644 (file)
@@ -5097,7 +5097,7 @@ create_ordered_paths(PlannerInfo *root,
                        foreach(lc, input_rel->partial_pathlist)
                        {
                                Path       *input_path = (Path *) lfirst(lc);
-                               Path       *sorted_path = input_path;
+                               Path       *sorted_path;
                                bool            is_sorted;
                                int                     presorted_keys;
                                double          total_groups;
index 6c49554defbcb39ddcb1aff3a2d9b2ba2b679270..ec944371dd36cfabfd64aefe2539042bcaa68f37 100644 (file)
@@ -1765,7 +1765,6 @@ generateClonedIndexStmt(RangeVar *heapRel, Relation source_idx,
                        char       *attname;
 
                        attname = get_attname(indrelid, attnum, false);
-                       keycoltype = get_atttype(indrelid, attnum);
 
                        iparam->name = attname;
                        iparam->expr = NULL;
index 7553d55987739faec466b4ed4566a71fb721de25..419c8fe845160d6f21aeee8e0a1a76b8bcf7e339 100644 (file)
@@ -4259,10 +4259,6 @@ get_qual_for_range(Relation parent, PartitionBoundSpec *spec,
                return result;
        }
 
-       lower_or_start_datum = list_head(spec->lowerdatums);
-       upper_or_start_datum = list_head(spec->upperdatums);
-       num_or_arms = key->partnatts;
-
        /*
         * If it is the recursive call for default, we skip the get_range_nulltest
         * to avoid accumulating the NullTest on the same keys for each partition.
index ab6f1e1c9dc985754563e173bba6272a8fc7c246..9336f9bc5e90472dea37e984ea1f4ca148ef6168 100644 (file)
@@ -232,7 +232,7 @@ ComputeExtStatisticsRows(Relation onerel,
        foreach(lc, lstats)
        {
                StatExtEntry *stat = (StatExtEntry *) lfirst(lc);
-               int                     stattarget = stat->stattarget;
+               int                     stattarget;
                VacAttrStats **stats;
                int                     nattrs = bms_num_members(stat->columns);
 
index 8aab96d3b066091b2cc5431674a8b9bcb2cd2728..49735bc06af8d35c29a81ae01e8a1c49c04ec733 100644 (file)
@@ -2124,7 +2124,6 @@ CheckAffix(const char *word, size_t len, AFFIX *Affix, int flagflags, char *neww
        }
        else
        {
-               int                     err;
                pg_wchar   *data;
                size_t          data_len;
                int                     newword_len;
@@ -2134,7 +2133,8 @@ CheckAffix(const char *word, size_t len, AFFIX *Affix, int flagflags, char *neww
                data = (pg_wchar *) palloc((newword_len + 1) * sizeof(pg_wchar));
                data_len = pg_mb2wchar_with_len(newword, data, newword_len);
 
-               if (!(err = pg_regexec(&(Affix->reg.regex), data, data_len, 0, NULL, 0, NULL, 0)))
+               if (pg_regexec(&(Affix->reg.regex), data, data_len,
+                                          0, NULL, 0, NULL, 0) == REG_OKAY)
                {
                        pfree(data);
                        return newword;