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
|
1997-09-08 04:41:22 +02:00
|
|
|
* $Header: /cvsroot/pgsql/src/backend/storage/smgr/smgrtype.c,v 1.4 1997/09/08 02:29: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;
|
|
|
|
} 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"},
|
|
|
|
#ifdef MAIN_MEMORY
|
|
|
|
{"main memory"}
|
1997-09-07 07:04:48 +02:00
|
|
|
#endif /* MAIN_MEMORY */
|
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)
|
|
|
|
return ((int2) i);
|
|
|
|
}
|
|
|
|
elog(WARN, "smgrin: illegal storage manager name %s", s);
|
|
|
|
return 0;
|
1996-07-09 08:22:35 +02:00
|
|
|
}
|
|
|
|
|
1997-09-08 04:41:22 +02: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)
|
|
|
|
elog(WARN, "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);
|
|
|
|
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)
|
|
|
|
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)
|
|
|
|
return (false);
|
|
|
|
return (true);
|
1996-07-09 08:22:35 +02:00
|
|
|
}
|