TrinityCore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
BasicStatementTask Class Reference

#include <AdhocStatement.h>

Public Member Functions

 BasicStatementTask (const char *sql, bool async=false)
 
 ~BasicStatementTask ()
 
bool Execute () override
 
QueryResultFuture GetFuture () const
 
- Public Member Functions inherited from SQLOperation
 SQLOperation ()
 
virtual ~SQLOperation ()
 
virtual int call ()
 
virtual void SetConnection (MySQLConnection *con)
 

Private Attributes

const char * m_sql
 
bool m_has_result
 
QueryResultPromisem_result
 

Additional Inherited Members

- Public Attributes inherited from SQLOperation
MySQLConnection * m_conn
 

Detailed Description

Raw, ad-hoc query.

Constructor & Destructor Documentation

BasicStatementTask::BasicStatementTask ( const char *  sql,
bool  async = false 
)

Basic, ad-hoc queries.

22  :
23 m_result(nullptr)
24 {
25  m_sql = strdup(sql);
26  m_has_result = async; // If the operation is async, then there's a result
27  if (async)
29 }
const char * m_sql
Definition: AdhocStatement.h:38
std::promise< QueryResult > QueryResultPromise
Definition: Callback.h:25
QueryResultPromise * m_result
Definition: AdhocStatement.h:40
bool m_has_result
Definition: AdhocStatement.h:39
BasicStatementTask::~BasicStatementTask ( )
32 {
33  free((void*)m_sql);
34  if (m_has_result && m_result != nullptr)
35  delete m_result;
36 }
const char * m_sql
Definition: AdhocStatement.h:38
QueryResultPromise * m_result
Definition: AdhocStatement.h:40
bool m_has_result
Definition: AdhocStatement.h:39

Member Function Documentation

bool BasicStatementTask::Execute ( )
overridevirtual

Implements SQLOperation.

39 {
40  if (m_has_result)
41  {
42  ResultSet* result = m_conn->Query(m_sql);
43  if (!result || !result->GetRowCount() || !result->NextRow())
44  {
45  delete result;
46  m_result->set_value(QueryResult(NULL));
47  return false;
48  }
49 
50  m_result->set_value(QueryResult(result));
51  return true;
52  }
53 
54  return m_conn->Execute(m_sql);
55 }
bool NextRow()
Definition: QueryResult.cpp:176
arena_t NULL
Definition: jemalloc_internal.h:624
const char * m_sql
Definition: AdhocStatement.h:38
MySQLConnection * m_conn
Definition: SQLOperation.h:70
Definition: QueryResult.h:30
QueryResultPromise * m_result
Definition: AdhocStatement.h:40
uint64 GetRowCount() const
Definition: QueryResult.h:37
std::shared_ptr< ResultSet > QueryResult
Definition: QueryResult.h:61
bool m_has_result
Definition: AdhocStatement.h:39

+ Here is the call graph for this function:

QueryResultFuture BasicStatementTask::GetFuture ( ) const
inline
35 { return m_result->get_future(); }
QueryResultPromise * m_result
Definition: AdhocStatement.h:40

+ Here is the caller graph for this function:

Member Data Documentation

bool BasicStatementTask::m_has_result
private
QueryResultPromise* BasicStatementTask::m_result
private
const char* BasicStatementTask::m_sql
private

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