1996-07-09 08:22:35 +02:00
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
*
|
1999-02-14 00:22:53 +01:00
|
|
|
* smgrtype.c
|
1997-09-07 07:04:48 +02:00
|
|
|
* storage manager type
|
1996-07-09 08:22:35 +02:00
|
|
|
*
|
2004-12-31 23:04:05 +01:00
|
|
|
* Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
|
2000-01-26 06:58:53 +01:00
|
|
|
* Portions Copyright (c) 1994, Regents of the University of California
|
1996-07-09 08:22:35 +02:00
|
|
|
*
|
|
|
|
*
|
|
|
|
* IDENTIFICATION
|
2004-12-31 23:04:05 +01:00
|
|
|
* $PostgreSQL: pgsql/src/backend/storage/smgr/smgrtype.c,v 1.26 2004/12/31 22:01:13 pgsql Exp $
|
1996-07-09 08:22:35 +02:00
|
|
|
*
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
#include "postgres.h"
|
|
|
|
|
|
|
|
#include "storage/smgr.h"
|
|
|
|
|
2004-02-10 02:55:27 +01:00
|
|
|
|
1997-09-07 07:04:48 +02:00
|
|
|
typedef struct smgrid
|
|
|
|
{
|
2004-08-29 07:07:03 +02:00
|
|
|
const 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
|
|
|
*/
|
2004-02-10 02:55:27 +01:00
|
|
|
static const smgrid StorageManager[] = {
|
|
|
|
{"magnetic disk"}
|
1996-07-09 08:22:35 +02:00
|
|
|
};
|
|
|
|
|
2004-08-29 07:07:03 +02:00
|
|
|
static const int NStorageManagers = lengthof(StorageManager);
|
2004-02-10 02:55:27 +01:00
|
|
|
|
1996-07-09 08:22:35 +02:00
|
|
|
|
2000-06-05 09:29:25 +02:00
|
|
|
Datum
|
|
|
|
smgrin(PG_FUNCTION_ARGS)
|
1996-07-09 08:22:35 +02:00
|
|
|
{
|
2000-06-05 09:29:25 +02:00
|
|
|
char *s = PG_GETARG_CSTRING(0);
|
|
|
|
int16 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)
|
2000-06-05 09:29:25 +02:00
|
|
|
PG_RETURN_INT16(i);
|
1997-09-07 07:04:48 +02:00
|
|
|
}
|
2003-07-25 00:04:15 +02:00
|
|
|
elog(ERROR, "unrecognized storage manager name \"%s\"", s);
|
2000-06-05 09:29:25 +02:00
|
|
|
PG_RETURN_INT16(0);
|
1996-07-09 08:22:35 +02:00
|
|
|
}
|
|
|
|
|
2000-06-05 09:29:25 +02:00
|
|
|
Datum
|
|
|
|
smgrout(PG_FUNCTION_ARGS)
|
1996-07-09 08:22:35 +02:00
|
|
|
{
|
2000-06-05 09:29:25 +02:00
|
|
|
int16 i = PG_GETARG_INT16(0);
|
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)
|
2003-07-25 00:04:15 +02:00
|
|
|
elog(ERROR, "invalid storage manager id: %d", i);
|
1996-07-09 08:22:35 +02:00
|
|
|
|
2000-06-05 09:29:25 +02:00
|
|
|
s = pstrdup(StorageManager[i].smgr_name);
|
|
|
|
PG_RETURN_CSTRING(s);
|
1996-07-09 08:22:35 +02:00
|
|
|
}
|
|
|
|
|
2000-06-05 09:29:25 +02:00
|
|
|
Datum
|
|
|
|
smgreq(PG_FUNCTION_ARGS)
|
1996-07-09 08:22:35 +02:00
|
|
|
{
|
2000-06-05 09:29:25 +02:00
|
|
|
int16 a = PG_GETARG_INT16(0);
|
|
|
|
int16 b = PG_GETARG_INT16(1);
|
|
|
|
|
|
|
|
PG_RETURN_BOOL(a == b);
|
1996-07-09 08:22:35 +02:00
|
|
|
}
|
|
|
|
|
2000-06-05 09:29:25 +02:00
|
|
|
Datum
|
|
|
|
smgrne(PG_FUNCTION_ARGS)
|
1996-07-09 08:22:35 +02:00
|
|
|
{
|
2000-06-05 09:29:25 +02:00
|
|
|
int16 a = PG_GETARG_INT16(0);
|
|
|
|
int16 b = PG_GETARG_INT16(1);
|
|
|
|
|
|
|
|
PG_RETURN_BOOL(a != b);
|
1996-07-09 08:22:35 +02:00
|
|
|
}
|