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

Commit77acab7

Browse files
committed
Modify ShmemInitStruct and ShmemInitHash to throw errors internally,
rather than returning NULL for some-but-not-all failures as they used to.Remove now-redundant tests for NULL from call sites.We had to do something about this because many call sites were failing tocheck for NULL; and changing it like this seems a lot more useful andmistake-proof than adding checks to the call sites without them.
1 parent5f70a04 commit77acab7

File tree

12 files changed

+88
-113
lines changed

12 files changed

+88
-113
lines changed

‎contrib/pg_stat_statements/pg_stat_statements.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* Copyright (c) 2008-2010, PostgreSQL Global Development Group
1515
*
1616
* IDENTIFICATION
17-
* $PostgreSQL: pgsql/contrib/pg_stat_statements/pg_stat_statements.c,v 1.13 2010/02/26 02:00:32 momjian Exp $
17+
* $PostgreSQL: pgsql/contrib/pg_stat_statements/pg_stat_statements.c,v 1.14 2010/04/28 16:54:15 tgl Exp $
1818
*
1919
*-------------------------------------------------------------------------
2020
*/
@@ -321,8 +321,6 @@ pgss_shmem_startup(void)
321321
pgss=ShmemInitStruct("pg_stat_statements",
322322
sizeof(pgssSharedState),
323323
&found);
324-
if (!pgss)
325-
elog(ERROR,"out of shared memory");
326324

327325
if (!found)
328326
{
@@ -343,8 +341,6 @@ pgss_shmem_startup(void)
343341
pgss_max,pgss_max,
344342
&info,
345343
HASH_ELEM |HASH_FUNCTION |HASH_COMPARE);
346-
if (!pgss_hash)
347-
elog(ERROR,"out of shared memory");
348344

349345
LWLockRelease(AddinShmemInitLock);
350346

‎doc/src/sgml/xfunc.sgml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<!-- $PostgreSQL: pgsql/doc/src/sgml/xfunc.sgml,v 1.145 2010/04/03 07:22:56 petere Exp $ -->
1+
<!-- $PostgreSQL: pgsql/doc/src/sgml/xfunc.sgml,v 1.146 2010/04/28 16:54:15 tgl Exp $ -->
22

33
<sect1 id="xfunc">
44
<title>User-Defined Functions</title>
@@ -3350,8 +3350,6 @@ void RequestAddinLWLocks(int n)
33503350

