OSDN Git Service

Improve the following.
authorHiroshi Inoue <inoue@tpf.co.jp>
Wed, 30 Aug 2000 08:48:55 +0000 (08:48 +0000)
committerHiroshi Inoue <inoue@tpf.co.jp>
Wed, 30 Aug 2000 08:48:55 +0000 (08:48 +0000)
 =# create table t (id int4 unique);
NOTICE:  CREATE TABLE/UNIQUE will create implicit index 't_id_key' for table 't'
 =# begin;
 query: drop table t;
NOTICE:  Caution: DROP TABLE cannot be rolled back, so don't abort now
NOTICE:  Caution: DROP INDEX cannot be rolled back, so don't abort now
 =# rollback;
 =# drop table t;
NOTICE:  mdopen: couldn't open t: No such file or directory
NOTICE:  RelationIdBuildRelation: smgropen(t): No such file or directory
NOTICE:  mdopen: couldn't open t: No such file or directory
NOTICE:  mdopen: couldn't open t: No such file or directory
NOTICE:  mdopen: couldn't open t_id_key: No such file or directory
NOTICE:  RelationIdBuildRelation: smgropen(t_id_key): No such file or directory
NOTICE:  mdopen: couldn't open t: No such file or directory
NOTICE:  RelationIdBuildRelation: smgropen(t): No such file or directory
NOTICE:  mdopen: couldn't open t: No such file or directory
ERROR:  cannot open relation t

src/backend/utils/cache/relcache.c

index 59758ad..013ade7 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *       $Header: /cvsroot/pgsql/src/backend/utils/cache/relcache.c,v 1.109 2000/08/06 04:39:03 tgl Exp $
+ *       $Header: /cvsroot/pgsql/src/backend/utils/cache/relcache.c,v 1.110 2000/08/30 08:48:55 inoue Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -1595,7 +1595,10 @@ RelationClearRelation(Relation relation, bool rebuildIt)
                 * this is kind of expensive, but I think we must do it in case
                 * relation has been truncated...
                 */
-               relation->rd_nblocks = RelationGetNumberOfBlocks(relation);
+               if (relation->rd_unlinked)
+                       relation->rd_nblocks = 0;
+               else
+                       relation->rd_nblocks = RelationGetNumberOfBlocks(relation);
 
                if (relDescChanged && !RelationHasReferenceCountZero(relation))
                        elog(ERROR, "RelationClearRelation: relation %u modified while in use",