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

Proposed by Vlad Lesin
Status: Merged
Approved by: Stewart Smith
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) Approve
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.
Revision history for this message
Stewart Smith (stewart) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'percona_playback/db_thread.cc'
--- percona_playback/db_thread.cc 2012-06-22 06:20:44 +0000
+++ percona_playback/db_thread.cc 2012-11-14 22:02:21 +0000
@@ -16,14 +16,28 @@
16#include "config.h"16#include "config.h"
1717
18#include <percona_playback/db_thread.h>18#include <percona_playback/db_thread.h>
19#include "percona_playback/query_result.h"
1920
20#include <assert.h>21#include <assert.h>
2122
22#include <boost/bind.hpp>23#include <boost/bind.hpp>
2324
25extern std::string g_session_init_query;
26
27void DBThread::connect_and_init_session()
28{
29 connect();
30 if (!g_session_init_query.empty())
31 {
32 QueryResult r;
33 QueryResult er;
34 execute_query(g_session_init_query, &r, er);
35 }
36}
37
24void DBThread::run()38void DBThread::run()
25{39{
26 connect();40 connect_and_init_session();
2741
28 QueryEntryPtr query;42 QueryEntryPtr query;
29 while (true)43 while (true)
@@ -36,7 +50,7 @@
36 if (query->is_quit())50 if (query->is_quit())
37 {51 {
38 disconnect();52 disconnect();
39 connect();53 connect_and_init_session();
40 continue;54 continue;
41 }55 }
4256
4357
=== modified file 'percona_playback/db_thread.h'
--- percona_playback/db_thread.h 2012-07-04 10:06:05 +0000
+++ percona_playback/db_thread.h 2012-11-14 22:02:21 +0000
@@ -72,6 +72,8 @@
72 thread.join();72 thread.join();
73 }73 }
7474
75 void connect_and_init_session();
76
75 virtual void connect()= 0;77 virtual void connect()= 0;
7678
77 virtual void disconnect()= 0;79 virtual void disconnect()= 0;
7880
=== modified file 'percona_playback/percona_playback.cc'
--- percona_playback/percona_playback.cc 2012-07-05 07:37:39 +0000
+++ percona_playback/percona_playback.cc 2012-11-14 22:02:21 +0000
@@ -41,6 +41,7 @@
41percona_playback::DBClientPlugin *g_dbclient_plugin= NULL;41percona_playback::DBClientPlugin *g_dbclient_plugin= NULL;
42percona_playback::InputPlugin *g_input_plugin= NULL;42percona_playback::InputPlugin *g_input_plugin= NULL;
43unsigned int g_db_thread_queue_depth;43unsigned int g_db_thread_queue_depth;
44std::string g_session_init_query;
4445
45using namespace percona_playback;46using namespace percona_playback;
4647
@@ -155,6 +156,9 @@
155 _("Queue depth for DB executor (thread). The larger this number the"156 _("Queue depth for DB executor (thread). The larger this number the"
156 " greater the played-back workload can deviate from the original workload"157 " greater the played-back workload can deviate from the original workload"
157 " as some connections may be up to queue-depth behind. (default 1)"))158 " as some connections may be up to queue-depth behind. (default 1)"))
159 ("session-init-query",
160 po::value<std::string>()->default_value(""),
161 _("This query will be executed just after each connect to db"))
158 ;162 ;
159163
160 std::string basic_usage;164 std::string basic_usage;

Subscribers

People subscribed via source and target branches

to all changes: