Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1WPcn0-00040B-0T for pgsql-bugs@arkaria.postgresql.org; Mon, 17 Mar 2014 19:01:34 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1WPcmz-0000tv-H0 for pgsql-bugs@arkaria.postgresql.org; Mon, 17 Mar 2014 19:01:33 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1WPcmy-0000tp-Qv for pgsql-bugs@postgresql.org; Mon, 17 Mar 2014 19:01:32 +0000 Received: from smtp82.ord1c.emailsrvr.com ([108.166.43.82]) by magus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1WPcmv-0008LK-Ce for pgsql-bugs@postgresql.org; Mon, 17 Mar 2014 19:01:32 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp3.relay.ord1c.emailsrvr.com (SMTP Server) with ESMTP id 599DA50F2B; Mon, 17 Mar 2014 15:01:28 -0400 (EDT) X-Virus-Scanned: OK Received: by smtp3.relay.ord1c.emailsrvr.com (Authenticated sender: jeff.frost-AT-pgexperts.com) with ESMTPSA id 818E450F2E; Mon, 17 Mar 2014 15:01:26 -0400 (EDT) Content-Type: multipart/signed; boundary="Apple-Mail=_039BECAF-71F0-49CA-8E27-81B0BF34D0D3"; protocol="application/pgp-signature"; micalg=pgp-sha1 Mime-Version: 1.0 (Mac OS X Mail 7.2 \(1874\)) Subject: Re: BUG #9606: pg_class relhaspkey column not updated on removal of primary key From: Jeff Frost In-Reply-To: <25726.1395082770@sss.pgh.pa.us> Date: Mon, 17 Mar 2014 12:01:24 -0700 Cc: pgsql-bugs@postgresql.org Message-Id: <7FBC4B95-6AF6-4CFC-A4E2-DE7D9C30AB4B@pgexperts.com> References: <20140317185255.20724.49675@wrigleys.postgresql.org> <25726.1395082770@sss.pgh.pa.us> To: Tom Lane X-Mailer: Apple Mail (2.1874) X-Pg-Spam-Score: -1.9 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org --Apple-Mail=_039BECAF-71F0-49CA-8E27-81B0BF34D0D3 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=us-ascii On Mar 17, 2014, at 11:59 AM, Tom Lane wrote: > jeff@pgexperts.com writes: >> [ $SUBJECT ] > > This is not a bug; please read the description of pg_class: > > relhaspkey bool True if the table has (or once had) a primary key > > The note at the bottom of the page explains why: > > Several of the Boolean flags in pg_class are maintained lazily: they are > guaranteed to be true if that's the correct state, but may not be reset to > false immediately when the condition is no longer true. For example, > relhasindex is set by CREATE INDEX, but it is never cleared by DROP > INDEX. Instead, VACUUM clears relhasindex if it finds the table has no > indexes. This arrangement avoids race conditions and improves concurrency. Sure enough, you're right! pkey_test=# select relname, relhaspkey FROM pg_class where relname = 'foo'; relname | relhaspkey ---------+------------ foo | t (1 row) pkey_test=# vacuum foo; VACUUM pkey_test=# select relname, relhaspkey FROM pg_class where relname = 'foo'; relname | relhaspkey ---------+------------ foo | f (1 row) Thanks, Tom, i had completely forgotten about that! --Apple-Mail=_039BECAF-71F0-49CA-8E27-81B0BF34D0D3 Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename=signature.asc Content-Type: application/pgp-signature; name=signature.asc Content-Description: Message signed with OpenPGP using GPGMail -----BEGIN PGP SIGNATURE----- Comment: GPGTools - http://www.gpgtools.org/ iEYEARECAAYFAlMnRoQACgkQbElkk0i3T39fLQCgsAAxRd1R5bK4ZyLPsGKhdtXi meMAn1aEnTd8iXCmYYP24LUaf24GhSJJ =iY4o -----END PGP SIGNATURE----- --Apple-Mail=_039BECAF-71F0-49CA-8E27-81B0BF34D0D3--