|
8 | 8 | * |
9 | 9 | * |
10 | 10 | * IDENTIFICATION |
11 | | - * $Header: /cvsroot/pgsql/src/backend/commands/vacuum.c,v 1.194 2001/05/25 15:34:49 momjian Exp $ |
| 11 | + * $Header: /cvsroot/pgsql/src/backend/commands/vacuum.c,v 1.195 2001/05/25 15:45:32 momjian Exp $ |
12 | 12 | * |
13 | 13 | *------------------------------------------------------------------------- |
14 | 14 | */ |
15 | 15 | #include "postgres.h" |
16 | 16 |
|
17 | 17 | #include <fcntl.h> |
18 | 18 | #include <unistd.h> |
19 | | -#include <stdlib.h> |
20 | | -#include <limits.h> |
21 | 19 | #include <time.h> |
22 | 20 | #include <sys/time.h> |
23 | 21 | #include <sys/types.h> |
24 | | -#include <dirent.h> |
25 | 22 | #include <sys/file.h> |
26 | 23 | #include <sys/stat.h> |
27 | 24 |
|
|
33 | 30 |
|
34 | 31 | #include "access/genam.h" |
35 | 32 | #include "access/heapam.h" |
36 | | -#include "access/transam.h" |
37 | 33 | #include "access/xlog.h" |
38 | 34 | #include "catalog/catalog.h" |
39 | 35 | #include "catalog/catname.h" |
@@ -163,7 +159,6 @@ static int vac_cmp_vtlinks(const void *left, const void *right); |
163 | 159 | static bool enough_space(VacPage vacpage, Size len); |
164 | 160 | static void init_rusage(VacRUsage *ru0); |
165 | 161 | static char *show_rusage(VacRUsage *ru0); |
166 | | -static void report_orphans(void); |
167 | 162 |
|
168 | 163 |
|
169 | 164 | /* |
@@ -241,10 +236,6 @@ vacuum(VacuumStmt *vacstmt) |
241 | 236 |
|
242 | 237 | /* clean up */ |
243 | 238 | vacuum_shutdown(); |
244 | | - |
245 | | - if (VacRelName == NULL) |
246 | | - report_orphans(); |
247 | | - |
248 | 239 | } |
249 | 240 |
|
250 | 241 | /* |
@@ -2655,74 +2646,3 @@ show_rusage(VacRUsage *ru0) |
2655 | 2646 |
|
2656 | 2647 | return result; |
2657 | 2648 | } |
2658 | | - |
2659 | | -/* |
2660 | | - * report_orphans |
2661 | | - * |
2662 | | - * Report files that are not referenced by any pg_class.relfilenode. |
2663 | | - * Could be caused by backend crash no cleaning up. |
2664 | | - */ |
2665 | | -static void |
2666 | | -report_orphans(void) |
2667 | | -{ |
2668 | | - DIR *db_dir; |
2669 | | - struct dirent *db_de; |
2670 | | - Relation rel; |
2671 | | - TupleDesc tupdesc; |
2672 | | - HeapScanDesc scan; |
2673 | | - HeapTuple tuple; |
2674 | | - Oid dir_file_oid; |
2675 | | - Oid rel_file_oid; |
2676 | | - Datum d; |
2677 | | - bool n; |
2678 | | - bool match_found; |
2679 | | - char cwd[MAXPGPATH]; |
2680 | | - |
2681 | | - getcwd(cwd,MAXPGPATH); |
2682 | | - db_dir = opendir("."); |
2683 | | - rel = heap_openr(RelationRelationName, AccessShareLock); |
2684 | | - Assert(db_dir); |
2685 | | - |
2686 | | - /* |
2687 | | - * Cycle through directory and check each file against |
2688 | | - * pg_class.relfilenode. |
2689 | | - * XXX This is O(n^2). Is it too slow? bjm |
2690 | | - */ |
2691 | | - while ((db_de = readdir(db_dir)) != NULL) |
2692 | | - { |
2693 | | - if (strspn(db_de->d_name, "0123456789") == |
2694 | | - strlen(db_de->d_name)) |
2695 | | - { |
2696 | | - dir_file_oid = (Oid) strtoul((db_de->d_name), NULL, 10); |
2697 | | - |
2698 | | - if (dir_file_oid >= GetMinStartupOid() || |
2699 | | - dir_file_oid <= BootstrapObjectIdData) |
2700 | | - continue; |
2701 | | - |
2702 | | - tupdesc = RelationGetDescr(rel); |
2703 | | - |
2704 | | - match_found = false; |
2705 | | - scan = heap_beginscan(rel, false, SnapshotNow, 0, (ScanKey) NULL); |
2706 | | - while (HeapTupleIsValid(tuple = heap_getnext(scan, 0))) |
2707 | | - { |
2708 | | - d = heap_getattr(tuple, Anum_pg_class_relfilenode, tupdesc, &n); |
2709 | | - rel_file_oid = DatumGetObjectId(d); |
2710 | | - if (dir_file_oid == rel_file_oid) |
2711 | | - { |
2712 | | - match_found = true; |
2713 | | - break; |
2714 | | - } |
2715 | | - } |
2716 | | - heap_endscan(scan); |
2717 | | - /* make sure there was no oid wrap-around during the scan */ |
2718 | | - if (!match_found && dir_file_oid <= ShmemVariableCache->nextOid) |
2719 | | - elog(NOTICE, |
2720 | | - "Unreferenced file found in database directory:\n\t%s/%s", |
2721 | | - cwd, db_de->d_name); |
2722 | | - /* Maybe one day we can unlink too. bjm 2001-05-24 */ |
2723 | | - } |
2724 | | - } |
2725 | | - |
2726 | | - heap_close(rel, AccessShareLock); |
2727 | | - closedir(db_dir); |
2728 | | -} |
0 commit comments