1996-07-09 08:22:35 +02:00
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
*
|
|
|
|
* smgrtype.c--
|
1997-09-07 07:04:48 +02:00
|
|
|
* storage manager type
|
1996-07-09 08:22:35 +02:00
|
|
|
*
|
|
|
|
* Copyright (c) 1994, Regents of the University of California
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* IDENTIFICATION
|
1998-09-01 05:29:17 +02:00
|
|
|
* $Header: /cvsroot/pgsql/src/backend/storage/smgr/smgrtype.c,v 1.10 1998/09/01 03:25:37 momjian Exp $
|
1996-07-09 08:22:35 +02:00
|
|
|
*
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
#include <string.h>
|
|
|
|
#include "postgres.h"
|
|
|
|
|
1997-09-07 07:04:48 +02:00
|
|
|
#include "utils/builtins.h" /* where the declarations go */
|
1996-07-09 08:22:35 +02:00
|
|
|
#include "utils/palloc.h"
|
|
|
|
#include "storage/smgr.h"
|
|
|
|
|
1997-09-07 07:04:48 +02:00
|
|
|
typedef struct smgrid
|
|
|
|
{
|
1997-09-08 04:41:22 +02:00
|
|
|
char *smgr_name;
|
1997-09-08 23:56:23 +02:00
|
|
|
} smgrid;
|
1996-07-09 08:22:35 +02:00
|
|
|
|
|
|
|
/*
|
1997-09-07 07:04:48 +02:00
|
|
|
* StorageManager[] -- List of defined storage managers.
|
1996-07-09 08:22:35 +02:00
|
|
|
*
|
1997-09-07 07:04:48 +02:00
|
|
|
* The weird comma placement is to keep compilers happy no matter
|
|
|
|
* which of these is (or is not) defined.
|
1996-07-09 08:22:35 +02:00
|
|
|
*/
|
|
|
|
|
1997-09-08 04:41:22 +02:00
|
|
|
static smgrid StorageManager[] = {
|
1996-07-09 08:22:35 +02:00
|
|
|
{"magnetic disk"},
|
1998-06-23 17:35:48 +02:00
|
|
|
#ifdef STABLE_MEMORY_STORAGE
|
1996-07-09 08:22:35 +02:00
|
|
|
{"main memory"}
|
1998-06-23 17:35:48 +02:00
|
|
|
#endif
|
1996-07-09 08:22:35 +02:00
|
|
|
};
|
|
|
|
|
1997-09-08 04:41:22 +02:00
|
|
|
static int NStorageManagers = lengthof(StorageManager);
|
1996-07-09 08:22:35 +02:00
|
|
|
|
|
|
|
int2
|
|
|
|
smgrin(char *s)
|
|
|
|
{
|
1997-09-08 04:41:22 +02:00
|
|
|
int i;
|
1996-07-09 08:22:35 +02:00
|
|
|
|
1997-09-07 07:04:48 +02:00
|
|
|
for (i = 0; i < NStorageManagers; i++)
|
|
|
|
{
|
|
|
|
if (strcmp(s, StorageManager[i].smgr_name) == 0)
|
1998-09-01 05:29:17 +02:00
|
|
|
return (int2) i;
|
1997-09-07 07:04:48 +02:00
|
|
|
}
|
1998-01-07 22:07:04 +01:00
|
|
|
elog(ERROR, "smgrin: illegal storage manager name %s", s);
|
1997-09-07 07:04:48 +02:00
|
|
|
return 0;
|
1996-07-09 08:22:35 +02:00
|
|
|
}
|
|
|
|
|
1998-02-26 05:46:47 +01:00
|
|
|
char *
|
1996-07-09 08:22:35 +02:00
|
|
|
smgrout(int2 i)
|
|
|
|
{
|
1997-09-08 04:41:22 +02:00
|
|
|
char *s;
|
1996-07-09 08:22:35 +02:00
|
|
|
|
1997-09-07 07:04:48 +02:00
|
|
|
if (i >= NStorageManagers || i < 0)
|
1998-01-07 22:07:04 +01:00
|
|
|
elog(ERROR, "Illegal storage manager id %d", i);
|
1996-07-09 08:22:35 +02:00
|
|
|
|
1997-09-07 07:04:48 +02:00
|
|
|
s = (char *) palloc(strlen(StorageManager[i].smgr_name) + 1);
|
|
|
|
strcpy(s, StorageManager[i].smgr_name);
|
1998-09-01 05:29:17 +02:00
|
|
|
return s;
|
1996-07-09 08:22:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
smgreq(int2 a, int2 b)
|
|
|
|
{
|
1997-09-07 07:04:48 +02:00
|
|
|
if (a == b)
|
1998-09-01 05:29:17 +02:00
|
|
|
return true;
|
|
|
|
return false;
|
1996-07-09 08:22:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
smgrne(int2 a, int2 b)
|
|
|
|
{
|
1997-09-07 07:04:48 +02:00
|
|
|
if (a == b)
|
1998-09-01 05:29:17 +02:00
|
|
|
return false;
|
|
|
|
return true;
|
1996-07-09 08:22:35 +02:00
|
|
|
}
|