RetCode StmtHandler::Execute(ExecutedResult* exec_result) { GETCURRENTTIME(start_time); RetCode ret = rSuccess; sql_parser_ = new Parser(sql_stmt_); AstNode* raw_ast = sql_parser_->GetRawAST(); if (NULL == raw_ast) { exec_result->error_info_ = "Parser Error"; exec_result->status_ = false; exec_result->result_ = NULL; return rParserError; } raw_ast->Print(); ret = GenerateStmtExec(raw_ast); if (rSuccess != ret) { return ret; } ret = stmt_exec_->Execute(exec_result); if (rSuccess != ret) { return ret; } double exec_time_ms = GetElapsedTime(start_time); if (NULL != exec_result->result_) exec_result->result_->query_time_ = exec_time_ms / 1000.0; cout << "execute time: " << exec_time_ms / 1000.0 << " sec" << endl; return rSuccess; }
void RDAUserDatabase::extendAuthTokenValidity(const Wt::Auth::User& user) { RDATData *prev=NULL; char *d=NULL,*t=NULL; /* * David: find the token with hash 'loginTokenHash_' (for this user) * and reset the expiration time to 30 minutes. */ if(SEC_TOKEN_FILENO==(-1)) { return; } ZERNRD(SEC_TOKEN_FILENO); FINDFLDSETSTRING(SEC_TOKEN_FILENO,"TOKEN",loginTokenHash_.c_str()); if(!EQLNRD(SEC_TOKEN_FILENO,1)) { prev=RDATDataNEW(SEC_TOKEN_FILENO); FINDFLDSETCHAR(SEC_TOKEN_FILENO,"DELETEFLAG",FALSE); FINDFLDSETSTRING(SEC_TOKEN_FILENO,"USER IDENTIFICATION",user.id().c_str()); d=GETCURRENTDATE10(); t=GETCURRENTTIME(); if(d!=NULL) Rfree(d); if(t!=NULL) Rfree(t); WRTTRANS(SEC_TOKEN_FILENO,0,NULL,prev); if(prev!=NULL) FreeRDATData(prev); } }
static void set_appdefaults(RDArsrc *mtnrsrc,mtnstruct *mtn,short update) { char *date=NULL,*timex=NULL; FINDRSCSETSTRING(mtnrsrc,"[VENINV][SOURCE USER]",USERLOGIN); date=GETCURRENTDATE(); timex=GETCURRENTTIME(); FINDRSCSETSTRING(mtnrsrc,"[VENINV][ENTRY DATE]",date); FINDRSCSETSTRING(mtnrsrc,"[VENINV][ENTRY TIME]",timex); if(date!=NULL) Rfree(date); if(timex!=NULL) Rfree(timex); setaddresses(mtnrsrc,mtn,update); if(update) { updatersrc(mtnrsrc,"[VENINV][SOURCE USER]"); updatersrc(mtnrsrc,"[VENINV][ENTRY DATE]"); updatersrc(mtnrsrc,"[VENINV][ENTRY TIME]"); } }
void RDAUserDatabase::addAuthToken (const Wt::Auth::User &user, const Wt::Auth::Token &token) { char *d=NULL,*t=NULL; RDATData *prev=NULL; /* * David: add a token for the user to the database, with token.hash() and * token.expirationTime() WDatetime values */ loginTokenHash_ = token.hash(); /* std::cerr << "SEC_TOKEN_FILENO [" << SEC_TOKEN_FILENO << "]" << std::endl; */ if(SEC_TOKEN_FILENO==(-1)) { return; } ZERNRD(SEC_TOKEN_FILENO); FINDFLDSETSTRING(SEC_TOKEN_FILENO,"TOKEN",token.hash().c_str()); FINDFLDSETCHAR(SEC_TOKEN_FILENO,"DELETEFLAG",FALSE); FINDFLDSETSTRING(SEC_TOKEN_FILENO,"USER IDENTIFICATION",user.id().c_str()); d=GETCURRENTDATE10(); t=GETCURRENTTIME(); WRTTRANS(SEC_TOKEN_FILENO,0,NULL,prev); ZERNRD(SEC_USERS_FILENO); FINDFLDSETSTRING(SEC_USERS_FILENO,"USER IDENTIFICATION",user.id().c_str()); if(EQLNRD(SEC_USERS_FILENO,1)) { KEYNRD(SEC_USERS_FILENO,1); } else { prev=RDATDataNEW(SEC_USERS_FILENO); FINDFLDSETSTRING(SEC_USERS_FILENO,"LAST LOGIN ATTEMPT DATE",d); FINDFLDSETSTRING(SEC_USERS_FILENO,"LAST LOGIN ATTEMPT TIME",t); WRTTRANS(SEC_USERS_FILENO,0,NULL,prev); if(prev!=NULL) FreeRDATData(prev); } if(d!=NULL) Rfree(d); if(t!=NULL) Rfree(t); }
static void printerrorlist(RDArsrc *parent,RDA_PFILE *fp) { int x; char *date=NULL,*timex=NULL; if(fp!=NULL) { date=GETCURRENTDATE(); timex=GETCURRENTTIME(); RDA_fprintf(fp," XPERT MAKE GUI SCREENS ERROR LIST Date: %*s\n",8,date); RDA_fprintf(fp,"%*sExecuted By: %s%*sTime: %s\n\n", ((80-(14+RDAstrlen(USERLOGIN)))/2), "",USERLOGIN, (((80-(14+RDAstrlen(USERLOGIN)))/2)-14),"", timex); if(date!=NULL) Rfree(date); if(timex!=NULL) Rfree(timex); for(x=0;x<errorlist->numlibs;++x) { RDA_fprintf(fp,"(%5d) %s\n",(x+1),errorlist->libs[x]); } RDA_fprintf(fp,"\f"); } }
double Timer::ElapsedTime() { GETCURRENTTIME(current); return LastElapsedTime(); }
long long Timer::ElapsedTicks() { GETCURRENTTIME(current); return LastElapsedTicks(); }
void Timer::Reset() { GETCURRENTTIME(start); current=start; }
RetCode StmtHandler::Execute(ExecutedResult* exec_result) { GETCURRENTTIME(start_time); RetCode ret = rSuccess; sql_parser_ = new Parser(sql_stmt_, (exec_result->info_)); AstNode* raw_ast = sql_parser_->GetRawAST(); if (NULL == raw_ast) { exec_result->error_info_ = "Parser Error\n" + exec_result->info_; exec_result->status_ = false; exec_result->result_ = NULL; return rSQLParserErr; } raw_ast->Print(); ret = GenerateStmtExec(raw_ast); if (rSuccess != ret) { return ret; } trim(sql_stmt_); to_lower(sql_stmt_); // not select stmt if (sql_stmt_.substr(0, 6) != string("select")) { ret = stmt_exec_->Execute(exec_result); if (rSuccess != ret) { return ret; } } else { // select stmt StmtExecStatus* exec_status = new StmtExecStatus(sql_stmt_); exec_status->RegisterToTracker(); stmt_exec_->set_stmt_exec_status(exec_status); ret = stmt_exec_->Execute(); if (rSuccess != ret) { exec_result->result_ = NULL; exec_result->status_ = false; exec_result->error_info_ = sql_stmt_ + string(" execution error!"); exec_status->set_exec_status(StmtExecStatus::ExecStatus::kError); return ret; } else { if (StmtExecStatus::ExecStatus::kCancelled == exec_status->get_exec_status()) { exec_result->result_ = NULL; exec_result->status_ = false; exec_result->error_info_ = sql_stmt_ + string(" have been cancelled!"); exec_status->set_exec_status(StmtExecStatus::ExecStatus::kError); } else if (StmtExecStatus::ExecStatus::kOk == exec_status->get_exec_status()) { exec_result->result_ = exec_status->get_query_result(); exec_result->status_ = true; exec_result->info_ = exec_status->get_exec_info(); exec_status->set_exec_status(StmtExecStatus::ExecStatus::kDone); } else { assert(false); exec_status->set_exec_status(StmtExecStatus::ExecStatus::kError); } } } double exec_time_ms = GetElapsedTime(start_time); if (NULL != exec_result->result_) { exec_result->result_->query_time_ = exec_time_ms / 1000.0; } cout << "execute time: " << exec_time_ms / 1000.0 << " sec" << endl; return rSuccess; }