Merge lp:~vlad-lesin/percona-playback/session_init_query into lp:percona-playback

Proposed by Vlad Lesin on 2012-11-14
Status: Merged
Approved by: Stewart Smith on 2012-11-15
Approved revision: 165
Merged at revision: 168
Proposed branch: lp:~vlad-lesin/percona-playback/session_init_query
Merge into: lp:percona-playback
Diff against target: 77 lines (+22/-2)
3 files modified
percona_playback/db_thread.cc (+16/-2)
percona_playback/db_thread.h (+2/-0)
percona_playback/percona_playback.cc (+4/-0)
To merge this branch: bzr merge lp:~vlad-lesin/percona-playback/session_init_query
Reviewer Review Type Date Requested Status
Stewart Smith (community) 2012-11-14 Approve on 2012-11-15
Review via email: mp+134374@code.launchpad.net

Description of the change

--session-init-query option is added. It allows to execute some query just after connection is established. This can be used for example to init some session variables.

This feature can not be tested with current testing system. That's why the test is absent.

To post a comment you must log in.
Stewart Smith (stewart) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'percona_playback/db_thread.cc'
2--- percona_playback/db_thread.cc 2012-06-22 06:20:44 +0000
3+++ percona_playback/db_thread.cc 2012-11-14 22:02:21 +0000
4@@ -16,14 +16,28 @@
5 #include "config.h"
6
7 #include <percona_playback/db_thread.h>
8+#include "percona_playback/query_result.h"
9
10 #include <assert.h>
11
12 #include <boost/bind.hpp>
13
14+extern std::string g_session_init_query;
15+
16+void DBThread::connect_and_init_session()
17+{
18+ connect();
19+ if (!g_session_init_query.empty())
20+ {
21+ QueryResult r;
22+ QueryResult er;
23+ execute_query(g_session_init_query, &r, er);
24+ }
25+}
26+
27 void DBThread::run()
28 {
29- connect();
30+ connect_and_init_session();
31
32 QueryEntryPtr query;
33 while (true)
34@@ -36,7 +50,7 @@
35 if (query->is_quit())
36 {
37 disconnect();
38- connect();
39+ connect_and_init_session();
40 continue;
41 }
42
43
44=== modified file 'percona_playback/db_thread.h'
45--- percona_playback/db_thread.h 2012-07-04 10:06:05 +0000
46+++ percona_playback/db_thread.h 2012-11-14 22:02:21 +0000
47@@ -72,6 +72,8 @@
48 thread.join();
49 }
50
51+ void connect_and_init_session();
52+
53 virtual void connect()= 0;
54
55 virtual void disconnect()= 0;
56
57=== modified file 'percona_playback/percona_playback.cc'
58--- percona_playback/percona_playback.cc 2012-07-05 07:37:39 +0000
59+++ percona_playback/percona_playback.cc 2012-11-14 22:02:21 +0000
60@@ -41,6 +41,7 @@
61 percona_playback::DBClientPlugin *g_dbclient_plugin= NULL;
62 percona_playback::InputPlugin *g_input_plugin= NULL;
63 unsigned int g_db_thread_queue_depth;
64+std::string g_session_init_query;
65
66 using namespace percona_playback;
67
68@@ -155,6 +156,9 @@
69 _("Queue depth for DB executor (thread). The larger this number the"
70 " greater the played-back workload can deviate from the original workload"
71 " as some connections may be up to queue-depth behind. (default 1)"))
72+ ("session-init-query",
73+ po::value<std::string>()->default_value(""),
74+ _("This query will be executed just after each connect to db"))
75 ;
76
77 std::string basic_usage;

Subscribers

People subscribed via source and target branches

to all changes: