Merge pull request #1097 from taosdata/feature/lihui
[#1096 TBASE-1389]
This commit is contained in:
commit
672c7d59d9
|
@ -908,6 +908,7 @@ static int32_t tscParseSqlForCreateTableOnDemand(char **sqlstr, SSqlObj *pSql) {
|
|||
|
||||
createTable = true;
|
||||
code = tscGetMeterMetaEx(pSql, pMeterMetaInfo->name, true);
|
||||
if (TSDB_CODE_ACTION_IN_PROGRESS == code) return code;
|
||||
} else {
|
||||
if (cstart != NULL) {
|
||||
sql = cstart;
|
||||
|
@ -1015,7 +1016,7 @@ int doParserInsertSql(SSqlObj *pSql, char *str) {
|
|||
tscTrace("async insert and waiting to get meter meta, then continue parse sql from offset: %" PRId64, pos);
|
||||
return code;
|
||||
}
|
||||
tscTrace("async insert parse error, code:%d, %s", code, tsError[code]);
|
||||
tscError("async insert parse error, code:%d, %s", code, tsError[code]);
|
||||
pSql->asyncTblPos = NULL;
|
||||
goto _error_clean; // TODO: should _clean or _error_clean to async flow ????
|
||||
} else {
|
||||
|
|
|
@ -48,6 +48,7 @@ static pthread_once_t tscinit = PTHREAD_ONCE_INIT;
|
|||
extern int tsTscEnableRecordSql;
|
||||
extern int tsNumOfLogLines;
|
||||
void taosInitNote(int numOfNoteLines, int maxNotes, char* lable);
|
||||
void deltaToUtcInitOnce();
|
||||
|
||||
void tscCheckDiskUsage(void *para, void *unused) {
|
||||
taosGetDisk();
|
||||
|
@ -60,6 +61,7 @@ void taos_init_imp() {
|
|||
SRpcInit rpcInit;
|
||||
|
||||
srand(taosGetTimestampSec());
|
||||
deltaToUtcInitOnce();
|
||||
|
||||
if (tscEmbedded == 0) {
|
||||
/*
|
||||
|
|
|
@ -42,6 +42,7 @@ int64_t taosGetTimestamp(int32_t precision);
|
|||
int32_t getTimestampInUsFromStr(char* token, int32_t tokenlen, int64_t* ts);
|
||||
|
||||
int32_t taosParseTime(char* timestr, int64_t* time, int32_t len, int32_t timePrec);
|
||||
void deltaToUtcInitOnce();
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -24,6 +24,61 @@
|
|||
#include "ttime.h"
|
||||
#include "tutil.h"
|
||||
|
||||
|
||||
// ==== mktime() kernel code =================//
|
||||
static int64_t m_deltaUtc = 0;
|
||||
void deltaToUtcInitOnce() {
|
||||
struct tm tm = {0};
|
||||
|
||||
(void)strptime("1970-01-01 00:00:00", (const char *)("%Y-%m-%d %H:%M:%S"), &tm);
|
||||
m_deltaUtc = (int64_t)mktime(&tm);
|
||||
//printf("====delta:%lld\n\n", seconds);
|
||||
return;
|
||||
}
|
||||
|
||||
int64_t user_mktime(struct tm * tm)
|
||||
{
|
||||
#define TAOS_MINUTE 60
|
||||
#define TAOS_HOUR (60*TAOS_MINUTE)
|
||||
#define TAOS_DAY (24*TAOS_HOUR)
|
||||
#define TAOS_YEAR (365*TAOS_DAY)
|
||||
|
||||
static int month[12] = {
|
||||
0,
|
||||
TAOS_DAY*(31),
|
||||
TAOS_DAY*(31+29),
|
||||
TAOS_DAY*(31+29+31),
|
||||
TAOS_DAY*(31+29+31+30),
|
||||
TAOS_DAY*(31+29+31+30+31),
|
||||
TAOS_DAY*(31+29+31+30+31+30),
|
||||
TAOS_DAY*(31+29+31+30+31+30+31),
|
||||
TAOS_DAY*(31+29+31+30+31+30+31+31),
|
||||
TAOS_DAY*(31+29+31+30+31+30+31+31+30),
|
||||
TAOS_DAY*(31+29+31+30+31+30+31+31+30+31),
|
||||
TAOS_DAY*(31+29+31+30+31+30+31+31+30+31+30)
|
||||
};
|
||||
|
||||
int64_t res;
|
||||
int year;
|
||||
|
||||
year= tm->tm_year - 70;
|
||||
res= TAOS_YEAR*year + TAOS_DAY*((year+1)/4);
|
||||
res+= month[tm->tm_mon];
|
||||
|
||||
if(tm->tm_mon > 1 && ((year+2)%4)) {
|
||||
res-= TAOS_DAY;
|
||||
}
|
||||
|
||||
res+= TAOS_DAY*(tm->tm_mday-1);
|
||||
res+= TAOS_HOUR*tm->tm_hour;
|
||||
res+= TAOS_MINUTE*tm->tm_min;
|
||||
res+= tm->tm_sec;
|
||||
|
||||
return res + m_deltaUtc;
|
||||
|
||||
}
|
||||
|
||||
|
||||
static int64_t parseFraction(char* str, char** end, int32_t timePrec);
|
||||
static int32_t parseTimeWithTz(char* timestr, int64_t* time, int32_t timePrec);
|
||||
static int32_t parseLocaltime(char* timestr, int64_t* time, int32_t timePrec);
|
||||
|
@ -238,6 +293,8 @@ int32_t parseLocaltime(char* timestr, int64_t* time, int32_t timePrec) {
|
|||
|
||||
/* mktime will be affected by TZ, set by using taos_options */
|
||||
int64_t seconds = mktime(&tm);
|
||||
//int64_t seconds = (int64_t)user_mktime(&tm);
|
||||
|
||||
int64_t fraction = 0;
|
||||
|
||||
if (*str == '.') {
|
||||
|
|
Loading…
Reference in New Issue