MIDAS
Loading...
Searching...
No Matches
SqlHistoryBase Class Referenceabstract
Inheritance diagram for SqlHistoryBase:
Collaboration diagram for SqlHistoryBase:

Public Member Functions

 SqlHistoryBase ()
 
virtual ~SqlHistoryBase ()
 
int hs_set_debug (int debug)
 set debug level, returns previous debug level
 
int hs_connect (const char *connect_string)
 returns HS_SUCCESS
 
int hs_disconnect ()
 disconnect from history, returns HS_SUCCESS
 
HsSchemanew_event (const char *event_name, time_t timestamp, int ntags, const TAG tags[])
 
int read_schema (HsSchemaVector *sv, const char *event_name, const time_t timestamp)
 
HsSchemamaybe_reopen (const char *event_name, time_t timestamp, HsSchema *s)
 
- Public Member Functions inherited from SchemaHistoryBase
 SchemaHistoryBase ()
 
virtual ~SchemaHistoryBase ()
 
int hs_define_event (const char *event_name, time_t timestamp, int ntags, const TAG tags[])
 see hs_define_event(), returns HS_SUCCESS or HS_FILE_ERROR
 
int hs_write_event (const char *event_name, time_t timestamp, int buffer_size, const char *buffer)
 see hs_write_event(), returns HS_SUCCESS or HS_FILE_ERROR
 
int hs_flush_buffers ()
 flush buffered data to storage where it is visible to mhttpd
 
int hs_clear_cache ()
 clear internal cache, returns HS_SUCCESS
 
int hs_get_events (time_t t, std::vector< std::string > *pevents)
 get list of events that exist(ed) at given time and later (value 0 means "return all events from beginning of time"), returns HS_SUCCESS
 
int hs_get_tags (const char *event_name, time_t t, std::vector< TAG > *ptags)
 get list of history variables for given event (use event names returned by hs_get_events()) that exist(ed) at given time and later (value 0 means "all variables for this event that ever existed"), also see hs_get_tags(), returns HS_SUCCESS
 
int hs_get_last_written (time_t timestamp, int num_var, const char *const event_name[], const char *const var_name[], const int var_index[], time_t last_written[])
 
int hs_read_buffer (time_t start_time, time_t end_time, int num_var, const char *const event_name[], const char *const var_name[], const int var_index[], MidasHistoryBufferInterface *buffer[], int hs_status[])
 returns HS_SUCCESS
 
int hs_read (time_t start_time, time_t end_time, time_t interval, int num_var, const char *const event_name[], const char *const var_name[], const int var_index[], int num_entries[], time_t *time_buffer[], double *data_buffer[], int st[])
 see hs_read(), returns HS_SUCCESS
 
int hs_read_binned (time_t start_time, time_t end_time, int num_bins, int num_var, const char *const event_name[], const char *const var_name[], const int var_index[], int num_entries[], int *count_bins[], double *mean_bins[], double *rms_bins[], double *min_bins[], double *max_bins[], time_t *bins_first_time[], double *bins_first_value[], time_t *bins_last_time[], double *bins_last_value[], time_t last_time[], double last_value[], int st[])
 returns HS_SUCCESS
 
- Public Member Functions inherited from MidasHistoryInterface
 MidasHistoryInterface ()
 history type: MIDAS, ODBC, SQLITE, etc
 
virtual ~MidasHistoryInterface ()
 

Public Attributes

SqlBasefSql
 
- Public Attributes inherited from MidasHistoryInterface
char name [NAME_LENGTH]
 
char type [NAME_LENGTH]
 history channel name
 

Protected Member Functions

virtual int read_table_and_event_names (HsSchemaVector *sv)=0
 
virtual int read_column_names (HsSchemaVector *sv, const char *table_name, const char *event_name)=0
 
virtual int create_table (HsSchemaVector *sv, const char *event_name, time_t timestamp)=0
 
virtual int update_column (const char *event_name, const char *table_name, const char *column_name, const char *column_type, const char *tag_name, const char *tag_type, const time_t timestamp, bool active, bool *have_transaction)=0
 
