The SqlServer class executes client SQL requests.
For an overview see page C++ Classes
The SqlServer methods are described below.
SqlServer(McoSqlEngine* engine, int port, size_t bufferSize = 64 * 1024, size_t nThreads = 8, int listenQueueSize = 5, error_handler_t handler = NULL, bool localDomain = false, void* sslParameters = NULL, bool authenticationRequired = false, int interruptTimeout = 100, int compressionLevel = 0);Constructs the SQL server; the arguments are defined as follows:
engine— The local McoSqlEngine instance.port— The server port.bufferSize— The size of the transfer buffer. Results of client query execution will be placed in this buffer. If the result data source cannot fit into the buffer, then the query result will be delivered to the client in parts. In this case, a transaction lock is kept until all the results are sent to the client.nThreads— The optimal number of threads spawned by the server. The server will spawn as many threads as client requests arrive. Each thread processes requests from the client until the client closes the connection. After this, the thread is returned to the pool of idle threads or is terminated if the number of threads exceeds the optimal number specified.listenQueueSize— The parameter of the socket listen function; specifies the maximum number of connections that can be concurrently accepted by the server.handler— An optional error handler.localDomain— Indicates that a Unix domain socket instead of a networked TCP socket is used for RSQL communication, which is possible only when the server and client are on the same host.sslParameters— A pointer to amco_ssl_params_tstructure containing SSL connection settings.authenticationRequired— Indicates whether authentication is required for clients.interruptTimeout— The period in milliseconds to poll the interrupts from the client(s). If 0, interruption is disabled.compressionLevel— Compression level: 0 = no compression, 1 = best speed, 9 = best compression. The default value is 0.SqlServer(const OpenParameters ¶ms);This constructor instantiates the server with the arguments specified in the OpenParameters structure defined as follows (the meanings of these arguments are defined in the constructor above):
struct OpenParameters { McoSqlEngine *engine; int port; size_t bufferSize; size_t nThreads; int listenQueueSize; error_handler_t handler; bool localDomain; void * sslParameters; bool authenticationRequired; int interruptTimeout; const char *netInterface; int nGcThreads; int gcPeriod; OpenParameters(McoSqlEngine *eng, int p) : engine(eng), port(p), bufferSize(64 * 1024), nThreads(8), listenQueueSize(5), handler(0), localDomain(false), sslParameters(0), authenticationRequired(false), interruptTimeout(100), netInterface(0), nGcThreads(0), gcPeriod(100) {} };void start();Starts the server; opens a socket at the specified port and accepts client connection requests.void stop();Stops the server; stops accepting connection requests and closes the server socket.void getSessionsInfo(session_info_handler_t handler, void* context = NULL);Enumerates sessions in a wait state followed by active sessions.void regSessionEvent(session_info_handler_t handler, void* context = NULL);Registers a callback to receive new session start and stop events.void regQueryInfoEvent(query_info_handler_t handler, void* context = NULL);Registers a callback to receive query statistics events.~SqlServer();Destroys the SQL server.