crawlserv++  [under development]
Application for crawling and analyzing textual content of websites.
Database.hpp File Reference
#include "Exception.hpp"
#include "Version.hpp"
#include "../Data/Data.hpp"
#include "../Helper/CommaLocale.hpp"
#include "../Helper/Container.hpp"
#include "../Helper/FileSystem.hpp"
#include "../Helper/Json.hpp"
#include "../Helper/Portability/locale.h"
#include "../Helper/Portability/mysqlcppconn.h"
#include "../Helper/Strings.hpp"
#include "../Helper/Utf8.hpp"
#include "../Helper/Versions.hpp"
#include "../Struct/ConfigProperties.hpp"
#include "../Struct/DatabaseSettings.hpp"
#include "../Struct/QueryProperties.hpp"
#include "../Struct/TableColumn.hpp"
#include "../Struct/TableProperties.hpp"
#include "../Struct/TargetTableProperties.hpp"
#include "../Struct/ThreadDatabaseEntry.hpp"
#include "../Struct/ThreadOptions.hpp"
#include "../Struct/ThreadStatus.hpp"
#include "../Struct/UrlListProperties.hpp"
#include "../Struct/WebsiteProperties.hpp"
#include "../Timer/Simple.hpp"
#include "../Wrapper/DatabaseLock.hpp"
#include "../Wrapper/DatabaseTryLock.hpp"
#include "../Wrapper/PreparedSqlStatement.hpp"
#include "../_extern/rapidjson/include/rapidjson/document.h"
#include <cppconn/driver.h>
#include <cppconn/exception.h>
#include <cppconn/prepared_statement.h>
#include <cppconn/resultset.h>
#include <cppconn/statement.h>
#include <mysql_connection.h>
#include <algorithm>
#include <cctype>
#include <chrono>
#include <cmath>
#include <cstddef>
#include <cstdint>
#include <fstream>
#include <functional>
#include <iostream>
#include <memory>
#include <mutex>
#include <queue>
#include <sstream>
#include <stdexcept>
#include <string>
#include <string_view>
#include <thread>
#include <tuple>
#include <utility>
#include <vector>
Include dependency graph for Database.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  crawlservpp::Main::Database
 Class handling database access for the command-and-control and its threads. More...
 
class  crawlservpp::Main::Database::Transaction
 Wrapper class for in-scope transactions. More...
 
class  crawlservpp::Main::Database::Exception
 Class for generic database exceptions. More...
 
class  crawlservpp::Main::Database::ConnectionException
 Class for database connection exceptions. More...
 
class  crawlservpp::Main::Database::IncorrectPathException
 Class for incorrect path exceptions. More...
 
class  crawlservpp::Main::Database::StorageEngineException
 Class for storage engine exceptions. More...
 
class  crawlservpp::Main::Database::PrivilegesException
 Class for insufficient privileges exceptions. More...
 
class  crawlservpp::Main::Database::WrongArgumentsException
 Class for wrong arguments exceptions. More...
 

Namespaces

 crawlservpp::Wrapper
 Namespace for RAII wrappers and Wrapper::Database.
 
 crawlservpp::Main
 Namespace for the main classes of the program.
 

Macros

#define MAIN_DATABASE_LOG_MOVING
 

Constants

constexpr auto crawlservpp::Main::sqlDir {"sql"sv}
 (Sub-)Directory for .sql files. More...
 
constexpr auto crawlservpp::Main::sqlExtension {".sql"sv}
 File extension for .sql files. More...
 
constexpr auto crawlservpp::Main::lockTimeOutSec {300}
 Time-out on table lock in seconds. More...
 
constexpr auto crawlservpp::Main::reconnectAfterIdleMs {600000}
 Idle time in milliseconds after which a re-connect to the database will be enforced. More...
 
constexpr auto crawlservpp::Main::sleepOnLockMs {250}
 Sleep time in milliseconds before re-attempting to add a database lock. More...
 
