backend.h 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637
  1. ///////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright (C) 2010-2011 Artyom Beilis (Tonkikh) <artyomtnk@yahoo.com>
  4. //
  5. // Distributed under:
  6. //
  7. // the Boost Software License, Version 1.0.
  8. // (See accompanying file LICENSE_1_0.txt or copy at
  9. // http://www.boost.org/LICENSE_1_0.txt)
  10. //
  11. // or (at your opinion) under:
  12. //
  13. // The MIT License
  14. // (See accompanying file MIT.txt or a copy at
  15. // http://www.opensource.org/licenses/mit-license.php)
  16. //
  17. ///////////////////////////////////////////////////////////////////////////////
  18. #ifndef CPPDB_BACKEND_H
  19. #define CPPDB_BACKEND_H
  20. #include <iosfwd>
  21. #include <ctime>
  22. #include <string>
  23. #include <memory>
  24. #include <map>
  25. #include <typeinfo>
  26. #include <cppdb/defs.h>
  27. #include <cppdb/errors.h>
  28. #include <cppdb/ref_ptr.h>
  29. #include <cppdb/connection_specific.h>
  30. // Borland errors about unknown pool-type without this include.
  31. #ifdef __BORLANDC__
  32. #include <cppdb/pool.h>
  33. #endif
  34. namespace cppdb {
  35. class connection_info;
  36. // Borland needs pool.h, but not this forward declaration.
  37. #ifndef __BORLANDC__
  38. class pool;
  39. #endif
  40. ///
  41. /// \brief This namepace includes all classes required to implement a cppdb SQL backend.
  42. ///
  43. namespace backend {
  44. ///
  45. /// \brief This class represents query result.
  46. ///
  47. /// This object is created by statement::query call, backend developer may assume that this object
  48. /// will stay alive as long as statement that created it exits, i.e. statement would be destroyed after
  49. /// result.
  50. ///
  51. class CPPDB_API result : public ref_counted {
  52. public:
  53. ///
  54. /// The flag that defines the information about availability of the next row in result
  55. ///
  56. typedef enum {
  57. last_row_reached, ///< No more rows exits, next() would return false
  58. next_row_exists, ///< There are more rows, next() would return true
  59. next_row_unknown ///< It is unknown, next() may return either true or false
  60. } next_row;
  61. ///
  62. /// Check if the next row in the result exists. If the DB engine can't perform
  63. /// this check without loosing data for current row, it should return next_row_unknown.
  64. ///
  65. virtual next_row has_next() = 0;
  66. ///
  67. /// Move to next row. Should be called before first access to any of members. If no rows remain
  68. /// return false, otherwise return true
  69. ///
  70. virtual bool next() = 0;
  71. ///
  72. /// Fetch an integer value for column \a col starting from 0.
  73. ///
  74. /// Should throw invalid_column() \a col value is invalid, should throw bad_value_cast() if the underlying data
  75. /// can't be converted to integer or its range is not supported by the integer type.
  76. ///
  77. virtual bool fetch(int col,short &v) = 0;
  78. ///
  79. /// Fetch an integer value for column \a col starting from 0.
  80. /// Returns true if ok, returns false if the column value is NULL and the referenced object should remain unchanged
  81. ///
  82. /// Should throw invalid_column() \a col value is invalid, should throw bad_value_cast() if the underlying data
  83. /// can't be converted to integer or its range is not supported by the integer type.
  84. ///
  85. virtual bool fetch(int col,unsigned short &v) = 0;
  86. ///
  87. /// Fetch an integer value for column \a col starting from 0.
  88. /// Returns true if ok, returns false if the column value is NULL and the referenced object should remain unchanged
  89. ///
  90. /// Should throw invalid_column() \a col value is invalid, should throw bad_value_cast() if the underlying data
  91. /// can't be converted to integer or its range is not supported by the integer type.
  92. ///
  93. virtual bool fetch(int col,int &v) = 0;
  94. ///
  95. /// Fetch an integer value for column \a col starting from 0.
  96. /// Returns true if ok, returns false if the column value is NULL and the referenced object should remain unchanged
  97. ///
  98. /// Should throw invalid_column() \a col value is invalid, should throw bad_value_cast() if the underlying data
  99. /// can't be converted to integer or its range is not supported by the integer type.
  100. ///
  101. virtual bool fetch(int col,unsigned &v) = 0;
  102. ///
  103. /// Fetch an integer value for column \a col starting from 0.
  104. /// Returns true if ok, returns false if the column value is NULL and the referenced object should remain unchanged
  105. ///
  106. /// Should throw invalid_column() \a col value is invalid, should throw bad_value_cast() if the underlying data
  107. /// can't be converted to integer or its range is not supported by the integer type.
  108. ///
  109. virtual bool fetch(int col,long &v) = 0;
  110. ///
  111. /// Fetch an integer value for column \a col starting from 0.
  112. /// Returns true if ok, returns false if the column value is NULL and the referenced object should remain unchanged
  113. ///
  114. /// Should throw invalid_column() \a col value is invalid, should throw bad_value_cast() if the underlying data
  115. /// can't be converted to integer or its range is not supported by the integer type.
  116. ///
  117. virtual bool fetch(int col,unsigned long &v) = 0;
  118. ///
  119. /// Fetch an integer value for column \a col starting from 0.
  120. /// Returns true if ok, returns false if the column value is NULL and the referenced object should remain unchanged
  121. ///
  122. /// Should throw invalid_column() \a col value is invalid, should throw bad_value_cast() if the underlying data
  123. /// can't be converted to integer or its range is not supported by the integer type.
  124. ///
  125. virtual bool fetch(int col,long long &v) = 0;
  126. ///
  127. /// Fetch an integer value for column \a col starting from 0.
  128. /// Returns true if ok, returns false if the column value is NULL and the referenced object should remain unchanged
  129. ///
  130. /// Should throw invalid_column() \a col value is invalid, should throw bad_value_cast() if the underlying data
  131. /// can't be converted to integer or its range is not supported by the integer type.
  132. ///
  133. virtual bool fetch(int col,unsigned long long &v) = 0;
  134. ///
  135. /// Fetch a floating point value for column \a col starting from 0.
  136. /// Returns true if ok, returns false if the column value is NULL and the referenced object should remain unchanged
  137. ///
  138. /// Should throw invalid_column() \a col value is invalid, should throw bad_value_cast() if the underlying data
  139. /// can't be converted to floating point value.
  140. ///
  141. virtual bool fetch(int col,float &v) = 0;
  142. ///
  143. /// Fetch a floating point value for column \a col starting from 0.
  144. /// Returns true if ok, returns false if the column value is NULL and the referenced object should remain unchanged
  145. ///
  146. /// Should throw invalid_column() \a col value is invalid, should throw bad_value_cast() if the underlying data
  147. /// can't be converted to floating point value.
  148. ///
  149. virtual bool fetch(int col,double &v) = 0;
  150. ///
  151. /// Fetch a floating point value for column \a col starting from 0.
  152. /// Returns true if ok, returns false if the column value is NULL and the referenced object should remain unchanged
  153. ///
  154. /// Should throw invalid_column() \a col value is invalid, should throw bad_value_cast() if the underlying data
  155. /// can't be converted to floating point value.
  156. ///
  157. virtual bool fetch(int col,long double &v) = 0;
  158. ///
  159. /// Fetch a string value for column \a col starting from 0.
  160. /// Returns true if ok, returns false if the column value is NULL and the referenced object should remain unchanged
  161. ///
  162. /// Should throw invalid_column() \a col value is invalid, any data should be convertible to
  163. /// text value (as formatting integer, floating point value or date-time as string).
  164. ///
  165. virtual bool fetch(int col,std::string &v) = 0;
  166. ///
  167. /// Fetch a BLOB value for column \a col starting from 0.
  168. /// Returns true if ok, returns false if the column value is NULL and the referenced object should remain unchanged
  169. ///
  170. /// Should throw invalid_column() \a col value is invalid, any data should be convertible to
  171. /// BLOB value as text (as formatting integer, floating point value or date-time as string).
  172. ///
  173. virtual bool fetch(int col,std::ostream &v) = 0;
  174. ///
  175. /// Fetch a date-time value for column \a col starting from 0.
  176. /// Returns true if ok, returns false if the column value is NULL and the referenced object should remain unchanged
  177. ///
  178. /// Should throw invalid_column() \a col value is invalid. If the data can't be converted
  179. /// to date-time it should throw bad_value_cast()
  180. ///
  181. virtual bool fetch(int col,std::tm &v) = 0;
  182. ///
  183. /// Check if the column \a col is NULL starting from 0, should throw invalid_column() if the index out of range
  184. ///
  185. virtual bool is_null(int col) = 0;
  186. ///
  187. /// Return the number of columns in the result. Should be valid even without calling next() first time.
  188. ///
  189. virtual int cols() = 0;
  190. ///
  191. /// Return the number of columns by its name. Return -1 if the name is invalid
  192. /// Should be able to work even without calling next() first time.
  193. ///
  194. virtual int name_to_column(std::string const &) = 0;
  195. ///
  196. /// Return the column name for column index starting from 0.
  197. /// Should throw invalid_column() if the index out of range
  198. /// Should be able to work even without calling next() first time.
  199. ///
  200. virtual std::string column_to_name(int) = 0;
  201. result();
  202. virtual ~result();
  203. private:
  204. struct data;
  205. std::unique_ptr<data> d;
  206. };
  207. class statements_cache;
  208. ///
  209. /// \brief This class represents a statement that can be either executed or queried for result
  210. ///
  211. class CPPDB_API statement : public ref_counted {
  212. public:
  213. // Begin of API
  214. ///
  215. /// Reset the prepared statement to initial state as before the operation. It is
  216. /// called by front-end each time before new query() or exec() are called.
  217. ///
  218. virtual void reset() = 0;
  219. ///
  220. /// Get the query the statement works with. Return it as is, used as key for statement
  221. /// caching
  222. ///
  223. virtual std::string const &sql_query() = 0;
  224. ///
  225. /// Bind a text value to column \a col (starting from 1). You may assume
  226. /// that the reference remains valid until real call of query() or exec()
  227. ///
  228. /// Should throw invalid_placeholder() if the value of col is out of range. May
  229. /// ignore if it is impossible to know whether the placeholder exists without special
  230. /// support from back-end.
  231. ///
  232. virtual void bind(int col,std::string const &) = 0;
  233. ///
  234. /// Bind a text value to column \a col (starting from 1). You may assume
  235. /// that the reference remains valid until real call of query() or exec()
  236. ///
  237. /// Should throw invalid_placeholder() if the value of col is out of range. May
  238. /// ignore if it is impossible to know whether the placeholder exists without special
  239. /// support from back-end.
  240. ///
  241. virtual void bind(int col,char const *s) = 0;
  242. ///
  243. /// Bind a text value to column \a col (starting from 1). You may assume
  244. /// that the reference remains valid until real call of query() or exec()
  245. ///
  246. /// Should throw invalid_placeholder() if the value of col is out of range. May
  247. /// ignore if it is impossible to know whether the placeholder exists without special
  248. /// support from back-end.
  249. ///
  250. virtual void bind(int col,char const *b,char const *e) = 0;
  251. ///
  252. /// Bind a date-time value to column \a col (starting from 1).
  253. ///
  254. /// Should throw invalid_placeholder() if the value of col is out of range. May
  255. /// ignore if it is impossible to know whether the placeholder exists without special
  256. /// support from back-end.
  257. ///
  258. virtual void bind(int col,std::tm const &) = 0;
  259. ///
  260. /// Bind a BLOB value to column \a col (starting from 1).
  261. ///
  262. /// Should throw invalid_placeholder() if the value of col is out of range. May
  263. /// ignore if it is impossible to know whether the placeholder exists without special
  264. /// support from back-end.
  265. ///
  266. virtual void bind(int col,std::istream &) = 0;
  267. ///
  268. /// Bind an integer value to column \a col (starting from 1).
  269. ///
  270. /// Should throw invalid_placeholder() if the value of col is out of range. May
  271. /// ignore if it is impossible to know whether the placeholder exists without special
  272. /// support from back-end.
  273. ///
  274. virtual void bind(int col,int v) = 0;
  275. ///
  276. /// Bind an integer value to column \a col (starting from 1).
  277. ///
  278. /// Should throw invalid_placeholder() if the value of col is out of range. May
  279. /// ignore if it is impossible to know whether the placeholder exists without special
  280. /// support from back-end.
  281. ///
  282. /// May throw bad_value_cast() if the value out of supported range by the DB.
  283. ///
  284. virtual void bind(int col,unsigned v) = 0;
  285. ///
  286. /// Bind an integer value to column \a col (starting from 1).
  287. ///
  288. /// Should throw invalid_placeholder() if the value of col is out of range. May
  289. /// ignore if it is impossible to know whether the placeholder exists without special
  290. /// support from back-end.
  291. ///
  292. /// May throw bad_value_cast() if the value out of supported range by the DB.
  293. ///
  294. virtual void bind(int col,long v) = 0;
  295. ///
  296. /// Bind an integer value to column \a col (starting from 1).
  297. ///
  298. /// Should throw invalid_placeholder() if the value of col is out of range. May
  299. /// ignore if it is impossible to know whether the placeholder exists without special
  300. /// support from back-end.
  301. ///
  302. /// May throw bad_value_cast() if the value out of supported range by the DB.
  303. ///
  304. virtual void bind(int col,unsigned long v) = 0;
  305. ///
  306. /// Bind an integer value to column \a col (starting from 1).
  307. ///
  308. /// Should throw invalid_placeholder() if the value of col is out of range. May
  309. /// ignore if it is impossible to know whether the placeholder exists without special
  310. /// support from back-end.
  311. ///
  312. /// May throw bad_value_cast() if the value out of supported range by the DB.
  313. ///
  314. virtual void bind(int col,long long v) = 0;
  315. ///
  316. /// Bind an integer value to column \a col (starting from 1).
  317. ///
  318. /// Should throw invalid_placeholder() if the value of col is out of range. May
  319. /// ignore if it is impossible to know whether the placeholder exists without special
  320. /// support from back-end.
  321. ///
  322. /// May throw bad_value_cast() if the value out of supported range by the DB.
  323. ///
  324. virtual void bind(int col,unsigned long long v) = 0;
  325. ///
  326. /// Bind a floating point value to column \a col (starting from 1).
  327. ///
  328. /// Should throw invalid_placeholder() if the value of col is out of range. May
  329. /// ignore if it is impossible to know whether the placeholder exists without special
  330. /// support from back-end.
  331. ///
  332. virtual void bind(int col,double v) = 0;
  333. ///
  334. /// Bind a floating point value to column \a col (starting from 1).
  335. ///
  336. /// Should throw invalid_placeholder() if the value of col is out of range. May
  337. /// ignore if it is impossible to know whether the placeholder exists without special
  338. /// support from back-end.
  339. ///
  340. virtual void bind(int col,long double v) = 0;
  341. ///
  342. /// Bind a NULL value to column \a col (starting from 1).
  343. ///
  344. /// Should throw invalid_placeholder() if the value of col is out of range. May
  345. /// ignore if it is impossible to know whether the placeholder exists without special
  346. /// support from back-end.
  347. ///
  348. virtual void bind_null(int col) = 0;
  349. ///
  350. /// Fetch the last sequence generated for last inserted row. May use sequence as parameter
  351. /// if the database uses sequences, should ignore the parameter \a sequence if the last
  352. /// id is fetched without parameter.
  353. ///
  354. /// Should be called after exec() for insert statement, otherwise the behavior is undefined.
  355. ///
  356. /// MUST throw not_supported_by_backend() if such option is not supported by the DB engine.
  357. ///
  358. virtual long long sequence_last(std::string const &sequence) = 0;
  359. ///
  360. /// Return the number of affected rows by last statement.
  361. ///
  362. /// Should be called after exec(), otherwise behavior is undefined.
  363. ///
  364. virtual unsigned long long affected() = 0;
  365. ///
  366. /// Return SQL Query result, MAY throw cppdb_error if the statement is not a query
  367. ///
  368. virtual result *query() = 0;
  369. ///
  370. /// Execute a statement, MAY throw cppdb_error if the statement returns results.
  371. ///
  372. virtual void exec() = 0;
  373. /// \cond INTERNAL
  374. // Caching support
  375. static void dispose(statement *selfp);
  376. void cache(statements_cache *c);
  377. statement();
  378. virtual ~statement() ;
  379. /// \endcond
  380. private:
  381. struct data;
  382. std::unique_ptr<data> d;
  383. statements_cache *cache_;
  384. };
  385. /// \cond INTERNAL
  386. class CPPDB_API statements_cache {
  387. statements_cache(statements_cache const &);
  388. void operator=(statements_cache const &);
  389. public:
  390. statements_cache();
  391. bool active();
  392. void set_size(size_t n);
  393. void put(statement *p_in);
  394. void clear();
  395. ref_ptr<statement> fetch(std::string const &q);
  396. ~statements_cache();
  397. private:
  398. struct data;
  399. std::unique_ptr<data> d;
  400. };
  401. /// \endcond
  402. class connection;
  403. ///
  404. /// \brief This class represents a driver that creates connections for
  405. /// given connection string, custom drivers can be are installed using this
  406. /// class
  407. ///
  408. class CPPDB_API driver : public ref_counted {
  409. driver(driver const &);
  410. void operator=(driver const &);
  411. public:
  412. driver() {}
  413. virtual ~driver() {}
  414. ///
  415. /// Return true if the driver in use (i.e. if there is any open connection exist (connection object)
  416. /// so it can't be removed from the driver
  417. ///
  418. virtual bool in_use() = 0;
  419. ///
  420. /// Create a connection object - should be implemented by driver
  421. ///
  422. virtual connection *open(connection_info const &cs) = 0;
  423. ///
  424. /// Create a connection object, generally calls open() but may add some information (as registering objects)
  425. /// and unregistering them
  426. ///
  427. virtual connection *connect(connection_info const &cs);
  428. };
  429. ///
  430. /// \brief This class represents a driver that can be unloaded from the driver_manager.
  431. ///
  432. class CPPDB_API loadable_driver : public driver {
  433. loadable_driver(loadable_driver const &);
  434. void operator=(loadable_driver const &);
  435. public:
  436. loadable_driver() {}
  437. ///
  438. /// Returns true if any of generated connections still exits
  439. ///
  440. virtual bool in_use();
  441. virtual ~loadable_driver() {}
  442. ///
  443. /// Creates a new connection object and keeps track of them for handing (in_use) correctly
  444. ///
  445. virtual connection *connect(connection_info const &cs);
  446. };
  447. extern "C" {
  448. ///
  449. /// This function type is the function that is generally resolved from the shared objects when loaded
  450. ///
  451. typedef cppdb::backend::connection *cppdb_backend_connect_function(connection_info const &ci);
  452. }
  453. ///
  454. /// \brief Create a static driver using connection function (usable for statically linking drivers).
  455. ///
  456. class CPPDB_API static_driver : public driver {
  457. public:
  458. ///
  459. /// Typedef of the function pointer that is used for creation of connection objects.
  460. ///
  461. typedef cppdb_backend_connect_function *connect_function_type;
  462. ///
  463. /// Create a new driver that creates connection using function \a c
  464. ///
  465. static_driver(connect_function_type c);
  466. ~static_driver();
  467. ///
  468. /// Always returns true as this driver cannot be unloaded
  469. ///
  470. bool in_use();
  471. ///
  472. /// Create new connection - basically calls the function to create the object
  473. ///
  474. backend::connection *open(connection_info const &ci);
  475. private:
  476. connect_function_type connect_;
  477. };
  478. ///
  479. /// \brief this class represents connection to database
  480. ///
  481. class CPPDB_API connection : public ref_counted {
  482. public:
  483. ///
  484. /// Create a new object. Connection information \a info is required
  485. ///
  486. connection(connection_info const &info);
  487. virtual ~connection();
  488. /// \cond INTERNAL
  489. void set_pool(ref_ptr<pool> p);
  490. ref_ptr<pool> get_pool();
  491. void set_driver(ref_ptr<loadable_driver> drv);
  492. static void dispose(connection *c);
  493. ref_ptr<statement> prepare(std::string const &q);
  494. ref_ptr<statement> get_prepared_statement(std::string const &q);
  495. ref_ptr<statement> get_prepared_uncached_statement(std::string const &q);
  496. ref_ptr<statement> get_statement(std::string const &q);
  497. /// \endcond
  498. // API
  499. ///
  500. /// Start new isolated transaction. Would not be called
  501. /// withing other transaction on current connection.
  502. ///
  503. virtual void begin() = 0;
  504. ///
  505. /// Commit the transaction, you may assume that is called after begin()
  506. /// was called.
  507. ///
  508. virtual void commit() = 0;
  509. ///
  510. /// Rollback the transaction. MUST never throw!!!
  511. ///
  512. virtual void rollback() = 0;
  513. ///
  514. /// Create a prepared statement \a q. May throw if preparation had failed.
  515. /// Should never return null value.
  516. ///
  517. virtual statement *prepare_statement(std::string const &q) = 0;
  518. ///
  519. /// Create a (unprepared) statement \a q. May throw if preparation had failed.
  520. /// Should never return null value.
  521. ///
  522. virtual statement *create_statement(std::string const &q) = 0;
  523. ///
  524. /// Escape a string for inclusion in SQL query. May throw not_supported_by_backend() if not supported by backend.
  525. ///
  526. virtual std::string escape(std::string const &) = 0;
  527. ///
  528. /// Escape a string for inclusion in SQL query. May throw not_supported_by_backend() if not supported by backend.
  529. ///
  530. virtual std::string escape(char const *s) = 0;
  531. ///
  532. /// Escape a string for inclusion in SQL query. May throw not_supported_by_backend() if not supported by backend.
  533. ///
  534. virtual std::string escape(char const *b,char const *e) = 0;
  535. ///
  536. /// Get the name of the driver, for example sqlite3, odbc
  537. ///
  538. virtual std::string driver() = 0;
  539. ///
  540. /// Get the name of the SQL Server, for example sqlite3, mssql, oracle, differs from driver() when
  541. /// the backend supports multiple databases like odbc backend.
  542. ///
  543. virtual std::string engine() = 0;
  544. ///
  545. /// Clear statements cache
  546. ///
  547. void clear_cache();
  548. ///
  549. /// Check if session specific preparations are done
  550. ///
  551. /// For new connections always false
  552. ///
  553. bool once_called() const;
  554. ///
  555. /// Set once status - true if called flase
  556. ///
  557. void once_called(bool v);
  558. ///
  559. /// Get connection specific data pointer of the type \a type , default 0.
  560. ///
  561. /// The ownership is not changed
  562. ///
  563. connection_specific_data *connection_specific_get(std::type_info const &type) const;
  564. ///
  565. /// Release ownership connection specific data pointer of the type \a type
  566. ///
  567. connection_specific_data *connection_specific_release(std::type_info const &type);
  568. ///
  569. /// Remove old connection specific data and set new one for a given
  570. /// type \a type , the ownership on \a p is transferred to connection.
  571. ///
  572. void connection_specific_reset(std::type_info const &type,connection_specific_data *p = 0);
  573. ///
  574. /// Check if this back-end can be recycled for reuse in a pool.
  575. ///
  576. /// If an exception is thrown during operation on DB this flag is reset
  577. /// to false by the front-end classes result, statement, session.
  578. ///
  579. /// Default is true
  580. ///
  581. bool recyclable();
  582. ///
  583. /// Set recyclable state of the session. If some problem occurs on connection
  584. /// that prevents its reuse it should be called with false parameter.
  585. ///
  586. void recyclable(bool value);
  587. private:
  588. struct data;
  589. std::unique_ptr<data> d;
  590. statements_cache cache_;
  591. ref_ptr<loadable_driver> driver_;
  592. ref_ptr<pool> pool_;
  593. unsigned default_is_prepared_ : 1;
  594. unsigned once_called_ : 1;
  595. unsigned recyclable_ : 1;
  596. unsigned reserverd_ : 29;
  597. };
  598. } // backend
  599. } // cppdb
  600. #endif