31#ifndef MYSQLX_DETAIL_SESSION_H
32#define MYSQLX_DETAIL_SESSION_H
52class CollectionOptions;
57 using Shared_session_pool = std::shared_ptr<Session_pool>;
65using Client_impl = common::Session_pool;
66using Shared_client_impl = std::shared_ptr<Client_impl>;
67using Session_impl = common::Session_impl;
68using Shared_session_impl = std::shared_ptr<common::Session_impl>;
75class PUBLIC_API Db_obj_base
80 Shared_session_impl m_sess;
84 Db_obj_base(
const Shared_session_impl& sess,
const string& name)
85 : m_sess(sess), m_name(name)
88 virtual ~Db_obj_base() NOEXCEPT
93class PUBLIC_API Collection_detail
98 Collection_detail(
const Shared_session_impl &sess,
const string &name)
99 : Db_obj_base(sess, name)
102 virtual Schema_detail& get_schema() = 0;
104 Result add_or_replace_one(
const string &
id, Value&&,
bool);
106 void index_drop(
const string &name);
107 void index_create(
const string &name, Value &&spec);
125struct PUBLIC_API Query_src
127 using Value = string;
128 using Res_impl = common::Result_impl;
130 Res_impl *m_res =
nullptr;
131 const void *m_row =
nullptr;
138 Query_src(Query_src &&other)
142 other.m_res =
nullptr;
145 Query_src(
const Query_src&) =
delete;
147 virtual ~Query_src() NOEXCEPT;
149 virtual
void iterator_start()
154 bool iterator_next();
155 string iterator_get();
162class PUBLIC_API Schema_detail
167 enum Obj_type { COLLECTION, TABLE };
178 struct PUBLIC_API Name_src
181 const Schema &m_schema;
182 Name_src(
const Schema&, Obj_type,
const string &pattern);
185 struct PUBLIC_API Collection_src
188 using Value = Collection;
190 Collection_src(
const Schema &sch,
const string &pattern)
191 : Name_src(sch, COLLECTION, pattern)
194 using Name_src::iterator_start;
195 using Name_src::iterator_next;
196 Collection iterator_get();
199 struct PUBLIC_API Table_src
204 Table_src(
const Schema &sch,
const string &pattern)
205 : Name_src(sch, TABLE, pattern)
208 using Name_src::iterator_start;
209 using Name_src::iterator_next;
210 Table iterator_get();
213 Schema_detail(
const Shared_session_impl &sess,
const string &name)
214 : Db_obj_base(sess, name)
219 using CollectionList = List_initializer<List_source<Collection_src>>;
220 using TableList = List_initializer<List_source<Table_src>>;
221 using StringList = List_initializer<List_source<Name_src>>;
227 CollectionOptions options);
229 CollectionOptions options);
230 void drop_collection(
const string &name);
232 friend Collection_detail;
245using SQL_statement_cmd = Executable<SqlResult, SQL_statement>;
248 :
public Bind_placeholders< SQL_statement_cmd >
250 ~SQL_statement() NOEXCEPT
253 SQL_statement(Session *sess,
const string &query)
257 reset(internal::Crud_factory::mk_sql(*sess, query));
262 SQL_statement(SQL_statement_cmd &other)
264 SQL_statement_cmd::operator=(other);
267 SQL_statement(SQL_statement_cmd &&other)
269 SQL_statement_cmd::operator=(std::move(other));
274struct Session_detail;
276struct PUBLIC_API Client_detail
281 Client_detail(
const Client_detail&) =
delete;
282 Client_detail& operator=(
const Client_detail&) =
delete;
286 Client_detail(common::Settings_impl &settings);
293 Client_detail(Client_detail && other)
295 m_impl = other.m_impl;
296 other.m_impl.reset();
299 common::Shared_session_pool& get_session_pool();
302 struct INTERNAL Impl;
305 Shared_client_impl m_impl = NULL;
312struct PUBLIC_API Session_detail
316 Session_detail(
const Session_detail&) =
delete;
317 Session_detail& operator=(
const Session_detail&) =
delete;
324 struct PUBLIC_API Name_src
327 const Session &m_sess;
328 Name_src(
const Session&,
const string &pattern);
331 struct PUBLIC_API Schema_src
334 using Value = Schema;
336 Schema_src(Session &sess,
const string &pattern)
337 : Name_src(sess, pattern)
340 Schema_src(Session &sess)
341 : Schema_src(sess,
"%")
344 using Name_src::iterator_start;
345 using Name_src::iterator_next;
346 Schema iterator_get();
351 using SchemaList = List_initializer<List_source<Schema_src>>;
355 Session_detail(Session_detail && other)
357 m_impl = other.m_impl;
358 other.m_impl.reset();
362 struct INTERNAL Impl;
372 Shared_session_impl m_impl = NULL;
375 Session_detail(common::Settings_impl&);
376 Session_detail(common::Shared_session_pool&);
378 virtual ~Session_detail() NOEXCEPT
387 void create_schema(
const string &name,
bool reuse);
388 void drop_schema(
const string &name);
389 string get_default_schema_name();
391 void start_transaction();
393 void rollback(
const string &sp =
string());
394 string savepoint_set(
const string &sp =
string());
395 void savepoint_remove(
const string&);
398 common::Session_impl& get_impl()
401 THROW(
"Invalid session");
405 INTERNAL cdk::Session& get_cdk_session();
412 void prepare_for_cmd();
417 friend Result_detail::Impl;
418 friend internal::Crud_factory;
A wrapper around std::wstring that can perform conversions from/to different character encodings used...
Definition: common.h:114