33513351
LWLockAcquire(AddinShmemInitLock, LW_EXCLUSIVE);
33523352
ptr = ShmemInitStruct("my struct name", size, &amp;found);
3353-
if (!ptr)
3354-
elog(ERROR, "out of shared memory");
33553353
if (!found)
33563354
{
33573355
initialize contents of shmem area;

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
* Portions Copyright (c) 1996-2010, PostgreSQL Global Development Group
4242
* Portions Copyright (c) 1994, Regents of the University of California
4343
*
44-
* $PostgreSQL: pgsql/src/backend/access/transam/slru.c,v 1.49 2010/02/16 22:34:43 tgl Exp $
44+
* $PostgreSQL: pgsql/src/backend/access/transam/slru.c,v 1.50 2010/04/28 16:54:15 tgl Exp $
4545
*
4646
*-------------------------------------------------------------------------
4747
*/
@@ -164,8 +164,6 @@ SimpleLruInit(SlruCtl ctl, const char *name, int nslots, int nlsns,
164164
shared= (SlruShared)ShmemInitStruct(name,
165165
SimpleLruShmemSize(nslots,nlsns),
166166
&found);
167-
if (!shared)
168-
elog(ERROR,"out of shared memory");
169167

170168
if (!IsUnderPostmaster)
171169
{

‎src/backend/commands/async.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Portions Copyright (c) 1994, Regents of the University of California
88
*
99
* IDENTIFICATION
10-
* $PostgreSQL: pgsql/src/backend/commands/async.c,v 1.156 2010/04/05 00:42:24 tgl Exp $
10+
* $PostgreSQL: pgsql/src/backend/commands/async.c,v 1.157 2010/04/28 16:54:15 tgl Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -464,9 +464,6 @@ AsyncShmemInit(void)
464464
asyncQueueControl= (AsyncQueueControl*)
465465
ShmemInitStruct("Async Queue Control",size,&found);
466466

467-
if (!asyncQueueControl)
468-
elog(ERROR,"out of shared memory");
469-
470467
if (!found)
471468
{
472469
/* First time through, so initialize it */

‎src/backend/postmaster/autovacuum.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
*
5656
*
5757
* IDENTIFICATION
58-
* $PostgreSQL: pgsql/src/backend/postmaster/autovacuum.c,v 1.109 2010/02/26 02:00:55 momjian Exp $
58+
* $PostgreSQL: pgsql/src/backend/postmaster/autovacuum.c,v 1.110 2010/04/28 16:54:15 tgl Exp $
5959
*
6060
*-------------------------------------------------------------------------
6161
*/
@@ -2771,10 +2771,6 @@ AutoVacuumShmemInit(void)
27712771
ShmemInitStruct("AutoVacuum Data",
27722772
AutoVacuumShmemSize(),
27732773
&found);
2774-
if (AutoVacuumShmem==NULL)
2775-
ereport(FATAL,
2776-
(errcode(ERRCODE_OUT_OF_MEMORY),
2777-
errmsg("not enough shared memory for autovacuum")));
27782774

27792775
if (!IsUnderPostmaster)
27802776
{

‎src/backend/postmaster/bgwriter.c

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
*
3939
*
4040
* IDENTIFICATION
41-
* $PostgreSQL: pgsql/src/backend/postmaster/bgwriter.c,v 1.67 2010/02/05 23:37:43 momjian Exp $
41+
* $PostgreSQL: pgsql/src/backend/postmaster/bgwriter.c,v 1.68 2010/04/28 16:54:15 tgl Exp $
4242
*
4343
*-------------------------------------------------------------------------
4444
*/
@@ -890,16 +890,14 @@ BgWriterShmemInit(void)
890890
ShmemInitStruct("Background Writer Data",
891891
BgWriterShmemSize(),
892892
&found);
893-
if (BgWriterShmem==NULL)
894-
ereport(FATAL,
895-
(errcode(ERRCODE_OUT_OF_MEMORY),
896-
errmsg("not enough shared memory for background writer")));
897-
if (found)
898-
return;/* already initialized */
899-
900-
MemSet(BgWriterShmem,0,sizeof(BgWriterShmemStruct));
901-
SpinLockInit(&BgWriterShmem->ckpt_lck);
902-
BgWriterShmem->max_requests=NBuffers;
893+
894+
if (!found)
895+
{
896+
/* First time through, so initialize */
897+
MemSet(BgWriterShmem,0,sizeof(BgWriterShmemStruct));
898+
SpinLockInit(&BgWriterShmem->ckpt_lck);
899+
BgWriterShmem->max_requests=NBuffers;
900+
}
903901
}
904902

905903
/*

‎src/backend/replication/walreceiverfuncs.c

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
*
1111
*
1212
* IDENTIFICATION
13-
* $PostgreSQL: pgsql/src/backend/replication/walreceiverfuncs.c,v 1.4 2010/02/26 02:00:57 momjian Exp $
13+
* $PostgreSQL: pgsql/src/backend/replication/walreceiverfuncs.c,v 1.5 2010/04/28 16:54:15 tgl Exp $
1414
*
1515
*-------------------------------------------------------------------------
1616
*/
@@ -58,17 +58,13 @@ WalRcvShmemInit(void)
5858
WalRcv= (WalRcvData*)
5959
ShmemInitStruct("Wal Receiver Ctl",WalRcvShmemSize(),&found);
6060

61-
if (WalRcv==NULL)
62-
ereport(FATAL,
63-
(errcode(ERRCODE_OUT_OF_MEMORY),
64-
errmsg("not enough shared memory for walreceiver")));
65-
if (found)
66-
return;/* already initialized */
67-
68-
/* Initialize the data structures */
69-
MemSet(WalRcv,0,WalRcvShmemSize());
70-
WalRcv->walRcvState=WALRCV_STOPPED;
71-
SpinLockInit(&WalRcv->mutex);
61+
if (!found)
62+
{
63+
/* First time through, so initialize */
64+
MemSet(WalRcv,0,WalRcvShmemSize());
65+
WalRcv->walRcvState=WALRCV_STOPPED;
66+
SpinLockInit(&WalRcv->mutex);
67+
}
7268
}
7369

7470
/* Is walreceiver in progress (or starting up)? */

‎src/backend/replication/walsender.c

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
*
3131
*
3232
* IDENTIFICATION
33-
* $PostgreSQL: pgsql/src/backend/replication/walsender.c,v 1.18 2010/04/28 16:10:42 heikki Exp $
33+
* $PostgreSQL: pgsql/src/backend/replication/walsender.c,v 1.19 2010/04/28 16:54:15 tgl Exp $
3434
*
3535
*-------------------------------------------------------------------------
3636
*/
@@ -268,8 +268,7 @@ WalSndHandshake(void)
268268
if (wal_level==WAL_LEVEL_MINIMAL)
269269
ereport(FATAL,
270270
(errcode(ERRCODE_CANNOT_CONNECT_NOW),
271-
errmsg("standby connections not allowed because wal_level='minimal'")));
272-
271+
errmsg("standby connections not allowed because wal_level=\"minimal\"")));
273272

274273
/* Send a CopyOutResponse message, and start streaming */
275274
pq_beginmessage(&buf,'H');
@@ -838,21 +837,17 @@ WalSndShmemInit(void)
838837
WalSndCtl= (WalSndCtlData*)
839838
ShmemInitStruct("Wal Sender Ctl",WalSndShmemSize(),&found);
840839

841-
if (WalSndCtl==NULL)
842-
ereport(FATAL,
843-
(errcode(ERRCODE_OUT_OF_MEMORY),
844-
errmsg("not enough shared memory for walsender")));
845-
if (found)
846-
return;/* already initialized */
847-
848-
/* Initialize the data structures */
849-
MemSet(WalSndCtl,0,WalSndShmemSize());
850-
851-
for (i=0;i<max_wal_senders;i++)
840+
if (!found)
852841
{
853-
WalSnd*walsnd=&WalSndCtl->walsnds[i];
842+
/* First time through, so initialize */
843+
MemSet(WalSndCtl,0,WalSndShmemSize());
844+
845+
for (i=0;i<max_wal_senders;i++)
846+
{
847+
WalSnd*walsnd=&WalSndCtl->walsnds[i];
854848

855-
SpinLockInit(&walsnd->mutex);
849+
SpinLockInit(&walsnd->mutex);
850+
}
856851
}
857852
}
858853

‎src/backend/storage/buffer/buf_table.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
*
1616
*
1717
* IDENTIFICATION
18-
* $PostgreSQL: pgsql/src/backend/storage/buffer/buf_table.c,v 1.51 2010/01/02 16:57:51 momjian Exp $
18+
* $PostgreSQL: pgsql/src/backend/storage/buffer/buf_table.c,v 1.52 2010/04/28 16:54:15 tgl Exp $
1919
*
2020
*-------------------------------------------------------------------------
2121
*/
@@ -66,9 +66,6 @@ InitBufTable(int size)
6666
size,size,
6767
&info,
6868
HASH_ELEM |HASH_FUNCTION |HASH_PARTITION);
69-
70-
if (!SharedBufHash)
71-
elog(FATAL,"could not initialize shared buffer hash table");
7269
}
7370

7471
/*

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp