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()
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();
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(Session *sess,
const string &query)
254 reset(internal::Crud_factory::mk_sql(*sess, query));
259 SQL_statement(SQL_statement_cmd &other)
261 SQL_statement_cmd::operator=(other);
264 SQL_statement(SQL_statement_cmd &&other)
266 SQL_statement_cmd::operator=(std::move(other));
271struct Session_detail;
273struct PUBLIC_API Client_detail
278 Client_detail(
const Client_detail&) =
delete;
279 Client_detail& operator=(
const Client_detail&) =
delete;
283 Client_detail(common::Settings_impl &settings);
290 Client_detail(Client_detail && other)
292 m_impl = other.m_impl;
293 other.m_impl.reset();
296 common::Shared_session_pool& get_session_pool();
299 struct INTERNAL Impl;
302 Shared_client_impl m_impl = NULL;
309struct PUBLIC_API Session_detail
313 Session_detail(
const Session_detail&) =
delete;
314 Session_detail& operator=(
const Session_detail&) =
delete;
321 struct PUBLIC_API Name_src
324 const Session &m_sess;
325 Name_src(
const Session&,
const string &pattern);
328 struct PUBLIC_API Schema_src
331 using Value = Schema;
333 Schema_src(Session &sess,
const string &pattern)
334 : Name_src(sess, pattern)
337 Schema_src(Session &sess)
338 : Schema_src(sess,
"%")
341 using Name_src::iterator_start;
342 using Name_src::iterator_next;
343 Schema iterator_get();
348 using SchemaList = List_initializer<List_source<Schema_src>>;
352 Session_detail(Session_detail && other)
354 m_impl = other.m_impl;
355 other.m_impl.reset();
359 struct INTERNAL Impl;
369 Shared_session_impl m_impl = NULL;
372 Session_detail(common::Settings_impl&);
373 Session_detail(common::Shared_session_pool&);
375 virtual ~Session_detail()
384 void create_schema(
const string &name,
bool reuse);
385 void drop_schema(
const string &name);
386 string get_default_schema_name();
388 void start_transaction();
390 void rollback(
const string &sp =
string());
391 string savepoint_set(
const string &sp =
string());
392 void savepoint_remove(
const string&);
395 common::Session_impl& get_impl()
398 THROW(
"Invalid session");
402 INTERNAL cdk::Session& get_cdk_session();
409 void prepare_for_cmd();
414 friend Result_detail::Impl;
415 friend internal::Crud_factory;
A wrapper around std::wstring that can perform conversions from/to different character encodings used...
Definition: common.h:114