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

Commit8a52b89

Browse files
committed
Further cleanup of dynahash.c API, in pursuit of portability and
readability. Bizarre '(long *) TRUE' return convention is gone,in favor of just raising an error internally in dynahash.c whenwe detect hashtable corruption. HashTableWalk is gone, in favorof using hash_seq_search directly, since it had no hope of workingwith non-LONGALIGNable datatypes. Simplify some other code that wasmade undesirably grotty by promixity to HashTableWalk.
1 parent3433180 commit8a52b89

File tree

20 files changed

+363
-564
lines changed

20 files changed

+363
-564
lines changed

‎src/backend/access/transam/xlogutils.c

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
77
* Portions Copyright (c) 1994, Regents of the University of California
88
*
9-
* $Header: /cvsroot/pgsql/src/backend/access/transam/xlogutils.c,v 1.19 2001/10/01 05:36:13 tgl Exp $
9+
* $Header: /cvsroot/pgsql/src/backend/access/transam/xlogutils.c,v 1.20 2001/10/05 17:28:11 tgl Exp $
1010
*
1111
*-------------------------------------------------------------------------
1212
*/
@@ -15,9 +15,9 @@
1515
#include"access/htup.h"
1616
#include"access/xlogutils.h"
1717
#include"catalog/pg_database.h"
18-
#include"lib/hasht.h"
1918
#include"storage/bufpage.h"
2019
#include"storage/smgr.h"
20+
#include"utils/hsearch.h"
2121
#include"utils/relcache.h"
2222

2323

@@ -233,27 +233,22 @@ _xl_init_rel_cache(void)
233233
ctl.entrysize=sizeof(XLogRelCacheEntry);
234234
ctl.hash=tag_hash;
235235

236-
_xlrelcache=hash_create(_XLOG_RELCACHESIZE,&ctl,
237-
HASH_ELEM |HASH_FUNCTION);
236+
_xlrelcache=hash_create("XLOG relcache",_XLOG_RELCACHESIZE,
237+
&ctl,HASH_ELEM |HASH_FUNCTION);
238238
}
239239

240240
staticvoid
241-
_xl_remove_hash_entry(XLogRelDesc**edata,Datumdummy)
241+
_xl_remove_hash_entry(XLogRelDesc*rdesc)
242242
{
243-
XLogRelCacheEntry*hentry;
244-
boolfound;
245-
XLogRelDesc*rdesc=*edata;
246243
Form_pg_classtpgc=rdesc->reldata.rd_rel;
244+
XLogRelCacheEntry*hentry;
247245

248246
rdesc->lessRecently->moreRecently=rdesc->moreRecently;
249247
rdesc->moreRecently->lessRecently=rdesc->lessRecently;
250248

251249
hentry= (XLogRelCacheEntry*)hash_search(_xlrelcache,
252-
(void*)&(rdesc->reldata.rd_node),HASH_REMOVE,&found);
253-
250+
(void*)&(rdesc->reldata.rd_node),HASH_REMOVE,NULL);
254251
if (hentry==NULL)
255-
elog(STOP,"_xl_remove_hash_entry: can't delete from cache");
256-
if (!found)
257252
elog(STOP,"_xl_remove_hash_entry: file was not found in cache");
258253

259254
if (rdesc->reldata.rd_fd >=0)
@@ -281,7 +276,7 @@ _xl_new_reldesc(void)
281276
/* reuse */
282277
res=_xlrelarr[0].moreRecently;
283278

284-
_xl_remove_hash_entry(&res,0);
279+
_xl_remove_hash_entry(res);
285280

