00001 /*------------------------------------------------------------------------- 00002 * 00003 * smgrtype.c 00004 * storage manager type 00005 * 00006 * Portions Copyright (c) 1996-2013, PostgreSQL Global Development Group 00007 * Portions Copyright (c) 1994, Regents of the University of California 00008 * 00009 * 00010 * IDENTIFICATION 00011 * src/backend/storage/smgr/smgrtype.c 00012 * 00013 *------------------------------------------------------------------------- 00014 */ 00015 #include "postgres.h" 00016 00017 #include "storage/smgr.h" 00018 00019 00020 typedef struct smgrid 00021 { 00022 const char *smgr_name; 00023 } smgrid; 00024 00025 /* 00026 * StorageManager[] -- List of defined storage managers. 00027 */ 00028 static const smgrid StorageManager[] = { 00029 {"magnetic disk"} 00030 }; 00031 00032 static const int NStorageManagers = lengthof(StorageManager); 00033 00034 00035 Datum 00036 smgrin(PG_FUNCTION_ARGS) 00037 { 00038 char *s = PG_GETARG_CSTRING(0); 00039 int16 i; 00040 00041 for (i = 0; i < NStorageManagers; i++) 00042 { 00043 if (strcmp(s, StorageManager[i].smgr_name) == 0) 00044 PG_RETURN_INT16(i); 00045 } 00046 elog(ERROR, "unrecognized storage manager name \"%s\"", s); 00047 PG_RETURN_INT16(0); 00048 } 00049 00050 Datum 00051 smgrout(PG_FUNCTION_ARGS) 00052 { 00053 int16 i = PG_GETARG_INT16(0); 00054 char *s; 00055 00056 if (i >= NStorageManagers || i < 0) 00057 elog(ERROR, "invalid storage manager ID: %d", i); 00058 00059 s = pstrdup(StorageManager[i].smgr_name); 00060 PG_RETURN_CSTRING(s); 00061 } 00062 00063 Datum 00064 smgreq(PG_FUNCTION_ARGS) 00065 { 00066 int16 a = PG_GETARG_INT16(0); 00067 int16 b = PG_GETARG_INT16(1); 00068 00069 PG_RETURN_BOOL(a == b); 00070 } 00071 00072 Datum 00073 smgrne(PG_FUNCTION_ARGS) 00074 { 00075 int16 a = PG_GETARG_INT16(0); 00076 int16 b = PG_GETARG_INT16(1); 00077 00078 PG_RETURN_BOOL(a != b); 00079 }