PostgreSQL Source Code  git master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
smgrtype.c File Reference
#include "postgres.h"
#include "storage/smgr.h"
#include "utils/builtins.h"
Include dependency graph for smgrtype.c:

Go to the source code of this file.

Data Structures

struct  smgrid
 

Typedefs

typedef struct smgrid smgrid
 

Functions

Datum smgrin (PG_FUNCTION_ARGS)
 
Datum smgrout (PG_FUNCTION_ARGS)
 
Datum smgreq (PG_FUNCTION_ARGS)
 
Datum smgrne (PG_FUNCTION_ARGS)
 

Variables

static const smgrid StorageManager []
 
static const int NStorageManagers = lengthof(StorageManager)
 

Typedef Documentation

Function Documentation

Datum smgreq ( PG_FUNCTION_ARGS  )

Definition at line 65 of file smgrtype.c.

References PG_GETARG_INT16, and PG_RETURN_BOOL.

66 {
67  int16 a = PG_GETARG_INT16(0);
68  int16 b = PG_GETARG_INT16(1);
69 
70  PG_RETURN_BOOL(a == b);
71 }
signed short int16
Definition: c.h:252
#define PG_RETURN_BOOL(x)
Definition: fmgr.h:303
#define PG_GETARG_INT16(n)
Definition: fmgr.h:227
Datum smgrin ( PG_FUNCTION_ARGS  )

Definition at line 37 of file smgrtype.c.

References elog, ERROR, i, NStorageManagers, PG_GETARG_CSTRING, and PG_RETURN_INT16.

38 {
39  char *s = PG_GETARG_CSTRING(0);
40  int16 i;
41 
42  for (i = 0; i < NStorageManagers; i++)
43  {
44  if (strcmp(s, StorageManager[i].smgr_name) == 0)
45  PG_RETURN_INT16(i);
46  }
47  elog(ERROR, "unrecognized storage manager name \"%s\"", s);
48  PG_RETURN_INT16(0);
49 }
signed short int16
Definition: c.h:252
#define PG_RETURN_INT16(x)
Definition: fmgr.h:300
#define ERROR
Definition: elog.h:43
static const smgrid StorageManager[]
Definition: smgrtype.c:29
int i
#define PG_GETARG_CSTRING(n)
Definition: fmgr.h:233
static const int NStorageManagers
Definition: smgrtype.c:33
#define elog
Definition: elog.h:219
Datum smgrne ( PG_FUNCTION_ARGS  )

Definition at line 74 of file smgrtype.c.

References PG_GETARG_INT16, and PG_RETURN_BOOL.

75 {
76  int16 a = PG_GETARG_INT16(0);
77  int16 b = PG_GETARG_INT16(1);
78 
79  PG_RETURN_BOOL(a != b);
80 }
signed short int16
Definition: c.h:252
#define PG_RETURN_BOOL(x)
Definition: fmgr.h:303
#define PG_GETARG_INT16(n)
Definition: fmgr.h:227
Datum smgrout ( PG_FUNCTION_ARGS  )

Definition at line 52 of file smgrtype.c.

References elog, ERROR, i, NStorageManagers, PG_GETARG_INT16, PG_RETURN_CSTRING, and pstrdup().

53 {
54  int16 i = PG_GETARG_INT16(0);
55  char *s;
56 
57  if (i >= NStorageManagers || i < 0)
58  elog(ERROR, "invalid storage manager ID: %d", i);
59 
60  s = pstrdup(StorageManager[i].smgr_name);
62 }
signed short int16
Definition: c.h:252
char * pstrdup(const char *in)
Definition: mcxt.c:1165
#define ERROR
Definition: elog.h:43
static const smgrid StorageManager[]
Definition: smgrtype.c:29
#define PG_GETARG_INT16(n)
Definition: fmgr.h:227
#define PG_RETURN_CSTRING(x)
Definition: fmgr.h:306
int i
static const int NStorageManagers
Definition: smgrtype.c:33
#define elog
Definition: elog.h:219

Variable Documentation

const int NStorageManagers = lengthof(StorageManager)
static

Definition at line 33 of file smgrtype.c.

Referenced by smgrin(), and smgrout().

const smgrid StorageManager[]
static
Initial value:
= {
{"magnetic disk"}
}

Definition at line 29 of file smgrtype.c.