286281
_xlast--;
287282
return (res);
@@ -298,13 +293,21 @@ XLogInitRelationCache(void)
298293
void
299294
XLogCloseRelationCache(void)
300295
{
296+
HASH_SEQ_STATUSstatus;
297+
XLogRelCacheEntry*hentry;
301298

302299
DestroyDummyCaches();
303300

304301
if (!_xlrelarr)
305302
return;
306303

307-
HashTableWalk(_xlrelcache, (HashtFunc)_xl_remove_hash_entry,0);
304+
hash_seq_init(&status,_xlrelcache);
305+
306+
while ((hentry= (XLogRelCacheEntry*)hash_seq_search(&status))!=NULL)
307+
{
308+
_xl_remove_hash_entry(hentry->rdesc);
309+
}
310+
308311
hash_destroy(_xlrelcache);
309312

310313
free(_xlrelarr);
@@ -321,12 +324,9 @@ XLogOpenRelation(bool redo, RmgrId rmid, RelFileNode rnode)
321324
boolfound;
322325

323326
hentry= (XLogRelCacheEntry*)
324-
hash_search(_xlrelcache, (void*)&rnode,HASH_FIND,&found);
325-
326-
if (hentry==NULL)
327-
elog(STOP,"XLogOpenRelation: error in cache");
327+
hash_search(_xlrelcache, (void*)&rnode,HASH_FIND,NULL);
328328

329-
if (found)
329+
if (hentry)
330330
{
331331
res=hentry->rdesc;
332332

@@ -348,7 +348,7 @@ XLogOpenRelation(bool redo, RmgrId rmid, RelFileNode rnode)
348348
hash_search(_xlrelcache, (void*)&rnode,HASH_ENTER,&found);
349349

350350
if (hentry==NULL)
351-
elog(STOP,"XLogOpenRelation:can't insert into cache");
351+
elog(STOP,"XLogOpenRelation:out of memory for cache");
352352

353353
if (found)
354354
elog(STOP,"XLogOpenRelation: file found on insert into cache");

‎src/backend/commands/command.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/commands/Attic/command.c,v 1.142 2001/09/07 21:57:53 momjian Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/commands/Attic/command.c,v 1.143 2001/10/05 17:28:11 tgl Exp $
1212
*
1313
* NOTES
1414
* The PerformAddAttribute() code, like most of the relation
@@ -259,7 +259,7 @@ PerformPortalClose(char *name, CommandDest dest)
259259
/*
260260
* Note: PortalCleanup is called as a side-effect
261261
*/
262-
PortalDrop(&portal);
262+
PortalDrop(portal);
263263
}
264264

265265
/* ----------------

‎src/backend/executor/spi.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/executor/spi.c,v 1.57 2001/08/02 18:08:43 tgl Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/executor/spi.c,v 1.58 2001/10/05 17:28:12 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -783,12 +783,10 @@ SPI_cursor_move(Portal portal, bool forward, int count)
783783
void
784784
SPI_cursor_close(Portalportal)
785785
{
786-
Portalmy_portal=portal;
787-
788-
if (!PortalIsValid(my_portal))
786+
if (!PortalIsValid(portal))
789787
elog(ERROR,"invalid portal in SPI cursor operation");
790788

791-
PortalDrop(&my_portal);
789+
PortalDrop(portal);
792790
}
793791

794792
/* =================== private functions =================== */

‎src/backend/lib/Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@
44
# Makefile for lib (miscellaneous stuff)
55
#
66
# IDENTIFICATION
7-
# $Header: /cvsroot/pgsql/src/backend/lib/Makefile,v 1.15 2000/08/31 16:09:59 petere Exp $
7+
# $Header: /cvsroot/pgsql/src/backend/lib/Makefile,v 1.16 2001/10/05 17:28:12 tgl Exp $
88
#
99
#-------------------------------------------------------------------------
1010

1111
subdir = src/backend/lib
1212
top_builddir = ../../..
1313
include$(top_builddir)/src/Makefile.global
1414

15-
OBJS = bit.ohasht.o lispsort.o stringinfo.o dllist.o
15+
OBJS = bit.odllist.o lispsort.o stringinfo.o
1616

1717
all: SUBSYS.o
1818

‎src/backend/lib/hasht.c

Lines changed: 0 additions & 58 deletions
This file was deleted.

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp