~fboranek/mariadb++/vs10

« back to all changes in this revision

Viewing changes to include/mariadb++/connection.hpp

  • Committer: Frantisek Boranek
  • Date: 2015-01-16 17:43:53 UTC
  • Revision ID: fboranek@atlas.cz-20150116174353-bcozr7536mymemz4
- fixed hang in connection due not NULL paramet passed as local socket
- fixed memory leak in destruction of connection
- generating config file
- force to chose throwing exception during build 
- fixed compilatin by VS2010

error C2065: '__PRETTY_FUNCTION__' : undeclared identifier      src\statement.cpp       33
error C2872: 'time' : ambiguous symbol  src\statement.cpp       163
error C4430: missing type specifier - int assumed. Note: C++ does not support default-int       D:\Workspace\git.mailserver.8.5.X\connect\extLibs\mariadb++\src\statement.cpp   163     1
error C2143: syntax error : missing ',' before '&'  src\statement.cpp       163
error C2511: 'void mariadb::statement::set_time(mariadb::u32,const int)' : overloaded member function not found in 'mariadb::statement' src\statement.cpp       164
error C3861: 'round': identifier not found      src\decimal.cpp 25
error C2668: 'pow' : ambiguous call to overloaded function      src\decimal.cpp 32
error C2466: cannot allocate an array of constant size 0        src\decimal.cpp 32
error C2065: '__func__' : undeclared identifier src\date_time.cpp       144


src\bind.cpp(49): warning C4800: 'const my_bool' : forcing value to bool 'true' or 'false' (performance warning)
src\connection.cpp(238): warning C4244: '+=' : conversion from 'my_ulonglong' to 'mariadb::u32', possible loss of data
src\connection.cpp(269): warning C4244: 'return' : conversion from 'my_ulonglong' to 'mariadb::u32', possible loss of data
src\date_time.cpp(65): warning C4996: 'localtime': This function or variable may be unsafe. Consider using localtime_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
src\date_time.cpp(633): warning C4996: 'localtime': This function or variable may be unsafe. Consider using localtime_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
src\date_time.cpp(647): warning C4996: 'gmtime': This function or variable may be unsafe. Consider using gmtime_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
src\date_time.cpp(673): warning C4996: 'sprintf': This function or variable may be unsafe. Consider using sprintf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
src\date_time.cpp(675): warning C4996: 'sprintf': This function or variable may be unsafe. Consider using sprintf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
src\date_time.cpp(684): warning C4996: 'sprintf': This function or variable may be unsafe. Consider using sprintf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
src\date_time.cpp(493): warning C4244: 'initializing' : conversion from 'mariadb::s64' to 'mariadb::u32', possible loss of data
src\date_time.cpp(496): warning C4244: 'initializing' : conversion from 'mariadb::s64' to 'mariadb::u32', possible loss of data
src\date_time.cpp(499): warning C4244: 'initializing' : conversion from 'mariadb::s64' to 'mariadb::u32', possible loss of data
src\date_time.cpp(502): warning C4244: 'initializing' : conversion from 'mariadb::s64' to 'mariadb::u32', possible loss of data
src\date_time.cpp(586): warning C4244: 'argument' : conversion from 'mariadb::u16' to 'mariadb::u8', possible loss of data
src\date_time.cpp(658): warning C4244: 'initializing' : conversion from 'mariadb::u16' to 'mariadb::u8', possible loss of data
src\date_time.cpp(659): warning C4244: 'initializing' : conversion from 'mariadb::u16' to 'mariadb::u8', possible loss of data
src\decimal.cpp(173): warning C4244: 'argument' : conversion from 'mariadb::s64' to 'mariadb::u8', possible loss of data
src\result_set.cpp(264): warning C4800: 'mariadb::u64' : forcing value to bool 'true' or 'false' (performance warning)
src\result_set.cpp(272): warning C4244: 'return' : conversion from 'mariadb::u64' to 'mariadb::u8', possible loss of data
src\result_set.cpp(280): warning C4244: 'return' : conversion from 'mariadb::s64' to 'mariadb::s8', possible loss of data
src\result_set.cpp(288): warning C4244: 'return' : conversion from 'mariadb::u64' to 'mariadb::u16', possible loss of data
src\result_set.cpp(296): warning C4244: 'return' : conversion from 'mariadb::s64' to 'mariadb::s16', possible loss of data
src\result_set.cpp(304): warning C4244: 'return' : conversion from 'mariadb::u64' to 'mariadb::u32', possible loss of data
src\result_set.cpp(312): warning C4244: 'return' : conversion from 'mariadb::s64' to 'mariadb::s32', possible loss of data
src\save_point.cpp(33): warning C4996: 'sprintf': This function or variable may be unsafe. Consider using sprintf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
src\save_point.cpp(35): warning C4996: 'sprintf': This function or variable may be unsafe. Consider using sprintf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
src\save_point.cpp(49): warning C4996: 'sprintf': This function or variable may be unsafe. Consider using sprintf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
src\save_point.cpp(64): warning C4996: 'sprintf': This function or variable may be unsafe. Consider using sprintf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
src\statement.cpp(85): warning C4244: 'return' : conversion from 'my_ulonglong' to 'mariadb::s32', possible loss of data
src\statement.cpp(96): warning C4244: 'return' : conversion from 'my_ulonglong' to 'mariadb::u32', possible loss of data
src\statement.cpp(125): warning C4244: 'argument' : conversion from 'mariadb::u64' to 'unsigned long', possible loss of data
src\time.cpp(55): warning C4996: 'localtime': This function or variable may be unsafe. Consider using localtime_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
src\time.cpp(366): warning C4244: 'initializing' : conversion from 'mariadb::s64' to 'mariadb::u32', possible loss of data
src\time.cpp(369): warning C4244: 'initializing' : conversion from 'mariadb::s64' to 'mariadb::u32', possible loss of data
src\time.cpp(372): warning C4244: 'initializing' : conversion from 'mariadb::s64' to 'mariadb::u32', possible loss of data
src\time.cpp(375): warning C4244: 'argument' : conversion from 'mariadb::s64' to 'mariadb::u32', possible loss of data
src\time.cpp(419): warning C4996: 'localtime': This function or variable may be unsafe. Consider using localtime_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
src\time.cpp(427): warning C4996: 'gmtime': This function or variable may be unsafe. Consider using gmtime_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
src\time.cpp(438): warning C4244: 'initializing' : conversion from 'mariadb::u16' to 'mariadb::u8', possible loss of data
src\time.cpp(444): warning C4244: '=' : conversion from 'mariadb::u16' to 'mariadb::u8', possible loss of data
src\time.cpp(450): warning C4244: 'initializing' : conversion from 'double' to 'mariadb::u16', possible loss of data
src\time.cpp(460): warning C4996: 'sprintf': This function or variable may be unsafe. Consider using sprintf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
src\time.cpp(462): warning C4996: 'sprintf': This function or variable may be unsafe. Consider using sprintf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
//
2
 
//  M A R I A D B + +
3
 
//
4
 
//      Author   : Sylvain Rochette Langlois
5
 
//      License  : Boost Software License (http://www.boost.org/users/license.html)
6
 
//
7
 
 
8
 
#ifndef _MARIADB_CONNECTION_HPP_
9
 
#define _MARIADB_CONNECTION_HPP_
10
 
 
11
 
#include <string>
12
 
#include "account.hpp"
13
 
#include "statement.hpp"
14
 
#include "transaction.hpp"
15
 
#include "save_point.hpp"
16
 
#include "result_set.hpp"
17
 
 
18
 
//
19
 
// C++ wrapper over mariadb-native-client API
20
 
//
21
 
 
22
 
namespace mariadb
23
 
{
24
 
        class connection : public last_error
25
 
        {
26
 
                friend class result_set;
27
 
                friend class statement;
28
 
                friend class transaction;
29
 
                friend class save_point;
30
 
 
31
 
        public:
32
 
                //
33
 
                // Destructor
34
 
                //
35
 
                virtual ~connection();
36
 
 
37
 
                //
38
 
                // Connect to the database
39
 
                //
40
 
                bool connect();
41
 
 
42
 
                //
43
 
                // Disconnect from the database
44
 
                //
45
 
                void disconnect();
46
 
 
47
 
                //
48
 
                // Tell if a connection is currently active to the database
49
 
                //
50
 
                bool connected() const;
51
 
 
52
 
                //
53
 
                // Get account
54
 
                //
55
 
                account_ref account() const;
56
 
 
57
 
                //
58
 
                // Get / Set schema (database)
59
 
                //
60
 
                const char* schema() const;
61
 
                bool set_schema(const char* schema);
62
 
 
63
 
                //
64
 
                // Execute a query with or without statement
65
 
                //
66
 
                s32 execute(const char* query);
67
 
                u32 insert(const char* query);
68
 
                result_set_ref query(const char* query);
69
 
 
70
 
                //
71
 
                // Set auto commit mode
72
 
                //
73
 
                bool auto_commit() const;
74
 
                bool set_auto_commit(bool auto_commit);
75
 
 
76
 
        public:
77
 
                //
78
 
                // Create statement
79
 
                //
80
 
                statement_ref create_statement(const char* query);
81
 
 
82
 
                //
83
 
                // Commit / rollback support
84
 
                //
85
 
                transaction_ref create_transaction(isolation::level level = isolation::repeatable_read, bool consistent_snapshot = true);
86
 
 
87
 
        public:
88
 
                //
89
 
                // Create a new connection
90
 
                //
91
 
                static connection_ref create(account_ref& account);
92
 
 
93
 
        private:
94
 
                //
95
 
                // Constructor
96
 
                //
97
 
                connection(account_ref& account);
98
 
 
99
 
        private:
100
 
                bool        m_auto_commit;
101
 
                MYSQL*      m_mysql;
102
 
                std::string m_schema;
103
 
                account_ref m_account;
104
 
        };
105
 
}
106
 
 
107
 
