I made it so it rolled over files at 1MB. My table ended up with 120
authorBruce Momjian <bruce@momjian.us>
Sat, 15 May 1999 22:31:07 +0000 (22:31 +0000)
committerBruce Momjian <bruce@momjian.us>
Sat, 15 May 1999 22:31:07 +0000 (22:31 +0000)
segments, and my indexes had 3(Yes, it DOES work!).
DROP TABLE removed ALL segments from the table, but only the main index
segment.

So it looks like removing the table itself is using mdunlink in md.c,
while removing indexes uses FileNameUnlink() which only unlinks 1 file.
As far as I can tell, calling FileNameUnlink() and mdunlink() is basically
the same, except mdunlink() deletes any extra segments.

I've done some testing and it seems to work.  It also passes regression
tests(except float8, geometry and rules, but that's normal).

If this patch is right, this fixes all known multi-segment problems on
Linux.

Ole Gjerde

src/backend/catalog/index.c

index 6a783bd374fb70805a1cfb2b34b3390666d218c9..a3a09ff57fae4288963060c91b1a6c66384aec6f 100644 (file)
@@ -1187,7 +1187,7 @@ index_destroy(Oid indexId)
         */
        ReleaseRelationBuffers(userindexRelation);
 
-       if (FileNameUnlink(relpath(userindexRelation->rd_rel->relname.data)) < 0)
+       if (mdunlink(userindexRelation) != SM_SUCCESS)
                elog(ERROR, "amdestroyr: unlink: %m");
 
        index_close(userindexRelation);