int update_schema (HsSqlSchema *s, const time_t timestamp, const int ntags, const TAG tags[], bool write_enable)
 
int update_schema1 (HsSqlSchema *s, const time_t timestamp, const int ntags, const TAG tags[], bool write_enable, bool *have_transaction)
 

Additional Inherited Members

- Protected Attributes inherited from SchemaHistoryBase
int fDebug = 0
 
std::string fConnectString
 
HsSchemaVector fWriterSchema
 
std::vector< HsSchema * > fWriterEvents
 
HsSchemaVector fReaderSchema
 

Detailed Description

Definition at line 4801 of file history_schema.cxx.

Constructor & Destructor Documentation

◆ SqlHistoryBase()

SqlHistoryBase::SqlHistoryBase ( )
inline

Definition at line 4806 of file history_schema.cxx.

4807 {
4808 fSql = NULL;
4810 }
int hs_clear_cache()
clear internal cache, returns HS_SUCCESS
Here is the call graph for this function:

◆ ~SqlHistoryBase()

virtual SqlHistoryBase::~SqlHistoryBase ( )
inlinevirtual

Definition at line 4812 of file history_schema.cxx.

4813 {
4814 hs_disconnect();
4815 if (fSql)
4816 delete fSql;
4817 fSql = NULL;
4818 }
int hs_disconnect()
disconnect from history, returns HS_SUCCESS
Here is the call graph for this function:

Member Function Documentation

◆ create_table()

virtual int SqlHistoryBase::create_table ( HsSchemaVector sv,
const char *  event_name,
time_t  timestamp 
)
protectedpure virtual

Implemented in SqliteHistory, and MysqlHistory.

Here is the caller graph for this function:

◆ hs_connect()

int SqlHistoryBase::hs_connect ( const char *  connect_string)
virtual

returns HS_SUCCESS

Implements SchemaHistoryBase.

Definition at line 4844 of file history_schema.cxx.

4845{
4846 if (fDebug)
4847 printf("hs_connect [%s]!\n", connect_string);
4848
4849 assert(fSql);
4850
4851 if (fSql->IsConnected())
4852 if (strcmp(fConnectString.c_str(), connect_string) == 0)
4853 return HS_SUCCESS;
4854
4855 hs_disconnect();
4856
4857 if (!connect_string || strlen(connect_string) < 1) {
4858 // FIXME: should use "logger dir" or some such default, that code should be in hs_get_history(), not here
4859 connect_string = ".";
4860 }
4861
4862 fConnectString = connect_string;
4863
4864 if (fDebug)
4865 printf("hs_connect: connecting to SQL database \'%s\'\n", fConnectString.c_str());
4866
4867 int status = fSql->Connect(fConnectString.c_str());
4868 if (status != DB_SUCCESS)
4869 return status;
4870
4871 return HS_SUCCESS;
4872}
virtual bool IsConnected()=0
virtual int Connect(const char *dsn=0)=0
#define DB_SUCCESS
Definition midas.h:632
#define HS_SUCCESS
Definition midas.h:728
DWORD status
Definition odbhist.cxx:39
Here is the call graph for this function:

◆ hs_disconnect()

int SqlHistoryBase::hs_disconnect ( )
virtual

disconnect from history, returns HS_SUCCESS

Implements SchemaHistoryBase.

Definition at line 4874 of file history_schema.cxx.

4875{
4876 if (fDebug)
4877 printf("hs_disconnect!\n");
4878
4880
4881 fSql->Disconnect();
4882
4884
4885 return HS_SUCCESS;
4886}
int hs_flush_buffers()
flush buffered data to storage where it is visible to mhttpd
virtual int Disconnect()=0
Here is the call graph for this function:
Here is the caller graph for this function:

◆ hs_set_debug()

int SqlHistoryBase::hs_set_debug ( int  debug)
inlinevirtual

set debug level, returns previous debug level

Reimplemented from SchemaHistoryBase.

Definition at line 4820 of file history_schema.cxx.