#endif
 
1
//
 
2
//  M A R I A D B + +
 
3
//
 
4
//      Author   : Sylvain Rochette Langlois
 
5
//      License  : Boost Software License (http://www.boost.org/users/license.html)
 
6
//
 
7
 
 
8
#ifndef _MARIADB_CONNECTION_HPP_
 
9
#define _MARIADB_CONNECTION_HPP_
 
10
 
 
11
#include <string>
 
12
#include <mariadb++/account.hpp>
 
13
#include <mariadb++/statement.hpp>
 
14
#include <mariadb++/transaction.hpp>
 
15
#include <mariadb++/save_point.hpp>
 
16
#include <mariadb++/result_set.hpp>
 
17
 
 
18
struct st_mysql;
 
19
typedef struct st_mysql MYSQL;
 
20
 
 
21
//
 
22
// C++ wrapper over mariadb-native-client API
 
23
//
 
24
 
 
25
namespace mariadb
 
26
{
 
27
        class connection : public last_error
 
28
        {
 
29
                friend class result_set;
 
30
                friend class statement;
 
31
                friend class transaction;
 
32
                friend class save_point;
 
33
 
 
34
        public:
 
35
                //
 
36
                // Destructor
 
37
                //
 
38
                virtual ~connection();
 
39
 
 
40
                //
 
41
                // Connect to the database
 
42
                //
 
43
                bool connect();
 
44
 
 
45
                //
 
46
                // Disconnect from the database
 
47
                //
 
48
                void disconnect();
 
49
 
 
50
                //
 
51
                // Tell if a connection is currently active to the database
 
52
                //
 
53
                bool connected() const;
 
54
 
 
55
                //
 
56
                // Get account
 
57
                //
 
58
                account_ref account() const;
 
59
 
 
60
                //
 
61
                // Get / Set schema (database)
 
62
                //
 
63
                const char* schema() const;
 
64
                bool set_schema(const char* schema);
 
65
 
 
66
                //
 
67
                // Get / Set character set
 
68
                //
 
69
                const std::string& charset() const;
 
70
                bool set_charset(const std::string& value);
 
71
 
 
72
                //
 
73
                // Execute a query with or without statement
 
74
                //
 
75
                u64 execute(const std::string& query);
 
76
                u64 insert(const std::string& query);
 
77
                result_set_ref query(const std::string& query);
 
78
 
 
79
                //
 
80
                // Set auto commit mode
 
81
                //
 
82
                bool auto_commit() const;
 
83
                bool set_auto_commit(bool auto_commit);
 
84
 
 
85
        public:
 
86
                //
 
87
                // Create statement
 
88
                //
 
89
                statement_ref create_statement(const char* query);
 
90
 
 
91
                //
 
92
                // Commit / rollback support
 
93
                //
 
94
                transaction_ref create_transaction(isolation::level level = isolation::repeatable_read, bool consistent_snapshot = true);
 
95
 
 
96
        public:
 
97
                //
 
98
                // Create a new connection
 
99
                //
 
100
                static connection_ref create(account_ref& account);
 
101
 
 
102
        private:
 
103
                //
 
104
                // Constructor
 
105
                //
 
106
                connection(account_ref& account);
 
107
 
 
108
        private:
 
109
                bool        m_auto_commit;
 
110
                MYSQL*      m_mysql;
 
111
                std::string m_schema;
 
112
                std::string m_charset;
 
113
                account_ref m_account;
 
114
        };
 
115
}
 
116
 
 
117
#endif