Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1WPiD0-0001QS-Ai for pgsql-bugs@arkaria.postgresql.org; Tue, 18 Mar 2014 00:48:46 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1WPiCz-0002mb-Qn for pgsql-bugs@arkaria.postgresql.org; Tue, 18 Mar 2014 00:48:45 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1WPiCx-0002mS-Qe for pgsql-bugs@postgresql.org; Tue, 18 Mar 2014 00:48:43 +0000 Received: from smtp98.ord1c.emailsrvr.com ([108.166.43.98]) by magus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1WPiCt-0006L6-VI for pgsql-bugs@postgresql.org; Tue, 18 Mar 2014 00:48:43 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp5.relay.ord1c.emailsrvr.com (SMTP Server) with ESMTP id 18ED51B0DF2; Mon, 17 Mar 2014 20:48:38 -0400 (EDT) X-Virus-Scanned: OK Received: by smtp5.relay.ord1c.emailsrvr.com (Authenticated sender: jeff.frost-AT-pgexperts.com) with ESMTPSA id A1DF21B01E8; Mon, 17 Mar 2014 20:48:37 -0400 (EDT) Content-Type: multipart/signed; boundary="Apple-Mail=_686EA7D4-C0B1-45FF-B375-A717390B6C3F"; 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: <7FBC4B95-6AF6-4CFC-A4E2-DE7D9C30AB4B@pgexperts.com> Date: Mon, 17 Mar 2014 17:48:36 -0700 Cc: pgsql-bugs@postgresql.org Message-Id: References: <20140317185255.20724.49675@wrigleys.postgresql.org> <25726.1395082770@sss.pgh.pa.us> <7FBC4B95-6AF6-4CFC-A4E2-DE7D9C30AB4B@pgexperts.com> 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=_686EA7D4-C0B1-45FF-B375-A717390B6C3F Content-Type: multipart/alternative; boundary="Apple-Mail=_E9C1D041-2215-4028-A185-44F7B7D7618A" --Apple-Mail=_E9C1D041-2215-4028-A185-44F7B7D7618A Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii On Mar 17, 2014, at 12:01 PM, Jeff Frost wrote: >=20 > On Mar 17, 2014, at 11:59 AM, Tom Lane wrote: >=20 >=20 > Sure enough, you're right! >=20 > pkey_test=3D# select relname, relhaspkey FROM pg_class where relname =3D= 'foo'; > relname | relhaspkey > ---------+------------ > foo | t > (1 row) >=20 > pkey_test=3D# vacuum foo; > VACUUM > pkey_test=3D# select relname, relhaspkey FROM pg_class where relname =3D= 'foo'; > relname | relhaspkey > ---------+------------ > foo | f > (1 row) >=20 > Thanks, Tom, i had completely forgotten about that! Interestingly, on 9.1.11, I have a table where the pkey was added after = the fact, then dropped, but it still shows as relhaspkey even though I = manually vacuumed it: \d output way after the pkey and associated column were dropped: Table "public.resources" Column | Type | Modifiers ------------+---------+----------- id | bigint | project_id | bigint | name | text | source_uid | integer | old_id | bigint | new_id | bigint | Indexes: "index_resources_on_id" btree (id) "index_resources_on_project_id" btree (project_id) select relname, relhaspkey FROM pg_class where relname =3D 'resources'; relname | relhaspkey -----------+------------ resources | t (1 row) VACUUM resources; select relname, relhaspkey FROM pg_class where relname =3D 'resources'; relname | relhaspkey -----------+------------ resources | t (1 row) Unfortunately, I can't seem to reproduce that behavior with a test case. --Apple-Mail=_E9C1D041-2215-4028-A185-44F7B7D7618A Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=us-ascii
On Mar 17, 2014, at 12:01 PM, Jeff = Frost <jeff@pgexperts.com>= wrote:


On Mar 17, 2014, at 11:59 AM, = Tom Lane <tgl@sss.pgh.pa.us> = wrote:


Sure enough, you're right!

pkey_test=3D# select = relname, relhaspkey FROM pg_class where relname =3D 'foo';
relname | = relhaspkey
---------+------------
foo     | = t
(1 row)

pkey_test=3D# vacuum foo;
VACUUM
pkey_test=3D# = select relname, relhaspkey FROM pg_class where relname =3D = 'foo';
relname | relhaspkey
---------+------------
foo =     | f
(1 row)

Thanks, Tom, i had = completely forgotten about = that!

Interestingly, on 9.1.11, I have = a table where the pkey was added after the fact, then dropped, but it = still shows as relhaspkey even though I manually vacuumed = it:

\d output way after the pkey and associated = column were dropped:

    =  Table "public.resources"
   Column   | =  Type   | = Modifiers
------------+---------+-----------
 id =         | bigint  |
 project_id = | bigint  |
 name       | text   =  |
 source_uid | integer |
 old_id =     | bigint  |
 new_id     | = bigint  |
Indexes:
    = "index_resources_on_id" btree (id)
    = "index_resources_on_project_id" btree = (project_id)

select relname, = relhaspkey FROM pg_class where relname =3D 'resources';
  = relname  | = relhaspkey
-----------+------------
 resources = | t
(1 row)

VACUUM = resources;

select relname, relhaspkey FROM = pg_class where relname =3D 'resources';
  relname  | = relhaspkey
-----------+------------
 resources = | t
(1 = row)



Unf= ortunately, I can't seem to reproduce that behavior with a test = case.


= --Apple-Mail=_E9C1D041-2215-4028-A185-44F7B7D7618A-- --Apple-Mail=_686EA7D4-C0B1-45FF-B375-A717390B6C3F 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/ iEYEARECAAYFAlMnl+QACgkQbElkk0i3T39mLgCeN8XXlA9qqoFVWJezFuQ3ccq3 VQgAnRu/hezwhMD5wl4L2ULZRCETfdV3 =aa9J -----END PGP SIGNATURE----- --Apple-Mail=_686EA7D4-C0B1-45FF-B375-A717390B6C3F--