4821 {
4822 if (fSql)
4823 fSql->fDebug = debug;
4825 }
virtual int hs_set_debug(int debug)
set debug level, returns previous debug level
BOOL debug
debug printouts
Definition mana.cxx:254
Here is the call graph for this function:

◆ maybe_reopen()

HsSchema * SqlHistoryBase::maybe_reopen ( const char *  event_name,
time_t  timestamp,
HsSchema s 
)
inlinevirtual

Implements SchemaHistoryBase.

Definition at line 4831 of file history_schema.cxx.

4831{ return s; };

◆ new_event()

HsSchema * SqlHistoryBase::new_event ( const char *  event_name,
time_t  timestamp,
int  ntags,
const TAG  tags[] 
)
virtual

Implements SchemaHistoryBase.

Definition at line 4888 of file history_schema.cxx.

4889{
4890 if (fDebug)
4891 printf("SqlHistory::new_event: event [%s], timestamp %s, ntags %d\n", event_name, TimeToString(timestamp).c_str(), ntags);
4892
4893 int status;
4894
4895 if (fWriterSchema.size() == 0) {
4897 if (status != HS_SUCCESS)
4898 return NULL;
4899 }
4900
4901 HsSqlSchema* s = (HsSqlSchema*)fWriterSchema.find_event(event_name, timestamp);
4902
4903 // schema does not exist, the SQL tables probably do not exist yet
4904
4905 if (!s) {
4906 status = create_table(&fWriterSchema, event_name, timestamp);
4907 if (status != HS_SUCCESS)
4908 return NULL;
4909
4910 s = (HsSqlSchema*)fWriterSchema.find_event(event_name, timestamp);
4911
4912 if (!s) {
4913 cm_msg(MERROR, "SqlHistory::new_event", "Error: Cannot create schema for event \'%s\', see previous messages", event_name);
4914 fWriterSchema.find_event(event_name, timestamp, 1);
4915 return NULL;
4916 }
4917 }
4918
4919 assert(s != NULL);
4920
4921 status = read_column_names(&fWriterSchema, s->fTableName.c_str(), s->fEventName.c_str());
4922 if (status != HS_SUCCESS)
4923 return NULL;
4924
4925 s = (HsSqlSchema*)fWriterSchema.find_event(event_name, timestamp);
4926
4927 if (!s) {
4928 cm_msg(MERROR, "SqlHistory::new_event", "Error: Cannot update schema database for event \'%s\', see previous messages", event_name);
4929 return NULL;
4930 }
4931
4932 if (0||fDebug) {
4933 printf("SqlHistory::new_event: schema for [%s] is %p\n", event_name, s);
4934 if (s)
4935 s->print();
4936 }
4937
4938 status = update_schema(s, timestamp, ntags, tags, true);
4939 if (status != HS_SUCCESS) {
4940 cm_msg(MERROR, "SqlHistory::new_event", "Error: Cannot create schema for event \'%s\', see previous messages", event_name);
4941 return NULL;
4942 }
4943
4944 status = read_column_names(&fWriterSchema, s->fTableName.c_str(), s->fEventName.c_str());
4945 if (status != HS_SUCCESS)
4946 return NULL;
4947
4948 s = (HsSqlSchema*)fWriterSchema.find_event(event_name, timestamp);
4949
4950 if (!s) {
4951 cm_msg(MERROR, "SqlHistory::new_event", "Error: Cannot update schema database for event \'%s\', see previous messages", event_name);
4952 return NULL;
4953 }
4954
4955 if (0||fDebug) {
4956 printf("SqlHistory::new_event: schema for [%s] is %p\n", event_name, s);
4957 if (s)
4958 s->print();
4959 }
4960
4961 // last call to UpdateMysqlSchema with "false" will check that new schema matches the new tags
4962
4963 status = update_schema(s, timestamp, ntags, tags, false);
4964 if (status != HS_SUCCESS) {
4965 cm_msg(MERROR, "SqlHistory::new_event", "Error: Cannot create schema for event \'%s\', see previous messages", event_name);
4966 //fDebug = 1;
4967 //update_schema(s, timestamp, ntags, tags, false);
4968 //abort();
4969 return NULL;
4970 }
4971
4972 HsSqlSchema* e = new HsSqlSchema();
4973
4974 *e = *s; // make a copy of the schema
4975
4976 return e;
4977}
std::string fEventName
size_t size() const
HsSchema * find_event(const char *event_name, const time_t timestamp, int debug=0)
void print(bool print_tags=true) const
std::string fTableName
HsSchemaVector fWriterSchema
virtual int create_table(HsSchemaVector *sv, const char *event_name, time_t timestamp)=0
virtual int read_column_names(HsSchemaVector *sv, const char *table_name, const char *event_name)=0
virtual int read_table_and_event_names(HsSchemaVector *sv)=0
int update_schema(HsSqlSchema *s, const time_t timestamp, const int ntags, const TAG tags[], bool write_enable)
#define MERROR
Definition midas.h:559
INT cm_msg(INT message_type, const char *filename, INT line, const char *routine, const char *format,...)
Definition midas.cxx:931
static std::string TimeToString(time_t t)
static double e(void)
Definition tinyexpr.c:136
Here is the call graph for this function:

◆ read_column_names()

virtual int SqlHistoryBase::read_column_names ( HsSchemaVector sv,
const char *  table_name,
const char *  event_name 
)
protectedpure virtual

Implemented in SqliteHistory, and MysqlHistory.

Here is the caller graph for this function:

◆ read_schema()

int SqlHistoryBase::read_schema ( HsSchemaVector sv,
const char *  event_name,
const time_t  timestamp 
)
virtual

Implements SchemaHistoryBase.

Definition at line 4979 of file history_schema.cxx.

4980{
4981 if (fDebug)
4982 printf("SqlHistory::read_schema: loading schema for event [%s] at time %s\n", event_name, TimeToString(timestamp).c_str());
4983
4984 int status;
4985
4986 if (sv->size() == 0) {
4988 if (status != HS_SUCCESS)
4989 return status;
4990 }
4991
4992 //sv->print(false);
4993
4994 if (event_name == NULL)
4995 return HS_SUCCESS;
4996
4997 for (size_t i=0; i<sv->size(); i++) {
4998 HsSqlSchema* h = (HsSqlSchema*)(*sv)[i];
4999 // skip schema with already read column names
5000 if (h->fVariables.size() > 0)
5001 continue;
5002 // skip schema with different name
5003 if (!MatchEventName(h->fEventName.c_str(), event_name))
5004 continue;
5005
5006 size_t nn = sv->size();
5007
5008 status = read_column_names(sv, h->fTableName.c_str(), h->fEventName.c_str());
5009
5010 // if new schema was added, loop all over again
5011 if (sv->size() != nn)
5012 i=0;
5013 }
5014
5015 //sv->print(false);
5016
5017 return HS_SUCCESS;
5018}
std::vector< HsSchemaEntry > fVariables
static bool MatchEventName(const char *event_name, const char *var_event_name)
INT i
Definition mdump.cxx:32
Here is the call graph for this function:

◆ read_table_and_event_names()

virtual int SqlHistoryBase::read_table_and_event_names ( HsSchemaVector sv)
protectedpure virtual

Implemented in SqliteHistory, and MysqlHistory.

Here is the caller graph for this function:

◆ update_column()

virtual int SqlHistoryBase::update_column ( const char *  event_name,
const char *  table_name,
const char *  column_name,
const char *  column_type,
const char *  tag_name,
const char *  tag_type,
const time_t  timestamp,
bool  active,
bool *  have_transaction 
)
protectedpure virtual

Implemented in SqliteHistory, and MysqlHistory.

Here is the caller graph for this function:

◆ update_schema()

int SqlHistoryBase::update_schema ( HsSqlSchema s,
const time_t  timestamp,
const int  ntags,
const TAG  tags[],
bool  write_enable 
)
protected

Definition at line 5020 of file history_schema.cxx.

5021{
5022 int status;
5023 bool have_transaction = false;
5024
5025 status = update_schema1(s, timestamp, ntags, tags, write_enable, &have_transaction);
5026
5027 if (have_transaction) {
5028 int xstatus;
5029
5030 if (status == HS_SUCCESS)
5031 xstatus = fSql->CommitTransaction(s->fTableName.c_str());
5032 else
5033 xstatus = fSql->RollbackTransaction(s->fTableName.c_str());
5034
5035 if (xstatus != DB_SUCCESS) {
5036 return HS_FILE_ERROR;
5037 }
5038 have_transaction = false;
5039 }
5040
5041 return status;
5042}
virtual int RollbackTransaction(const char *table_name)=0
virtual int CommitTransaction(const char *table_name)=0
int update_schema1(HsSqlSchema *s, const time_t timestamp, const int ntags, const TAG tags[], bool write_enable, bool *have_transaction)
#define HS_FILE_ERROR
Definition midas.h:729
Here is the call graph for this function:
Here is the caller graph for this function:

◆ update_schema1()

int SqlHistoryBase::update_schema1 ( HsSqlSchema s,
const time_t  timestamp,
const int  ntags,
const TAG  tags[],
bool  write_enable,
bool *  have_transaction 
)
protected

Definition at line 5044 of file history_schema.cxx.

5045{
5046 int status;
5047
5048 if (fDebug)
5049 printf("update_schema1\n");
5050
5051 // check that compare schema with tags[]
5052
5053 bool schema_ok = true;
5054
5055 int offset = 0;
5056 for (int i=0; i<ntags; i++) {
5057 for (unsigned int j=0; j<tags[i].n_data; j++) {
5058 int tagtype = tags[i].type;
5059 std::string tagname = tags[i].name;
5060 std::string maybe_colname = MidasNameToSqlName(tags[i].name);
5061
5062 if (tags[i].n_data > 1) {
5063 char s[256];
5064 sprintf(s, "[%d]", j);
5065 tagname += s;
5066
5067 sprintf(s, "_%d", j);
5068 maybe_colname += s;
5069 }
5070
5071 int count = 0;
5072
5073 for (size_t j=0; j<s->fVariables.size(); j++) {
5074 // NB: inactive columns will be reactivated or recreated by the if(count==0) branch. K.O.
5075 if (s->fColumnInactive[j])
5076 continue;
5077 if (tagname == s->fVariables[j].name) {
5078 if (s->fSql->TypesCompatible(tagtype, s->fColumnTypes[j].c_str())) {
5079 if (count == 0) {
5080 s->fOffsets[j] = offset;
5081 offset += rpc_tid_size(tagtype);
5082 }
5083 count++;
5084 if (count > 1) {
5085 cm_msg(MERROR, "SqlHistory::update_schema", "Duplicate SQL column \'%s\' type \'%s\' in table \"%s\" with MIDAS type \'%s\' history event \"%s\" tag \"%s\"", s->fColumnNames[j].c_str(), s->fColumnTypes[j].c_str(), s->fTableName.c_str(), rpc_tid_name(tagtype), s->fEventName.c_str(), tagname.c_str());
5087 }
5088 } else {
5089 // column with incompatible type, mark it as unused
5090 schema_ok = false;
5091 if (fDebug)
5092 printf("Incompatible column!\n");
5093 if (write_enable) {
5094 cm_msg(MINFO, "SqlHistory::update_schema", "Deactivating SQL column \'%s\' type \'%s\' in table \"%s\" as incompatible with MIDAS type \'%s\' history event \"%s\" tag \"%s\"", s->fColumnNames[j].c_str(), s->fColumnTypes[j].c_str(), s->fTableName.c_str(), rpc_tid_name(tagtype), s->fEventName.c_str(), tagname.c_str());
5096
5097 status = update_column(s->fEventName.c_str(), s->fTableName.c_str(), s->fColumnNames[j].c_str(), s->fColumnTypes[j].c_str(), s->fVariables[j].tag_name.c_str(), s->fVariables[i].tag_type.c_str(), timestamp, false, have_transaction);
5098 if (status != HS_SUCCESS)
5099 return status;
5100 }
5101 }
5102 }
5103 }
5104
5105 if (count == 0) {
5106 // tag does not have a corresponding column
5107 schema_ok = false;
5108 if (fDebug)
5109 printf("No column for tag %s!\n", tagname.c_str());
5110
5111 bool found_column = false;
5112
5113 if (write_enable) {
5114 for (size_t j=0; j<s->fVariables.size(); j++) {
5115 if (tagname == s->fVariables[j].tag_name) {
5116 bool typeok = s->fSql->TypesCompatible(tagtype, s->fColumnTypes[j].c_str());
5117 if (typeok) {
5118 cm_msg(MINFO, "SqlHistory::update_schema", "Reactivating SQL column \'%s\' type \'%s\' in table \"%s\" for history event \"%s\" tag \"%s\"", s->fColumnNames[j].c_str(), s->fColumnTypes[j].c_str(), s->fTableName.c_str(), s->fEventName.c_str(), tagname.c_str());
5120
5121 status = update_column(s->fEventName.c_str(), s->fTableName.c_str(), s->fColumnNames[j].c_str(), s->fColumnTypes[j].c_str(), s->fVariables[j].tag_name.c_str(), s->fVariables[j].tag_type.c_str(), timestamp, true, have_transaction);
5122 if (status != HS_SUCCESS)
5123 return status;
5124
5125 if (count == 0) {
5126 s->fOffsets[j] = offset;
5127 offset += rpc_tid_size(tagtype);
5128 }
5129 count++;
5130 found_column = true;
5131 if (count > 1) {
5132 cm_msg(MERROR, "SqlHistory::update_schema", "Duplicate SQL column \'%s\' type \'%s\' in table \"%s\" for history event \"%s\" tag \"%s\"", s->fColumnNames[j].c_str(), s->fColumnTypes[j].c_str(), s->fTableName.c_str(), s->fEventName.c_str(), tagname.c_str());
5134 }
5135 }
5136 }
5137 }
5138 }
5139
5140 // create column
5141 if (!found_column && write_enable) {
5142 std::string col_name = maybe_colname;
5143 const char* col_type = s->fSql->ColumnType(tagtype);
5144
5145 bool dupe = false;
5146 for (size_t kk=0; kk<s->fColumnNames.size(); kk++)
5147 if (s->fColumnNames[kk] == col_name) {
5148 dupe = true;
5149 break;
5150 }
5151
5152 time_t now = time(NULL);
5153
5154 bool retry = false;
5155 for (int t=0; t<20; t++) {
5156
5157 // if duplicate column name, change it, try again
5158 if (dupe || retry) {
5159 col_name = maybe_colname;
5160 col_name += "_";
5161 col_name += TimeToString(now);
5162 if (t > 0) {
5163 char s[256];
5164 sprintf(s, "_%d", t);
5165 col_name += s;
5166 }
5167 }
5168
5169 if (fDebug)
5170 printf("SqlHistory::update_schema: table [%s], add column [%s] type [%s] for tag [%s]\n", s->fTableName.c_str(), col_name.c_str(), col_type, tagname.c_str());
5171
5172 status = CreateSqlColumn(fSql, s->fTableName.c_str(), col_name.c_str(), col_type, have_transaction, fDebug);
5173
5174 if (status == DB_KEY_EXIST) {
5175 if (fDebug)
5176 printf("SqlHistory::update_schema: table [%s], add column [%s] type [%s] for tag [%s] failed: duplicate column name\n", s->fTableName.c_str(), col_name.c_str(), col_type, tagname.c_str());
5177 retry = true;
5178 continue;
5179 }
5180
5181 if (status != HS_SUCCESS)
5182 return status;
5183
5184 break;
5185 }
5186
5187 if (status != HS_SUCCESS)
5188 return status;
5189
5190 status = update_column(s->fEventName.c_str(), s->fTableName.c_str(), col_name.c_str(), col_type, tagname.c_str(), rpc_tid_name(tagtype), timestamp, true, have_transaction);
5191 if (status != HS_SUCCESS)
5192 return status;
5193 }
5194 }
5195
5196 if (count > 1) {
5197 // schema has duplicate tags
5198 schema_ok = false;
5199 cm_msg(MERROR, "SqlHistory::update_schema", "Duplicate tags or SQL columns for history event \"%s\" tag \"%s\"", s->fEventName.c_str(), tagname.c_str());
5201 }
5202 }
5203 }
5204
5205 // mark as unused all columns not listed in tags
5206
5207 for (size_t k=0; k<s->fColumnNames.size(); k++)
5208 if (s->fVariables[k].name.length() > 0) {
5209 bool found = false;
5210
5211 for (int i=0; i<ntags; i++) {
5212 for (unsigned int j=0; j<tags[i].n_data; j++) {
5213 std::string tagname = tags[i].name;
5214
5215 if (tags[i].n_data > 1) {
5216 char s[256];
5217 sprintf(s, "[%d]", j);
5218 tagname += s;
5219 }
5220
5221 if (s->fVariables[k].name == tagname) {
5222 found = true;
5223 break;
5224 }
5225 }
5226
5227 if (found)
5228 break;
5229 }
5230
5231 if (!found) {
5232 // column not found in tags list
5233 schema_ok = false;
5234 if (fDebug)
5235 printf("Event [%s] Column [%s] tag [%s] not listed in tags list!\n", s->fEventName.c_str(), s->fColumnNames[k].c_str(), s->fVariables[k].name.c_str());
5236 if (write_enable) {
5237 cm_msg(MINFO, "SqlHistory::update_schema", "Deactivating SQL column \'%s\' type \'%s\' in table \"%s\" for history event \"%s\" not used for any tags", s->fColumnNames[k].c_str(), s->fColumnTypes[k].c_str(), s->fTableName.c_str(), s->fEventName.c_str());
5239
5240 status = update_column(s->fEventName.c_str(), s->fTableName.c_str(), s->fColumnNames[k].c_str(), s->fColumnTypes[k].c_str(), s->fVariables[k].tag_name.c_str(), s->fVariables[k].tag_type.c_str(), timestamp, false, have_transaction);
5241 if (status != HS_SUCCESS)
5242 return status;
5243 }
5244 }
5245 }
5246
5247 if (!write_enable)
5248 if (!schema_ok) {
5249 if (fDebug)
5250 printf("Return error!\n");
5251 return HS_FILE_ERROR;
5252 }
5253
5254 return HS_SUCCESS;
5255}
std::vector< int > fOffsets
std::vector< std::string > fColumnNames
std::vector< std::string > fColumnTypes
std::vector< bool > fColumnInactive
char name[NAME_LENGTH]
Definition history.h:111
virtual bool TypesCompatible(int midas_tid, const char *sql_type)=0
virtual const char * ColumnType(int midas_tid)=0
virtual int update_column(const char *event_name, const char *table_name, const char *column_name, const char *column_type, const char *tag_name, const char *tag_type, const time_t timestamp, bool active, bool *have_transaction)=0
#define DB_KEY_EXIST
Definition midas.h:642
#define MINFO
Definition midas.h:560
INT cm_msg_flush_buffer()
Definition midas.cxx:881
const char * rpc_tid_name(INT id)
Definition midas.cxx:11895
INT rpc_tid_size(INT id)
Definition midas.cxx:11888
static std::string MidasNameToSqlName(const char *s)
static int CreateSqlColumn(SqlBase *sql, const char *table_name, const char *column_name, const char *column_type, bool *have_transaction, int debug)
double count
Definition mdump.cxx:33
static int offset
Definition mgd.cxx:1500
INT j
Definition odbhist.cxx:40
INT k
Definition odbhist.cxx:40
DWORD type
Definition midas.h:1235
DWORD n_data
Definition midas.h:1236
char name[NAME_LENGTH]
Definition midas.h:1234
Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ fSql

SqlBase* SqlHistoryBase::fSql

Definition at line 4804 of file history_schema.cxx.


The documentation for this class was generated from the following file: