00001 #include "drms.h"
00002 #include "jsoc_main.h"
00003
00004 #define kSeries "series"
00005 #define kTablename "tname"
00006 #define kUndefined "undefined"
00007
00008 typedef enum
00009 {
00010 kDSErr_Success = 0,
00011 kDSErr_BadArg,
00012 kDSErr_OutOfMemory,
00013 kDSErr_BadQuery,
00014 kDSErr_CantDropShadow
00015 } DSError_t;
00016
00017 char *module_name = "dropshadow";
00018
00019
00020 ModuleArgs_t module_args[] =
00021 {
00022 {ARG_STRING, kSeries, "", "The series whose shadow table is to be dropped."},
00023 {ARG_STRING, kTablename, kUndefined, "Optional - the name of the shadow table to drop. This table was used for debugging since there is only one name that DRMS will recognize (<series name>_shadow). "},
00024 {ARG_END}
00025 };
00026
00027
00028 int DoIt(void)
00029 {
00030 DSError_t err = kDSErr_Success;
00031 int drmsstat = DRMS_SUCCESS;
00032
00033 const char *series = cmdparams_get_str(&cmdparams, kSeries, &drmsstat);
00034 const char *tname = cmdparams_get_str(&cmdparams, kTablename, &drmsstat);
00035
00036 if (drmsstat != DRMS_SUCCESS)
00037 {
00038 err = kDSErr_BadArg;
00039 }
00040 else
00041 {
00042 if (strcmp(tname, kUndefined) == 0)
00043 {
00044 tname = NULL;
00045 }
00046
00047 drmsstat = drms_series_dropshadow(drms_env, series, tname);
00048
00049 if (drmsstat != DRMS_SUCCESS)
00050 {
00051 if (drmsstat == DRMS_ERROR_OUTOFMEMORY)
00052 {
00053 err = kDSErr_OutOfMemory;
00054 }
00055 else if (drmsstat == DRMS_ERROR_BADDBQUERY)
00056 {
00057 err = kDSErr_BadQuery;
00058 }
00059 else
00060 {
00061 err = kDSErr_CantDropShadow;
00062 }
00063 }
00064 }
00065
00066 return err;
00067 }