112 uint32 sqlRecordCount = 0;
113 uint32 sqlHighestIndex = 0;
121 query +=
" ORDER BY " + *sql->
indexName +
" DESC";
128 sqlRecordCount =
uint32(result->GetRowCount());
131 fields = result->Fetch();
144 char* sqlDataTable =
NULL;
148 sqlRecordCount, sqlHighestIndex, sqlDataTable));
162 fields = result->Fetch();
173 indexTable.asT[id] =
reinterpret_cast<T*
>(&sqlDataTable[offset]);
176 indexTable.asT[rowIndex]=
reinterpret_cast<T*
>(&sqlDataTable[offset]);
179 uint32 sqlColumnNumber = 0;
181 for (; columnNumber < sql->
formatString->size(); ++columnNumber)
185 switch (
fmt[columnNumber])
188 *
reinterpret_cast<float*
>(&sqlDataTable[offset]) = 0.0f;
193 *
reinterpret_cast<uint32*
>(&sqlDataTable[offset]) =
uint32(0);
197 *
reinterpret_cast<uint8*
>(&sqlDataTable[offset]) =
uint8(0);
201 *
reinterpret_cast<uint64*
>(&sqlDataTable[offset]) =
uint64(0);
206 *
reinterpret_cast<char**
>(&sqlDataTable[offset]) =
stringPoolList.back();
207 offset +=
sizeof(
char*);
213 bool validSqlColumn =
true;
214 switch (
fmt[columnNumber])
217 *
reinterpret_cast<float*
>(&sqlDataTable[offset]) = fields[sqlColumnNumber].GetFloat();
222 *
reinterpret_cast<uint32*
>(&sqlDataTable[offset]) = fields[sqlColumnNumber].GetUInt32();
226 *
reinterpret_cast<uint8*
>(&sqlDataTable[offset]) = fields[sqlColumnNumber].GetUInt8();
230 *
reinterpret_cast<uint64*
>(&sqlDataTable[offset]) = fields[sqlColumnNumber].GetUInt64();
234 TC_LOG_ERROR(
"server.loading",
"Unsupported data type in table '%s' at char %d", sql->
sqlTableName.c_str(), columnNumber);
239 validSqlColumn =
false;
242 if (validSqlColumn && (columnNumber != (sql->
formatString->size()-1)))
247 TC_LOG_ERROR(
"server.loading",
"Incorrect sql format string '%s' at char %d", sql->
sqlTableName.c_str(), columnNumber);
252 if (sqlColumnNumber != (result->GetFieldCount() - 1))
254 TC_LOG_ERROR(
"server.loading",
"SQL and DBC format strings are not matching for table: '%s'", sql->
sqlTableName.c_str());
260 }
while (result->NextRow());
std::string const * indexName
Definition: DBCStore.h:33
int32 sqlIndexPos
Definition: DBCStore.h:36
uint32 fieldCount
Definition: DBCStore.h:309
StringPoolList stringPoolList
Definition: DBCStore.h:319
Class used to access individual fields of database query result.
Definition: Field.h:56
std::string const * formatString
Definition: DBCStore.h:32
arena_t NULL
Definition: jemalloc_internal.h:624
WorldDatabaseWorkerPool WorldDatabase
Accessor to the world database.
Definition: DatabaseEnv.cpp:20
uint64_t uint64
Definition: g3dmath.h:170
char * query(struct soap *soap)
Definition: httpget.cpp:244
bool Load(const char *filename, const char *fmt)
Definition: DBCFileLoader.cpp:28
Definition: DBCFileLoader.h:26
int32 indexPos
Definition: DBCStore.h:35
std::string sqlTableName
Definition: DBCStore.h:34
char * AutoProduceStrings(const char *fmt, char *dataTable)
Definition: DBCFileLoader.cpp:272
uint32 GetNumRows() const
Get begin iterator over records.
Definition: DBCFileLoader.h:84
uint32_t uint32
Definition: Define.h:150
uint64_t uint64
Definition: Define.h:149
std::shared_ptr< ResultSet > QueryResult
Definition: QueryResult.h:61
char * AutoProduceData(const char *fmt, uint32 &count, char **&indexTable, uint32 sqlRecordCount, uint32 sqlHighestIndex, char *&sqlDataTable)
Definition: DBCFileLoader.cpp:173
T * dataTable
Definition: DBCStore.h:318
uint8_t uint8
Definition: g3dmath.h:164
uint32 GetCols() const
Definition: DBCFileLoader.h:86
QueryResult Query(const char *sql, T *connection=nullptr)
Definition: DatabaseWorkerPool.cpp:113
uint32 GetUInt32() const
Definition: Field.h:146
int32_t int32
Definition: g3dmath.h:167
uint8_t uint8
Definition: Define.h:152
union DBCStorage::@339 indexTable
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207
uint32_t uint32
Definition: g3dmath.h:168
uint32 nCount
Definition: DBCStore.h:308