Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit6f1ca7e

Browse files
committed
Fix bogus hashtable setup. (This code has quite a few other problems
too, but that one is in my way at the moment.)
1 parentc2e729f commit6f1ca7e

File tree

1 file changed

+13
-33
lines changed

1 file changed

+13
-33
lines changed

‎src/backend/utils/init/checkfiles.c

Lines changed: 13 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*-------------------------------------------------------------------------
22
*
33
*checkfiles.c
4-
*support to clean upstale relation fileson crash recovery
4+
*check forstale relation filesduring crash recovery
55
*
66
*If a backend crashes while in a transaction that has created or
77
*deleted a relfilenode, a stale file can be left over in the data
@@ -14,24 +14,24 @@
1414
*files, and use the 'dirty' flag to determine if we should run this on
1515
*a clean startup.
1616
*
17-
* $PostgreSQL: pgsql/src/backend/utils/init/checkfiles.c,v 1.1 2005/05/0218:26:53 momjian Exp $
17+
* $PostgreSQL: pgsql/src/backend/utils/init/checkfiles.c,v 1.2 2005/05/05 22:18:27 tgl Exp $
1818
*
1919
*-------------------------------------------------------------------------
2020
*/
2121
#include"postgres.h"
2222

23+
#include"access/heapam.h"
24+
#include"access/relscan.h"
25+
#include"access/skey.h"
26+
#include"catalog/catalog.h"
27+
#include"catalog/pg_tablespace.h"
28+
#include"miscadmin.h"
2329
#include"storage/fd.h"
24-
2530
#include"utils/flatfiles.h"
26-
#include"miscadmin.h"
27-
#include"catalog/pg_tablespace.h"
28-
#include"catalog/catalog.h"
29-
#include"access/skey.h"
3031
#include"utils/fmgroids.h"
31-
#include"access/relscan.h"
32-
#include"access/heapam.h"
3332
#include"utils/resowner.h"
3433

34+
3535
staticvoidCheckStaleRelFilesFrom(Oidtablespaceoid,Oiddboid);
3636
staticvoidCheckStaleRelFilesFromTablespace(Oidtablespaceoid);
3737

@@ -52,11 +52,6 @@ AllocateDirChecked(char *path)
5252
/*
5353
* Scan through all tablespaces for relations left over
5454
* by aborted transactions.
55-
*
56-
* For example, if a transaction issues
57-
* BEGIN; CREATE TABLE foobar ();
58-
* and then the backend crashes, the file is left in the
59-
* tablespace until CheckStaleRelFiles deletes it.
6055
*/
6156
void
6257
CheckStaleRelFiles(void)
@@ -125,31 +120,18 @@ CheckStaleRelFilesFrom(Oid tablespaceoid, Oid dboid)
125120
structdirent*de;
126121
HASHCTLhashctl;
127122
HTAB*relfilenodeHash;
128-
MemoryContextmcxt;
129123
RelFileNodernode;
130124
char*path;
131125

132-
/*
133-
* We create a private memory context so that we can easily deallocate the
134-
* hash table and its contents
135-
*/
136-
mcxt=AllocSetContextCreate(TopMemoryContext,"CheckStaleRelFiles",
137-
ALLOCSET_DEFAULT_MINSIZE,
138-
ALLOCSET_DEFAULT_INITSIZE,
139-
ALLOCSET_DEFAULT_MAXSIZE);
140-
141-
hashctl.hash=tag_hash;
142-
143126
/*
144127
* The entry contents is not used for anything, we just check if an oid is
145128
* in the hash table or not.
146129
*/
147130
hashctl.keysize=sizeof(Oid);
148-
hashctl.entrysize=1;
149-
hashctl.hcxt=mcxt;
131+
hashctl.entrysize=sizeof(Oid);
132+
hashctl.hash=tag_hash;
150133
relfilenodeHash=hash_create("relfilenodeHash",100,&hashctl,
151-
HASH_FUNCTION
152-
|HASH_ELEM |HASH_CONTEXT);
134+
HASH_FUNCTION |HASH_ELEM);
153135

154136
/* Read all relfilenodes from pg_class into the hash table */
155137
{
@@ -209,10 +191,9 @@ CheckStaleRelFilesFrom(Oid tablespaceoid, Oid dboid)
209191
rnode.relNode=relfilenode;
210192

211193
filepath=relpath(rnode);
212-
213194
ereport(LOG,
214195
(errcode_for_file_access(),
215-
errmsg("Thetable or index file \"%s\" is stale and canbesafely removed",
196+
errmsg("table or index file \"%s\" is stale and can safely be removed",
216197
filepath)));
217198
pfree(filepath);
218199
}
@@ -221,5 +202,4 @@ CheckStaleRelFilesFrom(Oid tablespaceoid, Oid dboid)
221202
FreeDir(dirdesc);
222203
pfree(path);
223204
hash_destroy(relfilenodeHash);
224-
MemoryContextDelete(mcxt);
225205
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp