*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/catalog/catalog.c,v 1.50 2003/11/29 19:51:42 pgsql Exp $
+ * $PostgreSQL: pgsql/src/backend/catalog/catalog.c,v 1.51 2004/01/06 18:07:31 neilc Exp $
*
*-------------------------------------------------------------------------
*/
* IsReservedName
* True iff name starts with the pg_ prefix.
*
- * For some classes of objects, the prefix pg_ is reserved
- * for system objects only.
+ * For some classes of objects, the prefix pg_ is reserved for
+ * system objects only. As of 7.3, this is now only true for
+ * schema names.
*/
bool
IsReservedName(const char *name)
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/commands/analyze.c,v 1.65 2003/11/29 19:51:47 pgsql Exp $
+ * $PostgreSQL: pgsql/src/backend/commands/analyze.c,v 1.66 2004/01/06 18:07:31 neilc Exp $
*
*-------------------------------------------------------------------------
*/
}
/*
- * Check that it's a plain table; we used to do this in getrels() but
- * seems safer to check after we've locked the relation.
+ * Check that it's a plain table; we used to do this in
+ * get_rel_oids() but seems safer to check after we've locked the
+ * relation.
*/
if (onerel->rd_rel->relkind != RELKIND_RELATION)
{
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/commands/vacuum.c,v 1.269 2003/11/29 19:51:47 pgsql Exp $
+ * $PostgreSQL: pgsql/src/backend/commands/vacuum.c,v 1.270 2004/01/06 18:07:31 neilc Exp $
*
*-------------------------------------------------------------------------
*/
/* non-export function prototypes */
-static List *getrels(const RangeVar *vacrel, const char *stmttype);
+static List *get_rel_oids(const RangeVar *vacrel, const char *stmttype);
static void vac_update_dbstats(Oid dbid,
TransactionId vacuumXID,
TransactionId frozenXID);
TransactionId initialOldestXmin = InvalidTransactionId;
TransactionId initialFreezeLimit = InvalidTransactionId;
bool all_rels;
- List *vrl,
+ List *relations,
*cur;
if (vacstmt->verbose)
all_rels = (vacstmt->relation == NULL);
/* Build list of relations to process (note this lives in vac_context) */
- vrl = getrels(vacstmt->relation, stmttype);
+ relations = get_rel_oids(vacstmt->relation, stmttype);
/*
* Formerly, there was code here to prevent more than one VACUUM from
/*
* Loop to process each selected relation.
*/
- foreach(cur, vrl)
+ foreach(cur, relations)
{
Oid relid = lfirsto(cur);
* per-relation transactions.
*/
static List *
-getrels(const RangeVar *vacrel, const char *stmttype)
+get_rel_oids(const RangeVar *vacrel, const char *stmttype)
{
- List *vrl = NIL;
+ List *oid_list = NIL;
MemoryContext oldcontext;
if (vacrel)
{
- /* Process specific relation */
+ /* Process a specific relation */
Oid relid;
relid = RangeVarGetRelid(vacrel, false);
/* Make a relation list entry for this guy */
oldcontext = MemoryContextSwitchTo(vac_context);
- vrl = lappendo(vrl, relid);
+ oid_list = lappendo(oid_list, relid);
MemoryContextSwitchTo(oldcontext);
}
else
{
/* Make a relation list entry for this guy */
oldcontext = MemoryContextSwitchTo(vac_context);
- vrl = lappendo(vrl, HeapTupleGetOid(tuple));
+ oid_list = lappendo(oid_list, HeapTupleGetOid(tuple));
MemoryContextSwitchTo(oldcontext);
}
heap_close(pgclass, AccessShareLock);
}
- return vrl;
+ return oid_list;
}
/*
}
/*
- * Check that it's a plain table; we used to do this in getrels() but
- * seems safer to check after we've locked the relation.
+ * Check that it's a plain table; we used to do this in
+ * get_rel_oids() but seems safer to check after we've locked the
+ * relation.
*/
if (onerel->rd_rel->relkind != expected_relkind)
{
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/storage/smgr/md.c,v 1.99 2003/11/29 19:51:57 pgsql Exp $
+ * $PostgreSQL: pgsql/src/backend/storage/smgr/md.c,v 1.100 2004/01/06 18:07:31 neilc Exp $
*
*-------------------------------------------------------------------------
*/
#include "utils/inval.h"
#include "utils/memutils.h"
-
-#undef DIAGNOSTIC
-
/*
- * The magnetic disk storage manager keeps track of open file descriptors
- * in its own descriptor pool. This happens for two reasons. First, at
- * transaction boundaries, we walk the list of descriptors and flush
- * anything that we've dirtied in the current transaction. Second, we want
- * to support relations larger than the OS' file size limit (often 2GBytes).
- * In order to do that, we break relations up into chunks of < 2GBytes
- * and store one chunk in each of several files that represent the relation.
- * See the BLCKSZ and RELSEG_SIZE configuration constants in include/pg_config.h.
+ * The magnetic disk storage manager keeps track of open file
+ * descriptors in its own descriptor pool. This is done to make it
+ * easier to support relations that are larger than the operating
+ * system's file size limit (often 2GBytes). In order to do that, we
+ * we break relations up into chunks of < 2GBytes and store one chunk
+ * in each of several files that represent the relation. See the
+ * BLCKSZ and RELSEG_SIZE configuration constants in
+ * include/pg_config.h.
*
* The file descriptor stored in the relation cache (see RelationGetFile())
* is actually an index into the Md_fdvec array. -1 indicates not open.
static int Md_Free = -1; /* head of freelist of unused fdvec
* entries */
static int CurFd = 0; /* first never-used fdvec index */
-static MemoryContext MdCxt; /* context for all my allocations */
+static MemoryContext MdCxt; /* context for all md.c allocations */
/* routines declared here */
static void mdclose_fd(int fd);
/*
* mdinit() -- Initialize private state for magnetic disk storage manager.
*
- * We keep a private table of all file descriptors. Whenever we do
- * a write to one, we mark it dirty in our table. Whenever we force
- * changes to disk, we mark the file descriptor clean. At transaction
- * commit, we force changes to disk for all dirty file descriptors.
- * This routine allocates and initializes the table.
+ * We keep a private table of all file descriptors. This routine
+ * allocates and initializes the table.
*
* Returns SM_SUCCESS or SM_FAIL with errno set as appropriate.
*/
#ifndef LET_OS_MANAGE_FILESIZE
seekpos = (long) (BLCKSZ * (blocknum % ((BlockNumber) RELSEG_SIZE)));
-#ifdef DIAGNOSTIC
- if (seekpos >= BLCKSZ * RELSEG_SIZE)
- elog(FATAL, "seekpos too big");
-#endif
+ Assert(seekpos < BLCKSZ * RELSEG_SIZE);
#else
seekpos = (long) (BLCKSZ * (blocknum));
#endif
/*
- * Note: because caller obtained blocknum by calling mdnblocks, which
+ * Note: because caller obtained blocknum by calling _mdnblocks, which
* did a seek(SEEK_END), this seek is often redundant and will be
* optimized away by fd.c. It's not redundant, however, if there is a
* partial page at the end of the file. In that case we want to try
}
#ifndef LET_OS_MANAGE_FILESIZE
-#ifdef DIAGNOSTIC
- if (_mdnblocks(v->mdfd_vfd, BLCKSZ) > ((BlockNumber) RELSEG_SIZE))
- elog(FATAL, "segment too big");
-#endif
+ Assert(_mdnblocks(v->mdfd_vfd, BLCKSZ) <= ((BlockNumber) RELSEG_SIZE));
#endif
return SM_SUCCESS;
Md_fdvec[vfd].mdfd_flags = (uint16) 0;
#ifndef LET_OS_MANAGE_FILESIZE
Md_fdvec[vfd].mdfd_chain = (MdfdVec *) NULL;
-
-#ifdef DIAGNOSTIC
- if (_mdnblocks(fd, BLCKSZ) > ((BlockNumber) RELSEG_SIZE))
- elog(FATAL, "segment too big");
-#endif
+ Assert(_mdnblocks(fd, BLCKSZ) <= ((BlockNumber) RELSEG_SIZE));
#endif
return vfd;
/*
* mdclose() -- Close the specified relation, if it isn't closed already.
*
- * AND FREE fd vector! It may be re-used for other relation!
+ * AND FREE fd vector! It may be re-used for other relations!
* reln should be flushed from cache after closing !..
*
* Returns SM_SUCCESS or SM_FAIL with errno set as appropriate.
#ifndef LET_OS_MANAGE_FILESIZE
seekpos = (long) (BLCKSZ * (blocknum % ((BlockNumber) RELSEG_SIZE)));
-
-#ifdef DIAGNOSTIC
- if (seekpos >= BLCKSZ * RELSEG_SIZE)
- elog(FATAL, "seekpos too big");
-#endif
+ Assert(seekpos < BLCKSZ * RELSEG_SIZE);
#else
seekpos = (long) (BLCKSZ * (blocknum));
#endif
#ifndef LET_OS_MANAGE_FILESIZE
seekpos = (long) (BLCKSZ * (blocknum % ((BlockNumber) RELSEG_SIZE)));
-#ifdef DIAGNOSTIC
- if (seekpos >= BLCKSZ * RELSEG_SIZE)
- elog(FATAL, "seekpos too big");
-#endif
+ Assert(seekpos < BLCKSZ * RELSEG_SIZE);
#else
seekpos = (long) (BLCKSZ * (blocknum));
#endif
#ifndef LET_OS_MANAGE_FILESIZE
seekpos = (long) (BLCKSZ * (blkno % ((BlockNumber) RELSEG_SIZE)));
-#ifdef DIAGNOSTIC
- if (seekpos >= BLCKSZ * RELSEG_SIZE)
- elog(FATAL, "seekpos too big");
-#endif
+ Assert(seekpos < BLCKSZ * RELSEG_SIZE);
#else
seekpos = (long) (BLCKSZ * (blkno));
#endif
/*
* mdabort() -- Abort a transaction.
- *
- * Changes need not be forced to disk at transaction abort.
*/
int
mdabort(void)
}
/*
- * _fdvec_alloc () -- grab a free (or new) md file descriptor vector.
+ * _fdvec_alloc() -- Grab a free (or new) md file descriptor vector.
*/
static int
_fdvec_alloc(void)
}
/*
- * _fdvec_free () -- free md file descriptor vector.
+ * _fdvec_free() -- free md file descriptor vector.
*
*/
static
v->mdfd_flags = (uint16) 0;
#ifndef LET_OS_MANAGE_FILESIZE
v->mdfd_chain = (MdfdVec *) NULL;
-
-#ifdef DIAGNOSTIC
- if (_mdnblocks(fd, BLCKSZ) > ((BlockNumber) RELSEG_SIZE))
- elog(FATAL, "segment too big");
-#endif
+ Assert(_mdnblocks(fd, BLCKSZ) <= ((BlockNumber) RELSEG_SIZE));
#endif
/* all done */
return v;
}
-/* Get the fd for the relation, opening it if it's not already open */
-
+/*
+ * _mdfd_getrelnfd() -- Get the (virtual) fd for the relation,
+ * opening it if it's not already open
+ *
+ */
static int
_mdfd_getrelnfd(Relation reln)
{
return fd;
}
-/* Find the segment of the relation holding the specified block */
-
+/*
+ * _mdfd_getseg() -- Find the segment of the relation holding the
+ * specified block
+ *
+ */
static MdfdVec *
_mdfd_getseg(Relation reln, BlockNumber blkno)
{
*
* The return value is the kernel descriptor, or -1 on failure.
*/
-
static int
_mdfd_blind_getseg(RelFileNode rnode, BlockNumber blkno)
{
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/storage/smgr/smgr.c,v 1.67 2003/12/12 18:45:09 petere Exp $
+ * $PostgreSQL: pgsql/src/backend/storage/smgr/smgr.c,v 1.68 2004/01/06 18:07:31 neilc Exp $
*
*-------------------------------------------------------------------------
*/
}
/*
- * smgrnblocks() -- Calculate the number of POSTGRES blocks in the
+ * smgrnblocks() -- Calculate the number of blocks in the
* supplied relation.
*
* Returns the number of blocks on success, aborts the current
}
/*
- * smgrtruncate() -- Truncate supplied relation to a specified number
- * of blocks
+ * smgrtruncate() -- Truncate supplied relation to the specified number
+ * of blocks
*
* Returns the number of blocks on success, aborts the current
* transaction on failure.
}
/*
- * smgrDoPendingDeletes() -- take care of relation deletes at end of xact.
+ * smgrDoPendingDeletes() -- Take care of relation deletes at end of xact.
*/
int
smgrDoPendingDeletes(bool isCommit)
* smgrcommit() -- Prepare to commit changes made during the current
* transaction.
*
- * This is called before we actually commit.
+ * This is called before we actually commit.
*/
int
smgrcommit(void)
}
/*
- * Sync files to disk at checkpoint time.
+ * smgrsync() -- Sync files to disk at checkpoint time.
*/
int
smgrsync(void)
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/include/utils/rel.h,v 1.71 2003/11/29 22:41:16 pgsql Exp $
+ * $PostgreSQL: pgsql/src/include/utils/rel.h,v 1.72 2004/01/06 18:07:32 neilc Exp $
*
*-------------------------------------------------------------------------
*/
typedef struct RelationData
{
- File rd_fd; /* open file descriptor, or -1 if none */
+ File rd_fd; /* open file descriptor, or -1 if
+ * none; this is NOT an operating
+ * system file descriptor */
RelFileNode rd_node; /* file node (physical identifier) */
BlockNumber rd_nblocks; /* number of blocks in rel */
BlockNumber rd_targblock; /* current insertion target block, or
/*
* RelationGetRelid
- *
- * returns the OID of the relation
+ * Returns the OID of the relation
*/
#define RelationGetRelid(relation) ((relation)->rd_id)
/*
* RelationGetFile
- *
- * Returns the open file descriptor for the rel
+ * Returns the open file descriptor for the rel, or -1 if
+ * none. This is NOT an operating system file descriptor; see md.c
+ * for more information
*/
#define RelationGetFile(relation) ((relation)->rd_fd)
/*
* RelationGetNumberOfAttributes
- *
- * Returns the number of attributes.
+ * Returns the number of attributes in a relation.
*/
#define RelationGetNumberOfAttributes(relation) ((relation)->rd_rel->relnatts)
/*
* RelationGetRelationName
- *
- * Returns the rel's name.
+ * Returns the rel's name.
*
* Note that the name is only unique within the containing namespace.
*/
/*
* RelationGetNamespace
- *
- * Returns the rel's namespace OID.
+ * Returns the rel's namespace OID.
*/
#define RelationGetNamespace(relation) \
((relation)->rd_rel->relnamespace)