pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
BUG #15539: Deadcode in OpenTableList
2+ messages / 2 participants
[nested] [flat]

Commits from this thread:
  2018-12-07 9286ef8e91 6bc8193193 aaf7b3bd6f  Clean up sloppy coding in publicationcmds.c's OpenTableList().
* BUG #15539: Deadcode in OpenTableList
@ 2018-12-07 10:18  PG Bug reporting form <noreply@postgresql.org>
  0 siblings, 1 reply; 2+ messages in thread

From: PG Bug reporting form @ 2018-12-07 10:18 UTC (permalink / raw)
  To: pgsql-bugs@lists.postgresql.org; +Cc: bianpan2016@163.com

The following bug has been logged on the website:

Bug reference:      15539
Logged by:          Pan Bian
Email address:      bianpan2016@163.com
PostgreSQL version: 11.1
Operating system:   Linux
Description:        

File: src/backend/commands/publicationcmds.c
Function: OpenTableList
Issue details:
The function OpenTableList performs the condition check " if
(list_member_oid(relids, childrelid))" twice. The second condition will
always evaluate to FALSE. As a result, the code (i.e., heap_close) on the
true branch of the second condition check is deadcode.

For your convenience, I copy-and-paste related code as follows.

static List *
OpenTableList(List *tables)
{
    ...
    foreach(lc, tables)
    {
        ...
        if (recurse)
        {
            ...
            foreach(child, children)
            {
                Oid         childrelid = lfirst_oid(child);

                if (list_member_oid(relids, childrelid))   //### first
check
                    continue;

                /*  
                 * Skip duplicates if user specified both parent and child
                 * tables.
                 */
                if (list_member_oid(relids, childrelid))  //### second
check, always be false
                {  //### deadcode
                    heap_close(rel, ShareUpdateExclusiveLock);
                    continue;
                }

                /* find_all_inheritors already got lock */
                rel = heap_open(childrelid, NoLock);
                rels = lappend(rels, rel);
                relids = lappend_oid(relids, childrelid);
            }
        }
    }   

    list_free(relids);

    return rels;
}

Thank you,
Pan Bian



^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: BUG #15539: Deadcode in OpenTableList
@ 2018-12-07 16:04  Tom Lane <tgl@sss.pgh.pa.us>
  parent: PG Bug reporting form <noreply@postgresql.org>
  0 siblings, 0 replies; 2+ messages in thread

From: Tom Lane @ 2018-12-07 16:04 UTC (permalink / raw)
  To: bianpan2016@163.com; +Cc: pgsql-bugs@lists.postgresql.org

=?utf-8?q?PG_Bug_reporting_form?= <noreply@postgresql.org> writes:
> The function OpenTableList performs the condition check " if
> (list_member_oid(relids, childrelid))" twice. The second condition will
> always evaluate to FALSE. As a result, the code (i.e., heap_close) on the
> true branch of the second condition check is deadcode.

Yeah, you're right.  I wonder whether we should've expected Coverity
to notice that.

Fix pushed, thanks for the report!

			regards, tom lane




^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2018-12-07 16:04 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2018-12-07 10:18 BUG #15539: Deadcode in OpenTableList PG Bug reporting form <noreply@postgresql.org>
2018-12-07 16:04 ` Tom Lane <tgl@sss.pgh.pa.us>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox