~vcs-imports/mammoth-replicator/trunk

« back to all changes in this revision

Viewing changes to src/backend/storage/smgr/smgrtype.c

  • Committer: alvherre
  • Date: 2005-12-16 21:24:52 UTC
  • Revision ID: svn-v4:db760fc0-0f08-0410-9d63-cc6633f64896:trunk:1
Initial import of the REL8_0_3 sources from the Pgsql CVS repository.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*-------------------------------------------------------------------------
 
2
 *
 
3
 * smgrtype.c
 
4
 *        storage manager type
 
5
 *
 
6
 * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
 
7
 * Portions Copyright (c) 1994, Regents of the University of California
 
8
 *
 
9
 *
 
10
 * IDENTIFICATION
 
11
 *        $PostgreSQL: pgsql/src/backend/storage/smgr/smgrtype.c,v 1.26 2004-12-31 22:01:13 pgsql Exp $
 
12
 *
 
13
 *-------------------------------------------------------------------------
 
14
 */
 
15
#include "postgres.h"
 
16
 
 
17
#include "storage/smgr.h"
 
18
 
 
19
 
 
20
typedef struct smgrid
 
21
{
 
22
        const char *smgr_name;
 
23
} smgrid;
 
24
 
 
25
/*
 
26
 *      StorageManager[] -- List of defined storage managers.
 
27
 */
 
28
static const smgrid StorageManager[] = {
 
29
        {"magnetic disk"}
 
30
};
 
31
 
 
32
static const int NStorageManagers = lengthof(StorageManager);
 
33
 
 
34
 
 
35
Datum
 
36
smgrin(PG_FUNCTION_ARGS)
 
37
{
 
38
        char       *s = PG_GETARG_CSTRING(0);
 
39
        int16           i;
 
40
 
 
41
        for (i = 0; i < NStorageManagers; i++)
 
42
        {
 
43
                if (strcmp(s, StorageManager[i].smgr_name) == 0)
 
44
                        PG_RETURN_INT16(i);
 
45
        }
 
46
        elog(ERROR, "unrecognized storage manager name \"%s\"", s);
 
47
        PG_RETURN_INT16(0);
 
48
}
 
49
 
 
50
Datum
 
51
smgrout(PG_FUNCTION_ARGS)
 
52
{
 
53
        int16           i = PG_GETARG_INT16(0);
 
54
        char       *s;
 
55
 
 
56
        if (i >= NStorageManagers || i < 0)
 
57
                elog(ERROR, "invalid storage manager id: %d", i);
 
58
 
 
59
        s = pstrdup(StorageManager[i].smgr_name);
 
60
        PG_RETURN_CSTRING(s);
 
61
}
 
62
 
 
63
Datum
 
64
smgreq(PG_FUNCTION_ARGS)
 
65
{
 
66
        int16           a = PG_GETARG_INT16(0);
 
67
        int16           b = PG_GETARG_INT16(1);
 
68
 
 
69
        PG_RETURN_BOOL(a == b);
 
70
}
 
71
 
 
72
Datum
 
73
smgrne(PG_FUNCTION_ARGS)
 
74
{
 
75
        int16           a = PG_GETARG_INT16(0);
 
76
        int16           b = PG_GETARG_INT16(1);
 
77
 
 
78
        PG_RETURN_BOOL(a != b);
 
79
}