1996-07-09 08:22:35 +02:00
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
*
|
1999-02-14 00:22:53 +01:00
|
|
|
* smgr.c
|
1997-09-07 07:04:48 +02:00
|
|
|
* public interface routines to storage manager switch.
|
1996-07-09 08:22:35 +02:00
|
|
|
*
|
1997-09-07 07:04:48 +02:00
|
|
|
* All file system operations in POSTGRES dispatch through these
|
|
|
|
* routines.
|
1996-07-09 08:22:35 +02:00
|
|
|
*
|
|
|
|
* Copyright (c) 1994, Regents of the University of California
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* IDENTIFICATION
|
1999-11-04 09:01:09 +01:00
|
|
|
* $Header: /cvsroot/pgsql/src/backend/storage/smgr/smgr.c,v 1.30 1999/11/04 08:01:01 inoue Exp $
|
1996-07-09 08:22:35 +02:00
|
|
|
*
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
#include "postgres.h"
|
|
|
|
|
1996-11-03 06:08:01 +01:00
|
|
|
#include "storage/smgr.h"
|
1996-07-09 08:22:35 +02:00
|
|
|
|
1997-09-08 04:41:22 +02:00
|
|
|
static void smgrshutdown(int dummy);
|
1997-09-07 07:04:48 +02:00
|
|
|
|
|
|
|
typedef struct f_smgr
|
|
|
|
{
|
1997-09-08 04:41:22 +02:00
|
|
|
int (*smgr_init) ();/* may be NULL */
|
|
|
|
int (*smgr_shutdown) (); /* may be NULL */
|
|
|
|
int (*smgr_create) ();
|
|
|
|
int (*smgr_unlink) ();
|
|
|
|
int (*smgr_extend) ();
|
|
|
|
int (*smgr_open) ();
|
|
|
|
int (*smgr_close) ();
|
|
|
|
int (*smgr_read) ();
|
|
|
|
int (*smgr_write) ();
|
|
|
|
int (*smgr_flush) ();
|
|
|
|
int (*smgr_blindwrt) ();
|
|
|
|
int (*smgr_nblocks) ();
|
|
|
|
int (*smgr_truncate) ();
|
|
|
|
int (*smgr_commit) (); /* may be NULL */
|
|
|
|
int (*smgr_abort) (); /* may be NULL */
|
1997-09-08 23:56:23 +02:00
|
|
|
} f_smgr;
|
1996-07-09 08:22:35 +02:00
|
|
|
|
|
|
|
/*
|
1997-09-07 07:04:48 +02:00
|
|
|
* The weird placement of commas in this init block is to keep the compiler
|
|
|
|
* happy, regardless of what storage managers we have (or don't have).
|
1996-07-09 08:22:35 +02:00
|
|
|
*/
|
|
|
|
|
1997-09-08 04:41:22 +02:00
|
|
|
static f_smgr smgrsw[] = {
|
1996-07-09 08:22:35 +02:00
|
|
|
|
1997-09-07 07:04:48 +02:00
|
|
|
/* magnetic disk */
|
|
|
|
{mdinit, NULL, mdcreate, mdunlink, mdextend, mdopen, mdclose,
|
|
|
|
mdread, mdwrite, mdflush, mdblindwrt, mdnblocks, mdtruncate,
|
|
|
|
mdcommit, mdabort},
|
1996-07-09 08:22:35 +02:00
|
|
|
|
1998-06-23 17:35:48 +02:00
|
|
|
#ifdef STABLE_MEMORY_STORAGE
|
1997-09-07 07:04:48 +02:00
|
|
|
/* main memory */
|
|
|
|
{mminit, mmshutdown, mmcreate, mmunlink, mmextend, mmopen, mmclose,
|
|
|
|
mmread, mmwrite, mmflush, mmblindwrt, mmnblocks, NULL,
|
|
|
|
mmcommit, mmabort},
|
1996-07-09 08:22:35 +02:00
|
|
|
|
1998-06-23 17:35:48 +02:00
|
|
|
#endif
|
1996-07-09 08:22:35 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
1997-09-07 07:04:48 +02:00
|
|
|
* This array records which storage managers are write-once, and which
|
|
|
|
* support overwrite. A 'true' entry means that the storage manager is
|
|
|
|
* write-once. In the best of all possible worlds, there would be no
|
|
|
|
* write-once storage managers.
|
1996-07-09 08:22:35 +02:00
|
|
|
*/
|
|
|
|
|
1998-10-08 20:30:52 +02:00
|
|
|
#ifdef NOT_USED
|
1997-09-08 04:41:22 +02:00
|
|
|
static bool smgrwo[] = {
|
1997-09-07 07:04:48 +02:00
|
|
|
false, /* magnetic disk */
|
1998-06-23 17:35:48 +02:00
|
|
|
#ifdef STABLE_MEMORY_STORAGE
|
1997-09-07 07:04:48 +02:00
|
|
|
false, /* main memory */
|
1998-06-23 17:35:48 +02:00
|
|
|
#endif
|
1996-07-09 08:22:35 +02:00
|
|
|
};
|
1999-05-25 18:15:34 +02:00
|
|
|
|
1998-10-08 20:30:52 +02:00
|
|
|
#endif
|
|
|
|
|
1997-09-08 04:41:22 +02:00
|
|
|
static int NSmgr = lengthof(smgrsw);
|
1996-07-09 08:22:35 +02:00
|
|
|
|
|
|
|
/*
|
1997-09-07 07:04:48 +02:00
|
|
|
* smgrinit(), smgrshutdown() -- Initialize or shut down all storage
|
|
|
|
* managers.
|
1996-07-09 08:22:35 +02:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
int
|
|
|
|
smgrinit()
|
|
|
|
{
|
1997-09-08 04:41:22 +02:00
|
|
|
int i;
|
1997-09-07 07:04:48 +02:00
|
|
|
|
|
|
|
for (i = 0; i < NSmgr; i++)
|
|
|
|
{
|
|
|
|
if (smgrsw[i].smgr_init)
|
|
|
|
{
|
|
|
|
if ((*(smgrsw[i].smgr_init)) () == SM_FAIL)
|
|
|
|
elog(FATAL, "initialization failed on %s", smgrout(i));
|
|
|
|
}
|
1996-07-09 08:22:35 +02:00
|
|
|
}
|
|
|
|
|
1997-09-07 07:04:48 +02:00
|
|
|
/* register the shutdown proc */
|
1998-06-27 06:53:49 +02:00
|
|
|
on_proc_exit(smgrshutdown, NULL);
|
1996-07-09 08:22:35 +02:00
|
|
|
|
1998-09-01 05:29:17 +02:00
|
|
|
return SM_SUCCESS;
|
1996-07-09 08:22:35 +02:00
|
|
|
}
|
|
|
|
|
1997-08-19 23:40:56 +02:00
|
|
|
static void
|
1996-07-09 08:22:35 +02:00
|
|
|
smgrshutdown(int dummy)
|
|
|
|
{
|
1997-09-08 04:41:22 +02:00
|
|
|
int i;
|
1997-09-07 07:04:48 +02:00
|
|
|
|
|
|
|
for (i = 0; i < NSmgr; i++)
|
|
|
|
{
|
|
|
|
if (smgrsw[i].smgr_shutdown)
|
|
|
|
{
|
|
|
|
if ((*(smgrsw[i].smgr_shutdown)) () == SM_FAIL)
|
|
|
|
elog(FATAL, "shutdown failed on %s", smgrout(i));
|
|
|
|
}
|
1996-07-09 08:22:35 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
1997-09-07 07:04:48 +02:00
|
|
|
* smgrcreate() -- Create a new relation.
|
1996-07-09 08:22:35 +02:00
|
|
|
*
|
1997-09-07 07:04:48 +02:00
|
|
|
* This routine takes a reldesc, creates the relation on the appropriate
|
|
|
|
* device, and returns a file descriptor for it.
|
1996-07-09 08:22:35 +02:00
|
|
|
*/
|
|
|
|
int
|
|
|
|
smgrcreate(int16 which, Relation reln)
|
|
|
|
{
|
1997-09-08 04:41:22 +02:00
|
|
|
int fd;
|
1996-07-09 08:22:35 +02:00
|
|
|
|
1997-09-07 07:04:48 +02:00
|
|
|
if ((fd = (*(smgrsw[which].smgr_create)) (reln)) < 0)
|
1998-09-01 06:40:42 +02:00
|
|
|
elog(ERROR, "cannot create %s", reln->rd_rel->relname.data);
|
1996-07-09 08:22:35 +02:00
|
|
|
|
1998-09-01 05:29:17 +02:00
|
|
|
return fd;
|
1996-07-09 08:22:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
1997-09-07 07:04:48 +02:00
|
|
|
* smgrunlink() -- Unlink a relation.
|
1996-07-09 08:22:35 +02:00
|
|
|
*
|
1997-09-07 07:04:48 +02:00
|
|
|
* The relation is removed from the store.
|
1996-07-09 08:22:35 +02:00
|
|
|
*/
|
|
|
|
int
|
|
|
|
smgrunlink(int16 which, Relation reln)
|
|
|
|
{
|
1997-09-08 04:41:22 +02:00
|
|
|
int status;
|
1996-07-09 08:22:35 +02:00
|
|
|
|
1997-09-07 07:04:48 +02:00
|
|
|
if ((status = (*(smgrsw[which].smgr_unlink)) (reln)) == SM_FAIL)
|
1998-07-20 18:14:18 +02:00
|
|
|
elog(ERROR, "cannot unlink %s", reln->rd_rel->relname.data);
|
1996-07-09 08:22:35 +02:00
|
|
|
|
1998-09-01 05:29:17 +02:00
|
|
|
return status;
|
1996-07-09 08:22:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
1997-09-07 07:04:48 +02:00
|
|
|
* smgrextend() -- Add a new block to a file.
|
1996-07-09 08:22:35 +02:00
|
|
|
*
|
1997-09-07 07:04:48 +02:00
|
|
|
* Returns SM_SUCCESS on success; aborts the current transaction on
|
|
|
|
* failure.
|
1996-07-09 08:22:35 +02:00
|
|
|
*/
|
|
|
|
int
|
|
|
|
smgrextend(int16 which, Relation reln, char *buffer)
|
|
|
|
{
|
1997-09-08 04:41:22 +02:00
|
|
|
int status;
|
1996-07-09 08:22:35 +02:00
|
|
|
|
1997-09-07 07:04:48 +02:00
|
|
|
status = (*(smgrsw[which].smgr_extend)) (reln, buffer);
|
1996-07-09 08:22:35 +02:00
|
|
|
|
1997-09-07 07:04:48 +02:00
|
|
|
if (status == SM_FAIL)
|
1999-04-23 21:37:42 +02:00
|
|
|
elog(ERROR, "%s: cannot extend. Check free disk space.", reln->rd_rel->relname.data);
|
1996-07-09 08:22:35 +02:00
|
|
|
|
1998-09-01 05:29:17 +02:00
|
|
|
return status;
|
1996-07-09 08:22:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
1997-09-07 07:04:48 +02:00
|
|
|
* smgropen() -- Open a relation using a particular storage manager.
|
1996-07-09 08:22:35 +02:00
|
|
|
*
|
1997-09-07 07:04:48 +02:00
|
|
|
* Returns the fd for the open relation on success, aborts the
|
|
|
|
* transaction on failure.
|
1996-07-09 08:22:35 +02:00
|
|
|
*/
|
|
|
|
int
|
|
|
|
smgropen(int16 which, Relation reln)
|
|
|
|
{
|
1997-09-08 04:41:22 +02:00
|
|
|
int fd;
|
1996-07-09 08:22:35 +02:00
|
|
|
|
1999-11-04 09:01:09 +01:00
|
|
|
if ((fd = (*(smgrsw[which].smgr_open)) (reln)) < 0 &&
|
|
|
|
!reln->rd_unlinked)
|
1998-07-20 18:14:18 +02:00
|
|
|
elog(ERROR, "cannot open %s", reln->rd_rel->relname.data);
|
1996-07-09 08:22:35 +02:00
|
|
|
|
1998-09-01 05:29:17 +02:00
|
|
|
return fd;
|
1996-07-09 08:22:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
1997-09-07 07:04:48 +02:00
|
|
|
* smgrclose() -- Close a relation.
|
1996-07-09 08:22:35 +02:00
|
|
|
*
|
1999-09-02 04:57:50 +02:00
|
|
|
* NOTE: underlying manager should allow case where relation is
|
|
|
|
* already closed. Indeed relation may have been unlinked!
|
|
|
|
* This is currently called only from RelationFlushRelation() when
|
|
|
|
* the relation cache entry is about to be dropped; could be doing
|
|
|
|
* simple relation cache clear, or finishing up DROP TABLE.
|
|
|
|
*
|
1997-09-07 07:04:48 +02:00
|
|
|
* Returns SM_SUCCESS on success, aborts on failure.
|
1996-07-09 08:22:35 +02:00
|
|
|
*/
|
|
|
|
int
|
|
|
|
smgrclose(int16 which, Relation reln)
|
|
|
|
{
|
1997-09-07 07:04:48 +02:00
|
|
|
if ((*(smgrsw[which].smgr_close)) (reln) == SM_FAIL)
|
1998-07-20 18:14:18 +02:00
|
|
|
elog(ERROR, "cannot close %s", reln->rd_rel->relname.data);
|
1996-07-09 08:22:35 +02:00
|
|
|
|
1998-09-01 05:29:17 +02:00
|
|
|
return SM_SUCCESS;
|
1996-07-09 08:22:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
1997-09-07 07:04:48 +02:00
|
|
|
* smgrread() -- read a particular block from a relation into the supplied
|
|
|
|
* buffer.
|
1996-07-09 08:22:35 +02:00
|
|
|
*
|
1997-09-07 07:04:48 +02:00
|
|
|
* This routine is called from the buffer manager in order to
|
|
|
|
* instantiate pages in the shared buffer cache. All storage managers
|
|
|
|
* return pages in the format that POSTGRES expects. This routine
|
|
|
|
* dispatches the read. On success, it returns SM_SUCCESS. On failure,
|
|
|
|
* the current transaction is aborted.
|
1996-07-09 08:22:35 +02:00
|
|
|
*/
|
|
|
|
int
|
|
|
|
smgrread(int16 which, Relation reln, BlockNumber blocknum, char *buffer)
|
|
|
|
{
|
1997-09-08 04:41:22 +02:00
|
|
|
int status;
|
1996-07-09 08:22:35 +02:00
|
|
|
|
1997-09-07 07:04:48 +02:00
|
|
|
status = (*(smgrsw[which].smgr_read)) (reln, blocknum, buffer);
|
1996-07-09 08:22:35 +02:00
|
|
|
|
1997-09-07 07:04:48 +02:00
|
|
|
if (status == SM_FAIL)
|
1998-01-07 22:07:04 +01:00
|
|
|
elog(ERROR, "cannot read block %d of %s",
|
1998-07-20 18:14:18 +02:00
|
|
|
blocknum, reln->rd_rel->relname.data);
|
1996-07-09 08:22:35 +02:00
|
|
|
|
1998-09-01 05:29:17 +02:00
|
|
|
return status;
|
1996-07-09 08:22:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
1997-09-07 07:04:48 +02:00
|
|
|
* smgrwrite() -- Write the supplied buffer out.
|
1996-07-09 08:22:35 +02:00
|
|
|
*
|
1997-09-07 07:04:48 +02:00
|
|
|
* This is not a synchronous write -- the interface for that is
|
|
|
|
* smgrflush(). The buffer is written out via the appropriate
|
|
|
|
* storage manager. This routine returns SM_SUCCESS or aborts
|
|
|
|
* the current transaction.
|
1996-07-09 08:22:35 +02:00
|
|
|
*/
|
|
|
|
int
|
|
|
|
smgrwrite(int16 which, Relation reln, BlockNumber blocknum, char *buffer)
|
|
|
|
{
|
1997-09-08 04:41:22 +02:00
|
|
|
int status;
|
1996-07-09 08:22:35 +02:00
|
|
|
|
1997-09-07 07:04:48 +02:00
|
|
|
status = (*(smgrsw[which].smgr_write)) (reln, blocknum, buffer);
|
1996-07-09 08:22:35 +02:00
|
|
|
|
1997-09-07 07:04:48 +02:00
|
|
|
if (status == SM_FAIL)
|
1998-01-07 22:07:04 +01:00
|
|
|
elog(ERROR, "cannot write block %d of %s",
|
1998-09-01 06:40:42 +02:00
|
|
|
blocknum, reln->rd_rel->relname.data);
|
1996-07-09 08:22:35 +02:00
|
|
|
|
1998-09-01 05:29:17 +02:00
|
|
|
return status;
|
1996-07-09 08:22:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
1997-09-07 07:04:48 +02:00
|
|
|
* smgrflush() -- A synchronous smgrwrite().
|
1996-07-09 08:22:35 +02:00
|
|
|
*/
|
|
|
|
int
|
|
|
|
smgrflush(int16 which, Relation reln, BlockNumber blocknum, char *buffer)
|
|
|
|
{
|
1997-09-08 04:41:22 +02:00
|
|
|
int status;
|
1996-07-09 08:22:35 +02:00
|
|
|
|
1997-09-07 07:04:48 +02:00
|
|
|
status = (*(smgrsw[which].smgr_flush)) (reln, blocknum, buffer);
|
1996-07-09 08:22:35 +02:00
|
|
|
|
1997-09-07 07:04:48 +02:00
|
|
|
if (status == SM_FAIL)
|
1998-01-07 22:07:04 +01:00
|
|
|
elog(ERROR, "cannot flush block %d of %s to stable store",
|
1998-07-20 18:14:18 +02:00
|
|
|
blocknum, reln->rd_rel->relname.data);
|
1996-07-09 08:22:35 +02:00
|
|
|
|
1998-09-01 05:29:17 +02:00
|
|
|
return status;
|
1996-07-09 08:22:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
1997-09-07 07:04:48 +02:00
|
|
|
* smgrblindwrt() -- Write a page out blind.
|
1996-07-09 08:22:35 +02:00
|
|
|
*
|
1997-09-07 07:04:48 +02:00
|
|
|
* In some cases, we may find a page in the buffer cache that we
|
|
|
|
* can't make a reldesc for. This happens, for example, when we
|
|
|
|
* want to reuse a dirty page that was written by a transaction
|
|
|
|
* that has not yet committed, which created a new relation. In
|
|
|
|
* this case, the buffer manager will call smgrblindwrt() with
|
|
|
|
* the name and OID of the database and the relation to which the
|
|
|
|
* buffer belongs. Every storage manager must be able to force
|
|
|
|
* this page down to stable storage in this circumstance.
|
1996-07-09 08:22:35 +02:00
|
|
|
*/
|
|
|
|
int
|
|
|
|
smgrblindwrt(int16 which,
|
1997-09-07 07:04:48 +02:00
|
|
|
char *dbname,
|
|
|
|
char *relname,
|
|
|
|
Oid dbid,
|
|
|
|
Oid relid,
|
|
|
|
BlockNumber blkno,
|
|
|
|
char *buffer)
|
1996-07-09 08:22:35 +02:00
|
|
|
{
|
1997-09-08 04:41:22 +02:00
|
|
|
char *dbstr;
|
|
|
|
char *relstr;
|
|
|
|
int status;
|
1996-07-09 08:22:35 +02:00
|
|
|
|
1997-09-07 07:04:48 +02:00
|
|
|
dbstr = pstrdup(dbname);
|
|
|
|
relstr = pstrdup(relname);
|
1996-07-09 08:22:35 +02:00
|
|
|
|
1997-09-07 07:04:48 +02:00
|
|
|
status = (*(smgrsw[which].smgr_blindwrt)) (dbstr, relstr, dbid, relid,
|
|
|
|
blkno, buffer);
|
1996-07-09 08:22:35 +02:00
|
|
|
|
1997-09-07 07:04:48 +02:00
|
|
|
if (status == SM_FAIL)
|
1998-01-07 22:07:04 +01:00
|
|
|
elog(ERROR, "cannot write block %d of %s [%s] blind",
|
1997-09-07 07:04:48 +02:00
|
|
|
blkno, relstr, dbstr);
|
1996-07-09 08:22:35 +02:00
|
|
|
|
1997-09-07 07:04:48 +02:00
|
|
|
pfree(dbstr);
|
|
|
|
pfree(relstr);
|
1996-07-09 08:22:35 +02:00
|
|
|
|
1998-09-01 05:29:17 +02:00
|
|
|
return status;
|
1996-07-09 08:22:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
1997-09-07 07:04:48 +02:00
|
|
|
* smgrnblocks() -- Calculate the number of POSTGRES blocks in the
|
|
|
|
* supplied relation.
|
1996-07-09 08:22:35 +02:00
|
|
|
*
|
1997-09-07 07:04:48 +02:00
|
|
|
* Returns the number of blocks on success, aborts the current
|
|
|
|
* transaction on failure.
|
1996-07-09 08:22:35 +02:00
|
|
|
*/
|
|
|
|
int
|
|
|
|
smgrnblocks(int16 which, Relation reln)
|
|
|
|
{
|
1997-09-08 04:41:22 +02:00
|
|
|
int nblocks;
|
1996-07-09 08:22:35 +02:00
|
|
|
|
1997-09-07 07:04:48 +02:00
|
|
|
if ((nblocks = (*(smgrsw[which].smgr_nblocks)) (reln)) < 0)
|
1998-07-20 18:14:18 +02:00
|
|
|
elog(ERROR, "cannot count blocks for %s", reln->rd_rel->relname.data);
|
1996-07-09 08:22:35 +02:00
|
|
|
|
1998-09-01 05:29:17 +02:00
|
|
|
return nblocks;
|
1996-07-09 08:22:35 +02:00
|
|
|
}
|
|
|
|
|
1996-11-27 08:25:52 +01:00
|
|
|
/*
|
1997-09-07 07:04:48 +02:00
|
|
|
* smgrtruncate() -- Truncate supplied relation to a specified number
|
|
|
|
* of blocks
|
1996-11-27 08:25:52 +01:00
|
|
|
*
|
1997-09-07 07:04:48 +02:00
|
|
|
* Returns the number of blocks on success, aborts the current
|
|
|
|
* transaction on failure.
|
1996-11-27 08:25:52 +01:00
|
|
|
*/
|
|
|
|
int
|
|
|
|
smgrtruncate(int16 which, Relation reln, int nblocks)
|
|
|
|
{
|
1997-09-08 04:41:22 +02:00
|
|
|
int newblks;
|
1997-09-07 07:04:48 +02:00
|
|
|
|
|
|
|
newblks = nblocks;
|
|
|
|
if (smgrsw[which].smgr_truncate)
|
|
|
|
{
|
|
|
|
if ((newblks = (*(smgrsw[which].smgr_truncate)) (reln, nblocks)) < 0)
|
1998-01-07 22:07:04 +01:00
|
|
|
elog(ERROR, "cannot truncate %s to %d blocks",
|
1998-09-01 06:40:42 +02:00
|
|
|
reln->rd_rel->relname.data, nblocks);
|
1997-09-07 07:04:48 +02:00
|
|
|
}
|
|
|
|
|
1998-09-01 05:29:17 +02:00
|
|
|
return newblks;
|
1996-11-27 08:25:52 +01:00
|
|
|
}
|
|
|
|
|
1996-07-09 08:22:35 +02:00
|
|
|
/*
|
1997-09-07 07:04:48 +02:00
|
|
|
* smgrcommit(), smgrabort() -- Commit or abort changes made during the
|
|
|
|
* current transaction.
|
1996-07-09 08:22:35 +02:00
|
|
|
*/
|
|
|
|
int
|
|
|
|
smgrcommit()
|
|
|
|
{
|
1997-09-08 04:41:22 +02:00
|
|
|
int i;
|
1997-09-07 07:04:48 +02:00
|
|
|
|
|
|
|
for (i = 0; i < NSmgr; i++)
|
|
|
|
{
|
|
|
|
if (smgrsw[i].smgr_commit)
|
|
|
|
{
|
|
|
|
if ((*(smgrsw[i].smgr_commit)) () == SM_FAIL)
|
|
|
|
elog(FATAL, "transaction commit failed on %s", smgrout(i));
|
|
|
|
}
|
1996-07-09 08:22:35 +02:00
|
|
|
}
|
|
|
|
|
1998-09-01 05:29:17 +02:00
|
|
|
return SM_SUCCESS;
|
1996-07-09 08:22:35 +02:00
|
|
|
}
|
|
|
|
|
1997-08-19 23:40:56 +02:00
|
|
|
#ifdef NOT_USED
|
1996-07-09 08:22:35 +02:00
|
|
|
int
|
|
|
|
smgrabort()
|
|
|
|
{
|
1997-09-08 04:41:22 +02:00
|
|
|
int i;
|
1997-09-07 07:04:48 +02:00
|
|
|
|
|
|
|
for (i = 0; i < NSmgr; i++)
|
|
|
|
{
|
|
|
|
if (smgrsw[i].smgr_abort)
|
|
|
|
{
|
|
|
|
if ((*(smgrsw[i].smgr_abort)) () == SM_FAIL)
|
|
|
|
elog(FATAL, "transaction abort failed on %s", smgrout(i));
|
|
|
|
}
|
1996-07-09 08:22:35 +02:00
|
|
|
}
|
|
|
|
|
1998-09-01 05:29:17 +02:00
|
|
|
return SM_SUCCESS;
|
1996-07-09 08:22:35 +02:00
|
|
|
}
|
1997-09-07 07:04:48 +02:00
|
|
|
|
1997-08-19 23:40:56 +02:00
|
|
|
#endif
|
1996-07-09 08:22:35 +02:00
|
|
|
|
1998-10-08 20:30:52 +02:00
|
|
|
#ifdef NOT_USED
|
1996-07-09 08:22:35 +02:00
|
|
|
bool
|
|
|
|
smgriswo(int16 smgrno)
|
|
|
|
{
|
1997-09-07 07:04:48 +02:00
|
|
|
if (smgrno < 0 || smgrno >= NSmgr)
|
1998-01-07 22:07:04 +01:00
|
|
|
elog(ERROR, "illegal storage manager number %d", smgrno);
|
1996-07-09 08:22:35 +02:00
|
|
|
|
1998-09-01 05:29:17 +02:00
|
|
|
return smgrwo[smgrno];
|
1996-07-09 08:22:35 +02:00
|
|
|
}
|
1999-05-25 18:15:34 +02:00
|
|
|
|
1998-10-08 20:30:52 +02:00
|
|
|
#endif
|