@@ -134,6 +134,79 @@ session::session(connection_pool & pool)
134
134
backEnd_ = pooledSession.get_backend ();
135
135
}
136
136
137
+ session::session (session && other)
138
+ : once(std::move(other.once)),
139
+ prepare(std::move(other.prepare)),
140
+ query_stream_(std::move(other.query_stream_)),
141
+ query_transformation_(std::move(other.query_transformation_)),
142
+ logger_(std::move(other.logger_)),
143
+ lastConnectParameters_(std::move(other.lastConnectParameters_)),
144
+ uppercaseColumnNames_(std::move(other.uppercaseColumnNames_)),
145
+ backEnd_(std::move(other.backEnd_)),
146
+ gotData_(std::move(other.gotData_)),
147
+ isFromPool_(std::move(other.isFromPool_)),
148
+ poolPosition_(std::move(other.poolPosition_)),
149
+ pool_(std::move(other.pool_))
150
+ {
151
+ if (!isFromPool_)
152
+ {
153
+ // If 'other' session was from a pool, 'once' and 'prepare'
154
+ // will have been already setup to point at the pooled session above.
155
+ // Otherwise reset them to reference 'this'.
156
+ once.set_session (this );
157
+ prepare.set_session (this );
158
+ }
159
+
160
+ other.reset_after_move ();
161
+ }
162
+
163
+ session& session::operator =(session && other)
164
+ {
165
+ if (this != &other)
166
+ {
167
+ if (isFromPool_)
168
+ {
169
+ pool_->give_back (poolPosition_);
170
+ }
171
+ else if (backEnd_ != other.backEnd_ )
172
+ {
173
+ delete backEnd_;
174
+ }
175
+
176
+ if (other.isFromPool_ )
177
+ {
178
+ // If 'other' session was from a pool, 'once' and 'prepare'
179
+ // will have been already setup reference the pooled session above.
180
+ // Otherwise leave them alone and let them continue referencing 'this'.
181
+ once = std::move (other.once );
182
+ prepare = std::move (other.prepare );
183
+ }
184
+
185
+ query_stream_ = std::move (other.query_stream_ );
186
+ query_transformation_ = std::move (other.query_transformation_ );
187
+ logger_ = std::move (other.logger_ );
188
+ lastConnectParameters_ = std::move (other.lastConnectParameters_ );
189
+ uppercaseColumnNames_ = std::move (other.uppercaseColumnNames_ );
190
+ backEnd_ = std::move (other.backEnd_ );
191
+ gotData_ = std::move (other.gotData_ );
192
+ isFromPool_ = std::move (other.isFromPool_ );
193
+ poolPosition_ = std::move (other.poolPosition_ );
194
+ pool_ = std::move (other.pool_ );
195
+
196
+ other.reset_after_move ();
197
+ }
198
+
199
+ return *this ;
200
+ }
201
+
202
+ void session::reset_after_move ()
203
+ {
204
+ isFromPool_ = false ;
205
+ pool_ = nullptr ;
206
+ backEnd_ = nullptr ;
207
+ pool_ = nullptr ;
208
+ }
209
+
137
210
session::~session ()
138
211
{
139
212
if (isFromPool_)
0 commit comments