constexpr auto crawlservpp::Main::maxContentSize {1073741824}
 Maximum size of database content in bytes (= 1 GiB). More...
 
constexpr auto crawlservpp::Main::maxContentSizeString {"1 GiB"sv}
 Maximum size of database content as string. More...
 
constexpr auto crawlservpp::Main::wwwPrefix {"www."sv}
 "www." prefix to be ignored when checking for a domain. More...
 
constexpr auto crawlservpp::Main::numUrlListTables {6}
 The minimum number of tables per URL list. More...
 
constexpr auto crawlservpp::Main::sqlConstraint {"CONSTRAINT "sv}
 The MySQL keyword for a constraint, including the trailing space. More...
 
constexpr auto crawlservpp::Main::secToMs {1000}
 The factor for converting seconds to milliseconds and vice versa. More...
 
constexpr auto crawlservpp::Main::sleepOnDeadLockMs {250}
 Time (in ms) to sleep on SQL deadlock. More...
 
constexpr auto crawlservpp::Main::maxColumnsUrlList {6}
 Maximum number of columns in all associated tables associated with an URL list. More...
 
constexpr auto crawlservpp::Main::numArgsAddUrl {4}
 Number fo arguments needed for adding one URL. More...
 

Constants for MySQL Queries

constexpr auto crawlservpp::Main::nAtOnce10 {10}
 Ten at once. More...
 
constexpr auto crawlservpp::Main::nAtOnce100 {100}
 One hundred at once. More...
 
constexpr auto crawlservpp::Main::nAtOnce500 {500}
 Five hundred at once. More...
 
constexpr auto crawlservpp::Main::sqlArg1 {1}
 First argument. More...
 
constexpr auto crawlservpp::Main::sqlArg2 {2}
 Second argument. More...
 
constexpr auto crawlservpp::Main::sqlArg3 {3}
 Third argument. More...
 
constexpr auto crawlservpp::Main::sqlArg4 {4}
 Fourth argument. More...
 
constexpr auto crawlservpp::Main::sqlArg5 {5}
 Fifth argument. More...
 
constexpr auto crawlservpp::Main::sqlArg6 {6}
 Sixth argument. More...
 
constexpr auto crawlservpp::Main::sqlArg7 {7}
 Seventh argument. More...
 
constexpr auto crawlservpp::Main::sqlArg8 {8}
 Eighth argument. More...
 
constexpr auto crawlservpp::Main::sqlArg9 {9}
 Ninth argument. More...
 

Constants for MySQL Connection Errors

constexpr auto crawlservpp::Main::sqlSortAborted {1027}
 Sort aborted. More...
 
constexpr auto crawlservpp::Main::sqlTooManyConnections {1040}
 Too many connections. More...
 
constexpr auto crawlservpp::Main::sqlCannotGetHostName {1042}
 Cannot get host name. More...
 
constexpr auto crawlservpp::Main::sqlBadHandShake {1043}
 Bad handshake. More...
 
constexpr auto crawlservpp::Main::sqlServerShutDown {1053}
 Server shutdown. More...
 
constexpr auto crawlservpp::Main::sqlNormalShutdown {1077}
 Normal shutdown. More...
 
constexpr auto crawlservpp::Main::sqlGotSignal {1078}
 Got signal. More...
 
constexpr auto crawlservpp::Main::sqlShutDownComplete {1079}
 Shutdown complete. More...
 
constexpr auto crawlservpp::Main::sqlForcingCloseOfThread {1080}
 Forcing close of thread. More...
 
constexpr auto crawlservpp::Main::sqlCannotCreateIPSocket {1081}
 Cannot create IP socket. More...
 
constexpr auto crawlservpp::Main::sqlAbortedConnection {1152}
 Aborted connection. More...
 
constexpr auto crawlservpp::Main::sqlReadErrorFromConnectionPipe {1154}
 Read error from connection pipe. More...
 
constexpr auto crawlservpp::Main::sqlPacketsOutOfOrder {1156}
 Packets out of order. More...
 
constexpr auto crawlservpp::Main::sqlCouldNotUncompressPackets {1157}
 Could not uncompress packets. More...
 
constexpr auto crawlservpp::Main::sqlErrorReadingPackets {1158}
 Error reading packets. More...
 
constexpr auto crawlservpp::Main::sqlTimeOutReadingPackets {1159}
 Timeout reading packets. More...
 
constexpr auto crawlservpp::Main::sqlErrorWritingPackets {1160}
 Error writing packets. More...
 
constexpr auto crawlservpp::Main::sqlTimeOutWritingPackets {1161}
 Timeout writing packets. More...
 
constexpr auto crawlservpp::Main::sqlNewAbortedConnection {1184}
 New aborted connection-. More...
 
constexpr auto crawlservpp::Main::sqlNetErrorReadingFromMaster {1189}
 Network error reading from master. More...
 
constexpr auto crawlservpp::Main::sqlNetErrorWritingToMaster {1190}
 Network error writing to master. More...
 
constexpr auto crawlservpp::Main::sqlMoreThanMaxUserConnections {1203}
 More than the maximum number of user connections. More...
 
constexpr auto crawlservpp::Main::sqlLockWaitTimeOutExceeded {1205}
 Lock wait timeout exceeded. More...
 
constexpr auto crawlservpp::Main::sqlNumOfLocksExceedsLockTableSize {1206}
 Number of locks exceeds lock table size. More...
 
constexpr auto crawlservpp::Main::sqlDeadLock {1213}
 Deadlock. More...
 
constexpr auto crawlservpp::Main::sqlServerErrorConnectingToMaster {1218}
 Server error connecting to master. More...
 
constexpr auto crawlservpp::Main::sqlQueryExecutionInterrupted {1317}
 Query execution interrupted. More...
 
constexpr auto crawlservpp::Main::sqlUnableToConnectToForeignDataSource {1429}
 Unable to connect to foreign data source. More...
 
constexpr auto crawlservpp::Main::sqlCannotConnectToServerThroughSocket {2002}
 Cannot connect to server through socket. More...
 
constexpr auto crawlservpp::Main::sqlCannotConnectToServer {2003}
 Cannot connect to server. More...
 
constexpr auto crawlservpp::Main::sqlUnknownServerHost {2005}
 Unknown server host. More...
 
constexpr auto crawlservpp::Main::sqlServerHasGoneAway {2006}
 Server has gone away. More...
 
constexpr auto crawlservpp::Main::sqlTCPError {2011}
 TCP error. More...
 
constexpr auto crawlservpp::Main::sqlErrorInServerHandshake {2012}
 Error in server handshake. More...
 
constexpr auto crawlservpp::Main::sqlLostConnectionDuringQuery {2013}
 Lost connection during query. More...
 
constexpr auto crawlservpp::Main::sqlClientErrorConnectingToSlave {2024}
 Client error connecting to slave. More...
 
constexpr auto crawlservpp::Main::sqlClientErrorConnectingToMaster {2025}
 Client error connecting to master. More...
 
constexpr auto crawlservpp::Main::sqlSSLConnectionError {2026}
 SSL connection error. More...
 
constexpr auto crawlservpp::Main::sqlMalformedPacket {2027}
 Malformed packet. More...
 
constexpr auto crawlservpp::Main::sqlInvalidConnectionHandle {2048}
 Invalid connection handle. More...
 

Constants for Other MySQL Errors

constexpr auto crawlservpp::Main::sqlStorageEngineError {1030}
 Storage engine error. More...
 
constexpr auto crawlservpp::Main::sqlInsufficientPrivileges {1045}
 Insufficient privileges. More...
 
constexpr auto crawlservpp::Main::sqlWrongArguments {1210}
 Wrong arguments. More...
 
constexpr auto crawlservpp::Main::sqlIncorrectPath {1525}
 Incorrect path. More...
 

Macro Definition Documentation

◆ MAIN_DATABASE_LOG_MOVING

#define MAIN_DATABASE_LOG_MOVING