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

Commitc6b1ef8

Browse files
committed
Check for malloc failure.
1 parentddd96e1 commitc6b1ef8

File tree

3 files changed

+18
-51
lines changed

3 files changed

+18
-51
lines changed

‎src/backend/utils/cache/inval.c

Lines changed: 3 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
* Portions Copyright (c) 1994, Regents of the University of California
3535
*
3636
* IDENTIFICATION
37-
* $Header: /cvsroot/pgsql/src/backend/utils/cache/inval.c,v 1.42 2001/03/22 03:59:57 momjian Exp $
37+
* $Header: /cvsroot/pgsql/src/backend/utils/cache/inval.c,v 1.43 2001/06/01 20:23:06 tgl Exp $
3838
*
3939
* Note - this code is real crufty... badly needs a rewrite to improve
4040
* readability and portability. (Shouldn't assume Oid == Index, for example)
@@ -53,7 +53,6 @@
5353

5454
/*
5555
*private invalidation structures
56-
*
5756
*/
5857

5958
typedefstructInvalidationUserData
@@ -102,7 +101,6 @@ typedef InvalidationMessageData *InvalidationMessage;
102101

103102
/*
104103
*variables and macros
105-
*
106104
*/
107105

108106
/*
@@ -152,7 +150,6 @@ static void InvalidationMessageRegisterSharedInvalid(InvalidationMessage message
152150
/*
153151
*InvalidationEntryAllocate
154152
*Allocates an invalidation entry.
155-
*
156153
*/
157154
staticInvalidationEntry
158155
InvalidationEntryAllocate(uint16size)
@@ -161,6 +158,8 @@ InvalidationEntryAllocate(uint16 size)
161158

162159
entryDataP= (InvalidationEntryData*)
163160
malloc(sizeof(char*)+size);/* XXX alignment */
161+
if (entryDataP==NULL)
162+
elog(ERROR,"Memory exhausted in InvalidationEntryAllocate");
164163
entryDataP->nextP=NULL;
165164
return (Pointer)&entryDataP->userData;
166165
}
@@ -169,7 +168,6 @@ InvalidationEntryAllocate(uint16 size)
169168
*LocalInvalidRegister
170169
* Link an invalidation entry into a chain of them. Really ugly
171170
* coding here.
172-
*
173171
*/
174172
staticLocalInvalid
175173
LocalInvalidRegister(LocalInvalidinvalid,
@@ -187,7 +185,6 @@ LocalInvalidRegister(LocalInvalid invalid,
187185
*LocalInvalidInvalidate
188186
*Processes, then frees all entries in a local cache
189187
*invalidation list unless freemember parameter is false.
190-
*
191188
*/
192189
staticvoid
193190
LocalInvalidInvalidate(LocalInvalidinvalid,
@@ -258,7 +255,6 @@ elog(DEBUG, "CacheIdRegisterLocalRollback(%d, %d, [%d, %d])", \
258255

259256
/*
260257
*CacheIdRegisterSpecifiedLocalInvalid
261-
*
262258
*/
263259
staticLocalInvalid
264260
CacheIdRegisterSpecifiedLocalInvalid(LocalInvalidinvalid,
@@ -270,14 +266,12 @@ CacheIdRegisterSpecifiedLocalInvalid(LocalInvalid invalid,
270266

271267
/*
272268
* debugging stuff
273-
*
274269
*/
275270
CacheIdRegisterSpecifiedLocalInvalid_DEBUG1;
276271

277272
/*
278273
* create a message describing the system catalog tuple we wish to
279274
* invalidate.
280-
*
281275
*/
282276
message= (InvalidationMessage)
283277
InvalidationEntryAllocate(sizeof(InvalidationMessageData));
@@ -290,15 +284,13 @@ CacheIdRegisterSpecifiedLocalInvalid(LocalInvalid invalid,
290284

291285
/*
292286
* Add message to linked list of unprocessed messages.
293-
*
294287
*/
295288
invalid=LocalInvalidRegister(invalid, (InvalidationEntry)message);
296289
returninvalid;
297290
}
298291

299292
/*
300293
*CacheIdRegisterLocalInvalid
301-
*
302294
*/
303295
staticvoid
304296
CacheIdRegisterLocalInvalid(intcacheId,
@@ -308,28 +300,24 @@ CacheIdRegisterLocalInvalid(int cacheId,
308300

309301
/*
310302
* debugging stuff
311-
*
312303
*/
313304
CacheIdRegisterLocalInvalid_DEBUG1;
314305

315306
/*
316307
* Add message to InvalidForall linked list.
317-
*
318308
*/
319309
InvalidForall=CacheIdRegisterSpecifiedLocalInvalid(InvalidForall,
320310
cacheId,hashIndex,pointer);
321311

322312
/*
323313
* Add message to InvalidLocal linked list.
324-
*
325314
*/
326315
InvalidLocal=CacheIdRegisterSpecifiedLocalInvalid(InvalidLocal,
327316
cacheId,hashIndex,pointer);
328317
}
329318

330319
/*
331320
*CacheIdRegisterLocalRollback
332-
*
333321
*/
334322
staticvoid
335323
CacheIdRegisterLocalRollback(intcacheId,
@@ -339,21 +327,18 @@ CacheIdRegisterLocalRollback(int cacheId,
339327

340328
/*
341329
* debugging stuff
342-
*
343330
*/
344331
CacheIdRegisterLocalRollback_DEBUG1;
345332

346333
/*
347334
* Add message to RollbackStack linked list.
348-
*
349335
*/
350336
RollbackStack=CacheIdRegisterSpecifiedLocalInvalid(
351337
RollbackStack,cacheId,hashIndex,pointer);
352338
}
353339

354340
/*
355341
*RelationIdRegisterSpecifiedLocalInvalid
356-
*
357342
*/
358343
staticLocalInvalid
359344
RelationIdRegisterSpecifiedLocalInvalid(LocalInvalidinvalid,
@@ -363,7 +348,6 @@ RelationIdRegisterSpecifiedLocalInvalid(LocalInvalid invalid,
363348

364349
/*
365350
* debugging stuff
366-
*
367351
*/
368352
#ifdefINVALIDDEBUG
369353
elog(DEBUG,"RelationRegisterSpecifiedLocalInvalid(%u, %u)",relationId,
@@ -373,7 +357,6 @@ RelationIdRegisterSpecifiedLocalInvalid(LocalInvalid invalid,
373357
/*
374358
* create a message describing the relation descriptor we wish to
375359
* invalidate.
376-
*
377360
*/
378361
message= (InvalidationMessage)
379362
InvalidationEntryAllocate(sizeof(InvalidationMessageData));
@@ -384,23 +367,20 @@ RelationIdRegisterSpecifiedLocalInvalid(LocalInvalid invalid,
384367

385368
/*
386369
* Add message to linked list of unprocessed messages.
387-
*
388370
*/
389371
invalid=LocalInvalidRegister(invalid, (InvalidationEntry)message);
390372
returninvalid;
391373
}
392374

393375
/*
394376
*RelationIdRegisterLocalInvalid
395-
*
396377
*/
397378
staticvoid
398379
RelationIdRegisterLocalInvalid(OidrelationId,OidobjectId)
399380
{
400381

401382
/*
402383
* debugging stuff
403-
*
404384
*/
405385
#ifdefINVALIDDEBUG
406386
elog(DEBUG,"RelationRegisterLocalInvalid(%u, %u)",relationId,
@@ -409,30 +389,26 @@ RelationIdRegisterLocalInvalid(Oid relationId, Oid objectId)
409389

410390
/*
411391
* Add message to InvalidForall linked list.
412-
*
413392
*/
414393
InvalidForall=RelationIdRegisterSpecifiedLocalInvalid(InvalidForall,
415394
relationId,objectId);
416395

417396
/*
418397
* Add message to InvalidLocal linked list.
419-
*
420398
*/
421399
InvalidLocal=RelationIdRegisterSpecifiedLocalInvalid(InvalidLocal,
422400
relationId,objectId);
423401
}
424402

425403
/*
426404
*RelationIdRegisterLocalRollback
427-
*
428405
*/
429406
staticvoid
430407
RelationIdRegisterLocalRollback(OidrelationId,OidobjectId)
431408
{
432409

433410
/*
434411
* debugging stuff
435-
*
436412
*/
437413
#ifdefINVALIDDEBUG
438414
elog(DEBUG,"RelationRegisterLocalRollback(%u, %u)",relationId,
@@ -441,7 +417,6 @@ RelationIdRegisterLocalRollback(Oid relationId, Oid objectId)
441417

442418
/*
443419
* Add message to RollbackStack linked list.
444-
*
445420
*/
446421
RollbackStack=RelationIdRegisterSpecifiedLocalInvalid(
447422
RollbackStack,relationId,objectId);
@@ -453,7 +428,6 @@ RelationIdRegisterLocalRollback(Oid relationId, Oid objectId)
453428
*This routine can invalidate a tuple in a system catalog cache
454429
*or a cached relation descriptor. You pay your money and you
455430
*take your chances...
456-
*
457431
*/
458432
#ifdefINVALIDDEBUG
459433
#defineCacheIdInvalidate_DEBUG1 \
@@ -472,7 +446,6 @@ CacheIdInvalidate(Index cacheId,
472446
/*
473447
* assume that if the item pointer is valid, then we are invalidating
474448
* an item in the specified system catalog cache.
475-
*
476449
*/
477450
if (ItemPointerIsValid(pointer))
478451
{
@@ -485,7 +458,6 @@ CacheIdInvalidate(Index cacheId,
485458
/*
486459
* if the cacheId is the oid of any of the following system relations,
487460
* then assume we are invalidating a relation descriptor
488-
*
489461
*/
490462
if (cacheId==RelOid_pg_class)
491463
{
@@ -501,7 +473,6 @@ CacheIdInvalidate(Index cacheId,
501473

502474
/*
503475
* Yow! the caller asked us to invalidate something else.
504-
*
505476
*/
506477
elog(FATAL,"CacheIdInvalidate: cacheId=%d relation id?",cacheId);
507478
}
@@ -512,7 +483,6 @@ CacheIdInvalidate(Index cacheId,
512483
*This blows away all tuples in the system catalog caches and
513484
*all the cached relation descriptors (and closes their files too).
514485
*Relation descriptors that have positive refcounts are then rebuilt.
515-
*
516486
*/
517487
staticvoid
518488
ResetSystemCaches(void)
@@ -523,7 +493,6 @@ ResetSystemCaches(void)
523493

524494
/*
525495
*InvalidationMessageRegisterSharedInvalid
526-
*
527496
*/
528497
#ifdefINVALIDDEBUG
529498
#defineInvalidationMessageRegisterSharedInvalid_DEBUG1 \
@@ -575,7 +544,6 @@ InvalidationMessageRegisterSharedInvalid(InvalidationMessage message)
575544

576545
/*
577546
*InvalidationMessageCacheInvalidate
578-
*
579547
*/
580548
#ifdefINVALIDDEBUG
581549
#defineInvalidationMessageCacheInvalidate_DEBUG1 \
@@ -624,7 +592,6 @@ InvalidationMessageCacheInvalidate(InvalidationMessage message)
624592

625593
/*
626594
*PrepareToInvalidateRelationCache
627-
*
628595
*/
629596
staticvoid
630597
PrepareToInvalidateRelationCache(Relationrelation,
@@ -636,13 +603,11 @@ PrepareToInvalidateRelationCache(Relation relation,
636603

637604
/*
638605
* get the relation object id
639-
*
640606
*/
641607
relationId=RelationGetRelid(relation);
642608

643609
/*
644610
* is it one of the ones we need to send an SI message for?
645-
*
646611
*/
647612
if (relationId==RelOid_pg_class)
648613
objectId=tuple->t_data->t_oid;
@@ -653,7 +618,6 @@ PrepareToInvalidateRelationCache(Relation relation,
653618

654619
/*
655620
* register the relcache-invalidation action in the appropriate list
656-
*
657621
*/
658622
Assert(PointerIsValid(function));
659623

@@ -674,7 +638,6 @@ DiscardInvalid(void)
674638

675639
/*
676640
* debugging stuff
677-
*
678641
*/
679642
#ifdefINVALIDDEBUG
680643
elog(DEBUG,"DiscardInvalid called");
@@ -697,15 +660,13 @@ RegisterInvalid(bool send)
697660

698661
/*
699662
* debugging stuff
700-
*
701663
*/
702664
#ifdefINVALIDDEBUG
703665
elog(DEBUG,"RegisterInvalid(%d) called",send);
704666
#endif/* defined(INVALIDDEBUG) */
705667

706668
/*
707669
* Process and free the current list of inval messages.
708-
*
709670
*/
710671

711672
DiscardInvalidStack(&InvalidLocal);
@@ -741,15 +702,13 @@ ImmediateLocalInvalidation(bool send)
741702

742703
/*
743704
* debugging stuff
744-
*
745705
*/
746706
#ifdefINVALIDDEBUG
747707
elog(DEBUG,"ImmediateLocalInvalidation(%d) called",send);
748708
#endif/* defined(INVALIDDEBUG) */
749709

750710
/*
751711
* Process and free the local list of inval messages.
752-
*
753712
*/
754713

755714
if (send)
@@ -801,7 +760,6 @@ PrepareForTupleInvalidation(Relation relation, HeapTuple tuple,
801760

802761
/*
803762
* sanity checks
804-
*
805763
*/
806764
Assert(RelationIsValid(relation));
807765
Assert(HeapTupleIsValid(tuple));
@@ -813,14 +771,12 @@ PrepareForTupleInvalidation(Relation relation, HeapTuple tuple,
813771
* We only need to worry about invalidation for tuples that are in
814772
* system relations; user-relation tuples are never in catcaches and
815773
* can't affect the relcache either.
816-
*
817774
*/
818775
if (!IsSystemRelationName(NameStr(RelationGetForm(relation)->relname)))
819776
return;
820777

821778
/*
822779
* debugging stuff
823-
*
824780
*/
825781
PrepareForTupleInvalidation_DEBUG1;
826782

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp