#include "midas.h"
#include "msystem.h"
#include <vector>
#include <string>
#include "history.h"
#include "mstrlcpy.h"
Go to the source code of this file.
◆ FREE
◆ FindIndexByColumnName()
Definition at line 1006 of file history_odbc.cxx.
1007{
1008 for (
unsigned i=0;
i<
ie->tags.size();
i++)
1010 return &
ie->tags[
i];
1011 }
1013}
BOOL equal_ustring(const char *str1, const char *str2)
TH1X EXPRT * h1_book(const char *name, const char *title, int bins, double min, double max)
◆ FindIndexByEventName()
Definition at line 988 of file history_odbc.cxx.
989{
993 }
995}
static std::vector< IndexEntry * > gHistoryIndex
◆ FindIndexByTableName()
◆ FindIndexByTagName()
Definition at line 997 of file history_odbc.cxx.
998{
999 for (
unsigned i=0;
i<
ie->tags.size();
i++)
1001 return &
ie->tags[
i];
1002 }
1004}
◆ isCompatible()
Definition at line 153 of file history_odbc.cxx.
154{
155#if 0
157#endif
158
160 return true;
161
163 return true;
164
165
167 return true;
168
169
170
172 return true;
173
174
175
177 return true;
178
179 return false;
180}
static int sql2midasType(const char *name)
static const char * midasTypeName(int tid)
static const char * midas2sqlType(int tid)
◆ MakeMidasHistoryODBC()
◆ MakeMidasHistorySqlDebug()
◆ midas2sqlType()
Definition at line 137 of file history_odbc.cxx.
138{
139 assert(tid>=0);
140 assert(tid<15);
142}
static const char ** sql_type
◆ MidasNameToSqlName()
Definition at line 932 of file history_odbc.cxx.
933{
935
936 for (
int i=0; s[
i]!=0;
i++) {
940 else
942 }
943
945}
◆ midasTypeName()
Definition at line 130 of file history_odbc.cxx.
131{
132 assert(tid>=0);
133 assert(tid<15);
135}
static const char * tid_name[]
◆ PrintTags()
◆ ReadIndex()
Definition at line 1020 of file history_odbc.cxx.
1021{
1023 printf(
"ReadIndex [%s]\n", event_name);
1024
1027
1030
1032 printf(
"ReadIndex: reading index for event [%s]\n", event_name);
1033
1034
1035
1036 char cmd[256];
1037
1038 if (event_name)
1039 sprintf(cmd,
"SELECT event_name, table_name, tag_name, column_name, itimestamp FROM _history_index where event_name=\'%s\';", event_name);
1040 else
1041 sprintf(cmd,
"SELECT event_name, table_name, tag_name, column_name, itimestamp FROM _history_index;");
1042
1044
1048 }
1049
1051 printf(
"ReadIndex: event %s, Read status %d, nrows: %d\n",
1052 event_name,
1055 }
1056
1059
1063 }
1064
1067
1070
1072 printf(
"ReadIndex: event %s, nrows: %d, ncols: %d\n",
1073 event_name,
1075
1078
1081
1082
1083 while (1) {
1086 break;
1087
1089
1091 if (p) {
1095
1101 }
1102
1103 if (timestamp >
ie->timestamp) {
1106 ie->timestamp = timestamp;
1107 }
1108
1109
1110 continue;
1111 }
1112
1114 if (p) {
1119
1126 }
1127
1129 for (
unsigned j=0;
j<
ie->tags.size();
j++)
1131 if (timestamp >
ie->tags[
j].timestamp) {
1132 ie->tags[
j].timestamp = timestamp;
1134 }
1136 break;
1137 }
1138
1143 it.timestamp = timestamp;
1144 ie->tags.push_back(
it);
1145 }
1146
1147
1148 continue;
1149 }
1150
1151 }
1152
1154
1156
1157 if (event_name ==
NULL)
1159
1160
1161
1163}
virtual const char * GetColumn(int icol)=0
virtual int Exec(const char *sql)=0
virtual int GetNumColumns()=0
virtual int GetNumRows()=0
static IndexEntry * FindIndexByEventName(const char *event_name)
◆ sql2midasType()
Definition at line 144 of file history_odbc.cxx.
145{
146 for (int tid=0; tid<15; tid++)
148 return tid;
149 printf(
"sql2midasType: Cannot convert SQL data type \'%s\' to a MIDAS data type!\n",
name);
150 return 0;
151}
◆ WriteEvent()
Definition at line 830 of file history_odbc.cxx.
831{
832
833
834 int n =
e->tags.size();
835
836 std::string tags;
838
839
840
841
842 for (
int i=0;
i<
n;
i++) {
843 const Tag*t = &
e->tags[
i];
844
845 if (t) {
847 void* ptr = (
void*)(buf+
offset);
848
850
851 for (
int j=0;
j<arraySize;
j++) {
852 tags += ", ";
854
855 if (arraySize <= 1)
857 else {
859 char s[256];
861 tags += s;
862 }
863
864 char s[1024];
865
867 default:
869 break;
870 case 1:
871 sprintf(s,
"%u",((
unsigned char*)ptr)[
j]);
872 break;
873 case 2:
874 sprintf(s,
"%d",((
signed char*)ptr)[
j]);
875 break;
876 case 3:
877 sprintf(s,
"\'%c\'",((
char*)ptr)[
j]);
878 break;
879 case 4:
880 sprintf(s,
"%u",((
unsigned short*)ptr)[
j]);
881 break;
882 case 5:
883 sprintf(s,
"%d",((
signed short*)ptr)[
j]);
884 break;
885 case 6:
886 sprintf(s,
"%u",((
unsigned int*)ptr)[
j]);
887 break;
888 case 7:
890 break;
891 case 8:
892 sprintf(s,
"%u",((
unsigned int*)ptr)[
j]);
893 break;
894 case 9:
895 sprintf(s,
"\'%.8g\'",((
float*)ptr)[
j]);
896 break;
897 case 10:
898 sprintf(s,
"\'%.16g\'",((
double*)ptr)[
j]);
899 break;
900 }
901
903 }
904 }
905 }
906
907
910 char s[1024];
911 strftime(s,
sizeof(s)-1,
"%Y-%m-%d %H:%M:%S.0",&
tms);
912
914 sprintf(
sss,
"INSERT INTO %s (_t_time, _i_time%s) VALUES (\'%s\', \'%d\'%s);",
915 e->table_name.c_str(),
916 tags.c_str(),
917 s,
918 (int)t,
920
922
925 }
926
928}
◆ gHaveIndex
◆ gHaveIndexAll
◆ gHistoryIndex
◆ gTrace
◆ sql_type
◆ sql_type_mysql
Initial value:= {
"xxxINVALIDxxxNULL",
"tinyint unsigned",
"tinyint",
"char",
"smallint unsigned",
"smallint",
"integer unsigned",
"integer",
"tinyint",
"float",
"double",
"integer unsigned",
"VARCHAR",
"xxxINVALIDxxxARRAY",
"xxxINVALIDxxxSTRUCT",
"xxxINVALIDxxxKEY",
"xxxINVALIDxxxLINK"
}
Definition at line 104 of file history_odbc.cxx.
104 {
105 "xxxINVALIDxxxNULL",
106 "tinyint unsigned",
107 "tinyint",
108 "char",
109 "smallint unsigned",
110 "smallint",
111 "integer unsigned",
112 "integer",
113 "tinyint",
114 "float",
115 "double",
116 "integer unsigned",
117 "VARCHAR",
118 "xxxINVALIDxxxARRAY",
119 "xxxINVALIDxxxSTRUCT",
120 "xxxINVALIDxxxKEY",
121 "xxxINVALIDxxxLINK"
122};
◆ tid_name
Initial value:= {
"NULL",
"UINT8",
"INT8",
"CHAR",
"UINT16",
"INT16",
"UINT32",
"INT32",
"BOOL",
"FLOAT",
"DOUBLE",
"BITFIELD",
"STRING",
"ARRAY",
"STRUCT",
"KEY",
"LINK",
"INT64",
"UINT64"
}
Definition at line 59 of file history_odbc.cxx.
59 {
60 "NULL",
61 "UINT8",
62 "INT8",
63 "CHAR",
64 "UINT16",
65 "INT16",
66 "UINT32",
67 "INT32",
68 "BOOL",
69 "FLOAT",
70 "DOUBLE",
71 "BITFIELD",
72 "STRING",
73 "ARRAY",
74 "STRUCT",
75 "KEY",
76 "LINK",
77 "INT64",
78 "UINT64"
79};
◆ tid_size
Initial value:= {
0,
1,
1,
1,
2,
2,
4,
4,
4,
4,
8,
4,
0,
0,
0,
0,
0,
8,
8
}
Definition at line 36 of file history_odbc.cxx.
36 {
37 0,
38 1,
39 1,
40 1,
41 2,
42 2,
43 4,
44 4,
45 4,
46 4,
47 8,
48 4,
49 0,
50 0,
51 0,
52 0,
53 0,
54 8,
55 8
56};