Properly access a buffer's LSN using existing access macros instead of abusing
[PostgreSQL.git] / src / backend / storage / smgr / smgrtype.c
blobcf5b2f252d4a6a82bcc7d3fea9cbeb5b7f38c796
1 /*-------------------------------------------------------------------------
3 * smgrtype.c
4 * storage manager type
6 * Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
7 * Portions Copyright (c) 1994, Regents of the University of California
10 * IDENTIFICATION
11 * $PostgreSQL$
13 *-------------------------------------------------------------------------
15 #include "postgres.h"
17 #include "storage/smgr.h"
20 typedef struct smgrid
22 const char *smgr_name;
23 } smgrid;
26 * StorageManager[] -- List of defined storage managers.
28 static const smgrid StorageManager[] = {
29 {"magnetic disk"}
32 static const int NStorageManagers = lengthof(StorageManager);
35 Datum
36 smgrin(PG_FUNCTION_ARGS)
38 char *s = PG_GETARG_CSTRING(0);
39 int16 i;
41 for (i = 0; i < NStorageManagers; i++)
43 if (strcmp(s, StorageManager[i].smgr_name) == 0)
44 PG_RETURN_INT16(i);
46 elog(ERROR, "unrecognized storage manager name \"%s\"", s);
47 PG_RETURN_INT16(0);
50 Datum
51 smgrout(PG_FUNCTION_ARGS)
53 int16 i = PG_GETARG_INT16(0);
54 char *s;
56 if (i >= NStorageManagers || i < 0)
57 elog(ERROR, "invalid storage manager id: %d", i);
59 s = pstrdup(StorageManager[i].smgr_name);
60 PG_RETURN_CSTRING(s);
63 Datum
64 smgreq(PG_FUNCTION_ARGS)
66 int16 a = PG_GETARG_INT16(0);
67 int16 b = PG_GETARG_INT16(1);
69 PG_RETURN_BOOL(a == b);
72 Datum
73 smgrne(PG_FUNCTION_ARGS)
75 int16 a = PG_GETARG_INT16(0);
76 int16 b = PG_GETARG_INT16(1);
78 PG_RETURN_BOOL(a != b);