Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1asAnj-0002Ih-VV for pgsql-hackers@arkaria.postgresql.org; Mon, 18 Apr 2016 15:09:24 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1asAnj-0003Ij-Bs for pgsql-hackers@arkaria.postgresql.org; Mon, 18 Apr 2016 15:09:23 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1asAmM-0000ys-8m for pgsql-hackers@postgresql.org; Mon, 18 Apr 2016 15:07:58 +0000 Received: from newmail.postgrespro.ru ([93.174.131.138] helo=mail.postgrespro.ru) by makus.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1asAmJ-0006ej-3c for pgsql-hackers@postgresql.org; Mon, 18 Apr 2016 15:07:57 +0000 Received: from localhost (localhost [127.0.0.1]) by mail.postgrespro.ru (Postfix) with ESMTP id 3E76821C7C8A for ; Mon, 18 Apr 2016 18:07:53 +0300 (MSK) Received: from mail.postgrespro.ru ([127.0.0.1]) by localhost (mail.postgrespro.ru [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Gg6Az_MdNCqB for ; Mon, 18 Apr 2016 18:07:51 +0300 (MSK) Received: from fujitsu (unknown [192.168.27.1]) by mail.postgrespro.ru (Postfix) with ESMTPSA id 6330421C7BC0 for ; Mon, 18 Apr 2016 18:07:51 +0300 (MSK) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=postgrespro.ru; s=mail; t=1460992071; bh=Fp8uW6mffvK6dsnR96SsCVPuh0uz8TtC/TEnv+W43g4=; h=Date:From:To:Subject; b=g+oCEegl6PpSVZL1Hx4wws6xGE1TPVCKk1mNItf1zYjFYd7/JApq9+c/vGGnRRhqx gIbMR6lYYumVkNVY66j+ZVRGWwJbrayT1eUlVd6VFLZXrN+ixrtcl7v+iddOoj5ECt rp4V/HS5miQbC+pYBYEmCe/tLPbar+pXj0HLaoUU= Date: Mon, 18 Apr 2016 18:07:11 +0300 From: Aleksander Alekseev To: pgsql-hackers Subject: Should we remove unused code? Message-ID: <20160418180711.55ac82c0@fujitsu> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="MP_/BlcIJFwf9Exa=xCojMCnlqI" X-Pg-Spam-Score: -3.0 (---) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-hackers Precedence: bulk Sender: pgsql-hackers-owner@postgresql.org --MP_/BlcIJFwf9Exa=xCojMCnlqI Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Content-Disposition: inline Hello Today I've read this post: http://blog.2ndquadrant.com/code-coverage/ I think its great and that everyone in this mailing list should familiarize themselves with it. Reading the coverage report, I discovered that some code is never executed. Sometimes its OK (error reporting in out-of-memory cases), sometimes its not (not enough tests). But there are also cases I'm not sure about. For instance there are two flags - HASH_SEGMENT and HASH_FFACTOR that are in fact never used (see attachment). I wonder whether we should keep code like this or not. What do you think? -- Best regards, Aleksander Alekseev http://eax.me/ --MP_/BlcIJFwf9Exa=xCojMCnlqI Content-Type: text/x-patch Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename=remove-unused-code.patch diff --git a/src/backend/utils/hash/dynahash.c b/src/backend/utils/hash/dynahash.c index 1a9f70c..9b32ceb 100644 --- a/src/backend/utils/hash/dynahash.c +++ b/src/backend/utils/hash/dynahash.c @@ -452,16 +452,6 @@ hash_create(const char *tabname, long nelem, HASHCTL *info, int flags) hctl->num_partitions = info->num_partitions; } - if (flags & HASH_SEGMENT) - { - hctl->ssize = info->ssize; - hctl->sshift = my_log2(info->ssize); - /* ssize had better be a power of 2 */ - Assert(hctl->ssize == (1L << hctl->sshift)); - } - if (flags & HASH_FFACTOR) - hctl->ffactor = info->ffactor; - /* * SHM hash tables have fixed directory size passed by the caller. */ diff --git a/src/include/utils/hsearch.h b/src/include/utils/hsearch.h index 007ba2c..0646a72 100644 --- a/src/include/utils/hsearch.h +++ b/src/include/utils/hsearch.h @@ -81,9 +81,7 @@ typedef struct HASHCTL /* Flags to indicate which parameters are supplied */ #define HASH_PARTITION 0x0001 /* Hashtable is used w/partitioned locking */ -#define HASH_SEGMENT 0x0002 /* Set segment size */ #define HASH_DIRSIZE 0x0004 /* Set directory size (initial and max) */ -#define HASH_FFACTOR 0x0008 /* Set fill factor */ #define HASH_ELEM 0x0010 /* Set keysize and entrysize */ #define HASH_BLOBS 0x0020 /* Select support functions for binary keys */ #define HASH_FUNCTION 0x0040 /* Set user defined hash function */ --MP_/BlcIJFwf9Exa=xCojMCnlqI Content-Type: text/plain Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers --MP_/BlcIJFwf9Exa=xCojMCnlqI--