1
0
mirror of https://github.com/postgres/postgres.git synced 2025-11-07 19:06:32 +03:00

Fix problems seen in parallel regress tests when SI buffer overruns (causing

syscache and relcache flushes).  Relcache entry rebuild now preserves
original tupledesc, rewrite rules, and triggers if possible, so that pointers
to these things remain valid --- if these things change while relcache entry
has positive refcount, we elog(ERROR) to avoid later crash.  Arrange for
xact-local rels to be rebuilt when an SI inval message is seen for them,
so that they are updated by CommandCounterIncrement the same as regular rels.
(This is useful because of Hiroshi's recent changes to process our own SI
messages at CommandCounterIncrement time.)  This allows simplification of
some routines that previously hacked around the lack of an automatic update.
catcache now keeps its own copy of tupledesc for its relation, rather than
depending on the relcache's copy; this avoids needing to reinitialize catcache
during a cache flush, which saves some cycles and eliminates nasty circularity
problems that occur if a cache flush happens while trying to initialize a
catcache.
Eliminate a number of permanent memory leaks that used to happen during
catcache or relcache flush; not least of which was that catcache never
freed any cached tuples!  (Rule parsetree storage is still leaked, however;
will fix that separately.)
Nothing done yet about code that uses tuples retrieved by SearchSysCache
for longer than is safe.
This commit is contained in:
Tom Lane
2000-01-31 04:35:57 +00:00
parent ca0f1435ec
commit a152ebeec6
15 changed files with 591 additions and 402 deletions

View File

@@ -1,13 +1,13 @@
/*-------------------------------------------------------------------------
*
* rel.h
* POSTGRES relation descriptor definitions.
* POSTGRES relation descriptor (a/k/a relcache entry) definitions.
*
*
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
* Portions Copyright (c) 1994, Regents of the University of California
*
* $Id: rel.h,v 1.33 2000/01/26 05:58:38 momjian Exp $
* $Id: rel.h,v 1.34 2000/01/31 04:35:57 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -21,6 +21,9 @@
#include "rewrite/prs2lock.h"
#include "storage/fd.h"
/* added to prevent circular dependency. bjm 1999/11/15 */
extern char *get_temp_rel_by_physicalname(const char *relname);
/*
* LockRelId and LockInfo really belong to lmgr.h, but it's more convenient
* to declare them here so we can have a LockInfoData field in a Relation.
@@ -39,6 +42,10 @@ typedef struct LockInfoData
typedef LockInfoData *LockInfo;
/*
* Likewise, this struct really belongs to trigger.h, but for convenience
* we put it here.
*/
typedef struct Trigger
{
@@ -58,6 +65,7 @@ typedef struct Trigger
typedef struct TriggerDesc
{
/* index data to identify which triggers are which */
uint16 n_before_statement[4];
uint16 n_before_row[4];
uint16 n_after_row[4];
@@ -66,9 +74,14 @@ typedef struct TriggerDesc
Trigger **tg_before_row[4];
Trigger **tg_after_row[4];
Trigger **tg_after_statement[4];
/* the actual array of triggers is here */
Trigger *triggers;
int numtriggers;
} TriggerDesc;
/*
* Here are the contents of a relation cache entry.
*/
typedef struct RelationData
{
@@ -87,7 +100,7 @@ typedef struct RelationData
RuleLock *rd_rules; /* rewrite rules */
IndexStrategy rd_istrat;
RegProcedure *rd_support;
TriggerDesc *trigdesc;
TriggerDesc *trigdesc; /* Trigger info, or NULL if rel has none */
} RelationData;
typedef RelationData *Relation;
@@ -110,15 +123,6 @@ typedef Relation *RelationPtr;
#define InvalidRelation ((Relation) NULL)
/*
* RelationGetSystemPort
* Returns system port of a relation.
*
* Note:
* Assumes relation descriptor is valid.
*/
#define RelationGetSystemPort(relation) ((relation)->rd_fd)
/*
* RelationHasReferenceCountZero
* True iff relation reference count is zero.
@@ -149,7 +153,7 @@ typedef Relation *RelationPtr;
/*
* RelationGetForm
* Returns relation attribute values for a relation.
* Returns pg_class tuple for a relation.
*
* Note:
* Assumes relation descriptor is valid.
@@ -159,15 +163,14 @@ typedef Relation *RelationPtr;
/*
* RelationGetRelid
*
* returns the object id of the relation
*
* returns the OID of the relation
*/
#define RelationGetRelid(relation) ((relation)->rd_id)
/*
* RelationGetFile
*
* Returns the open File decscriptor
* Returns the open file descriptor for the rel
*/
#define RelationGetFile(relation) ((relation)->rd_fd)
@@ -176,8 +179,6 @@ typedef Relation *RelationPtr;
*
* Returns a Relation Name
*/
/* added to prevent circular dependency. bjm 1999/11/15 */
char *get_temp_rel_by_physicalname(const char *relname);
#define RelationGetRelationName(relation) \
(\
(strncmp(RelationGetPhysicalRelationName(relation), \
@@ -210,10 +211,19 @@ char *get_temp_rel_by_physicalname(const char *relname);
*/
#define RelationGetDescr(relation) ((relation)->rd_att)
/*
* RelationGetIndexStrategy
* Returns index strategy for a relation.
*
* Note:
* Assumes relation descriptor is valid.
* Assumes relation descriptor is for an index relation.
*/
#define RelationGetIndexStrategy(relation) ((relation)->rd_istrat)
extern IndexStrategy RelationGetIndexStrategy(Relation relation);
extern void RelationSetIndexSupport(Relation relation, IndexStrategy strategy,
RegProcedure *support);
extern void RelationSetIndexSupport(Relation relation,
IndexStrategy strategy,
RegProcedure *support);
#endif /* REL_H */