34
34
* Portions Copyright (c) 1994, Regents of the University of California
35
35
*
36
36
* 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 $
38
38
*
39
39
* Note - this code is real crufty... badly needs a rewrite to improve
40
40
* readability and portability. (Shouldn't assume Oid == Index, for example)
53
53
54
54
/*
55
55
* private invalidation structures
56
- *
57
56
*/
58
57
59
58
typedef struct InvalidationUserData
@@ -102,7 +101,6 @@ typedef InvalidationMessageData *InvalidationMessage;
102
101
103
102
/*
104
103
* variables and macros
105
- *
106
104
*/
107
105
108
106
/*
@@ -152,7 +150,6 @@ static void InvalidationMessageRegisterSharedInvalid(InvalidationMessage message
152
150
/*
153
151
* InvalidationEntryAllocate
154
152
* Allocates an invalidation entry.
155
- *
156
153
*/
157
154
static InvalidationEntry
158
155
InvalidationEntryAllocate (uint16 size )
@@ -161,6 +158,8 @@ InvalidationEntryAllocate(uint16 size)
161
158
162
159
entryDataP = (InvalidationEntryData * )
163
160
malloc (sizeof (char * ) + size ); /* XXX alignment */
161
+ if (entryDataP == NULL )
162
+ elog (ERROR , "Memory exhausted in InvalidationEntryAllocate" );
164
163
entryDataP -> nextP = NULL ;
165
164
return (Pointer ) & entryDataP -> userData ;
166
165
}
@@ -169,7 +168,6 @@ InvalidationEntryAllocate(uint16 size)
169
168
* LocalInvalidRegister
170
169
* Link an invalidation entry into a chain of them. Really ugly
171
170
* coding here.
172
- *
173
171
*/
174
172
static LocalInvalid
175
173
LocalInvalidRegister (LocalInvalid invalid ,
@@ -187,7 +185,6 @@ LocalInvalidRegister(LocalInvalid invalid,
187
185
* LocalInvalidInvalidate
188
186
* Processes, then frees all entries in a local cache
189
187
* invalidation list unless freemember parameter is false.
190
- *
191
188
*/
192
189
static void
193
190
LocalInvalidInvalidate (LocalInvalid invalid ,
@@ -258,7 +255,6 @@ elog(DEBUG, "CacheIdRegisterLocalRollback(%d, %d, [%d, %d])", \
258
255
259
256
/*
260
257
* CacheIdRegisterSpecifiedLocalInvalid
261
- *
262
258
*/
263
259
static LocalInvalid
264
260
CacheIdRegisterSpecifiedLocalInvalid (LocalInvalid invalid ,
@@ -270,14 +266,12 @@ CacheIdRegisterSpecifiedLocalInvalid(LocalInvalid invalid,
270
266
271
267
/*
272
268
* debugging stuff
273
- *
274
269
*/
275
270
CacheIdRegisterSpecifiedLocalInvalid_DEBUG1 ;
276
271
277
272
/*
278
273
* create a message describing the system catalog tuple we wish to
279
274
* invalidate.
280
- *
281
275
*/
282
276
message = (InvalidationMessage )
283
277
InvalidationEntryAllocate (sizeof (InvalidationMessageData ));
@@ -290,15 +284,13 @@ CacheIdRegisterSpecifiedLocalInvalid(LocalInvalid invalid,
290
284
291
285
/*
292
286
* Add message to linked list of unprocessed messages.
293
- *
294
287
*/
295
288
invalid = LocalInvalidRegister (invalid , (InvalidationEntry ) message );
296
289
return invalid ;
297
290
}
298
291
299
292
/*
300
293
* CacheIdRegisterLocalInvalid
301
- *
302
294
*/
303
295
static void
304
296
CacheIdRegisterLocalInvalid (int cacheId ,
@@ -308,28 +300,24 @@ CacheIdRegisterLocalInvalid(int cacheId,
308
300
309
301
/*
310
302
* debugging stuff
311
- *
312
303
*/
313
304
CacheIdRegisterLocalInvalid_DEBUG1 ;
314
305
315
306
/*
316
307
* Add message to InvalidForall linked list.
317
- *
318
308
*/
319
309
InvalidForall = CacheIdRegisterSpecifiedLocalInvalid (InvalidForall ,
320
310
cacheId , hashIndex , pointer );
321
311
322
312
/*
323
313
* Add message to InvalidLocal linked list.
324
- *
325
314
*/
326
315
InvalidLocal = CacheIdRegisterSpecifiedLocalInvalid (InvalidLocal ,
327
316
cacheId , hashIndex , pointer );
328
317
}
329
318
330
319
/*
331
320
* CacheIdRegisterLocalRollback
332
- *
333
321
*/
334
322
static void
335
323
CacheIdRegisterLocalRollback (int cacheId ,
@@ -339,21 +327,18 @@ CacheIdRegisterLocalRollback(int cacheId,
339
327
340
328
/*
341
329
* debugging stuff
342
- *
343
330
*/
344
331
CacheIdRegisterLocalRollback_DEBUG1 ;
345
332
346
333
/*
347
334
* Add message to RollbackStack linked list.
348
- *
349
335
*/
350
336
RollbackStack = CacheIdRegisterSpecifiedLocalInvalid (
351
337
RollbackStack , cacheId , hashIndex , pointer );
352
338
}
353
339
354
340
/*
355
341
* RelationIdRegisterSpecifiedLocalInvalid
356
- *
357
342
*/
358
343
static LocalInvalid
359
344
RelationIdRegisterSpecifiedLocalInvalid (LocalInvalid invalid ,
@@ -363,7 +348,6 @@ RelationIdRegisterSpecifiedLocalInvalid(LocalInvalid invalid,
363
348
364
349
/*
365
350
* debugging stuff
366
- *
367
351
*/
368
352
#ifdef INVALIDDEBUG
369
353
elog (DEBUG , "RelationRegisterSpecifiedLocalInvalid(%u, %u)" , relationId ,
@@ -373,7 +357,6 @@ RelationIdRegisterSpecifiedLocalInvalid(LocalInvalid invalid,
373
357
/*
374
358
* create a message describing the relation descriptor we wish to
375
359
* invalidate.
376
- *
377
360
*/
378
361
message = (InvalidationMessage )
379
362
InvalidationEntryAllocate (sizeof (InvalidationMessageData ));
@@ -384,23 +367,20 @@ RelationIdRegisterSpecifiedLocalInvalid(LocalInvalid invalid,
384
367
385
368
/*
386
369
* Add message to linked list of unprocessed messages.
387
- *
388
370
*/
389
371
invalid = LocalInvalidRegister (invalid , (InvalidationEntry ) message );
390
372
return invalid ;
391
373
}
392
374
393
375
/*
394
376
* RelationIdRegisterLocalInvalid
395
- *
396
377
*/
397
378
static void
398
379
RelationIdRegisterLocalInvalid (Oid relationId , Oid objectId )
399
380
{
400
381
401
382
/*
402
383
* debugging stuff
403
- *
404
384
*/
405
385
#ifdef INVALIDDEBUG
406
386
elog (DEBUG , "RelationRegisterLocalInvalid(%u, %u)" , relationId ,
@@ -409,30 +389,26 @@ RelationIdRegisterLocalInvalid(Oid relationId, Oid objectId)
409
389
410
390
/*
411
391
* Add message to InvalidForall linked list.
412
- *
413
392
*/
414
393
InvalidForall = RelationIdRegisterSpecifiedLocalInvalid (InvalidForall ,
415
394
relationId , objectId );
416
395
417
396
/*
418
397
* Add message to InvalidLocal linked list.
419
- *
420
398
*/
421
399
InvalidLocal = RelationIdRegisterSpecifiedLocalInvalid (InvalidLocal ,
422
400
relationId , objectId );
423
401
}
424
402
425
403
/*
426
404
* RelationIdRegisterLocalRollback
427
- *
428
405
*/
429
406
static void
430
407
RelationIdRegisterLocalRollback (Oid relationId , Oid objectId )
431
408
{
432
409
433
410
/*
434
411
* debugging stuff
435
- *
436
412
*/
437
413
#ifdef INVALIDDEBUG
438
414
elog (DEBUG , "RelationRegisterLocalRollback(%u, %u)" , relationId ,
@@ -441,7 +417,6 @@ RelationIdRegisterLocalRollback(Oid relationId, Oid objectId)
441
417
442
418
/*
443
419
* Add message to RollbackStack linked list.
444
- *
445
420
*/
446
421
RollbackStack = RelationIdRegisterSpecifiedLocalInvalid (
447
422
RollbackStack , relationId , objectId );
@@ -453,7 +428,6 @@ RelationIdRegisterLocalRollback(Oid relationId, Oid objectId)
453
428
* This routine can invalidate a tuple in a system catalog cache
454
429
* or a cached relation descriptor. You pay your money and you
455
430
* take your chances...
456
- *
457
431
*/
458
432
#ifdef INVALIDDEBUG
459
433
#define CacheIdInvalidate_DEBUG1 \
@@ -472,7 +446,6 @@ CacheIdInvalidate(Index cacheId,
472
446
/*
473
447
* assume that if the item pointer is valid, then we are invalidating
474
448
* an item in the specified system catalog cache.
475
- *
476
449
*/
477
450
if (ItemPointerIsValid (pointer ))
478
451
{
@@ -485,7 +458,6 @@ CacheIdInvalidate(Index cacheId,
485
458
/*
486
459
* if the cacheId is the oid of any of the following system relations,
487
460
* then assume we are invalidating a relation descriptor
488
- *
489
461
*/
490
462
if (cacheId == RelOid_pg_class )
491
463
{
@@ -501,7 +473,6 @@ CacheIdInvalidate(Index cacheId,
501
473
502
474
/*
503
475
* Yow! the caller asked us to invalidate something else.
504
- *
505
476
*/
506
477
elog (FATAL , "CacheIdInvalidate: cacheId=%d relation id?" , cacheId );
507
478
}
@@ -512,7 +483,6 @@ CacheIdInvalidate(Index cacheId,
512
483
* This blows away all tuples in the system catalog caches and
513
484
* all the cached relation descriptors (and closes their files too).
514
485
* Relation descriptors that have positive refcounts are then rebuilt.
515
- *
516
486
*/
517
487
static void
518
488
ResetSystemCaches (void )
@@ -523,7 +493,6 @@ ResetSystemCaches(void)
523
493
524
494
/*
525
495
* InvalidationMessageRegisterSharedInvalid
526
- *
527
496
*/
528
497
#ifdef INVALIDDEBUG
529
498
#define InvalidationMessageRegisterSharedInvalid_DEBUG1 \
@@ -575,7 +544,6 @@ InvalidationMessageRegisterSharedInvalid(InvalidationMessage message)
575
544
576
545
/*
577
546
* InvalidationMessageCacheInvalidate
578
- *
579
547
*/
580
548
#ifdef INVALIDDEBUG
581
549
#define InvalidationMessageCacheInvalidate_DEBUG1 \
@@ -624,7 +592,6 @@ InvalidationMessageCacheInvalidate(InvalidationMessage message)
624
592
625
593
/*
626
594
* PrepareToInvalidateRelationCache
627
- *
628
595
*/
629
596
static void
630
597
PrepareToInvalidateRelationCache (Relation relation ,
@@ -636,13 +603,11 @@ PrepareToInvalidateRelationCache(Relation relation,
636
603
637
604
/*
638
605
* get the relation object id
639
- *
640
606
*/
641
607
relationId = RelationGetRelid (relation );
642
608
643
609
/*
644
610
* is it one of the ones we need to send an SI message for?
645
- *
646
611
*/
647
612
if (relationId == RelOid_pg_class )
648
613
objectId = tuple -> t_data -> t_oid ;
@@ -653,7 +618,6 @@ PrepareToInvalidateRelationCache(Relation relation,
653
618
654
619
/*
655
620
* register the relcache-invalidation action in the appropriate list
656
- *
657
621
*/
658
622
Assert (PointerIsValid (function ));
659
623
@@ -674,7 +638,6 @@ DiscardInvalid(void)
674
638
675
639
/*
676
640
* debugging stuff
677
- *
678
641
*/
679
642
#ifdef INVALIDDEBUG
680
643
elog (DEBUG , "DiscardInvalid called" );
@@ -697,15 +660,13 @@ RegisterInvalid(bool send)
697
660
698
661
/*
699
662
* debugging stuff
700
- *
701
663
*/
702
664
#ifdef INVALIDDEBUG
703
665
elog (DEBUG , "RegisterInvalid(%d) called" , send );
704
666
#endif /* defined(INVALIDDEBUG) */
705
667
706
668
/*
707
669
* Process and free the current list of inval messages.
708
- *
709
670
*/
710
671
711
672
DiscardInvalidStack (& InvalidLocal );
@@ -741,15 +702,13 @@ ImmediateLocalInvalidation(bool send)
741
702
742
703
/*
743
704
* debugging stuff
744
- *
745
705
*/
746
706
#ifdef INVALIDDEBUG
747
707
elog (DEBUG , "ImmediateLocalInvalidation(%d) called" , send );
748
708
#endif /* defined(INVALIDDEBUG) */
749
709
750
710
/*
751
711
* Process and free the local list of inval messages.
752
- *
753
712
*/
754
713
755
714
if (send )
@@ -801,7 +760,6 @@ PrepareForTupleInvalidation(Relation relation, HeapTuple tuple,
801
760
802
761
/*
803
762
* sanity checks
804
- *
805
763
*/
806
764
Assert (RelationIsValid (relation ));
807
765
Assert (HeapTupleIsValid (tuple ));
@@ -813,14 +771,12 @@ PrepareForTupleInvalidation(Relation relation, HeapTuple tuple,
813
771
* We only need to worry about invalidation for tuples that are in
814
772
* system relations; user-relation tuples are never in catcaches and
815
773
* can't affect the relcache either.
816
- *
817
774
*/
818
775
if (!IsSystemRelationName (NameStr (RelationGetForm (relation )-> relname )))
819
776
return ;
820
777
821
778
/*
822
779
* debugging stuff
823
- *
824
780
*/
825
781
PrepareForTupleInvalidation_DEBUG1 ;
826
782
0 commit comments