| 253 | } |
| 254 | |
| 255 | statement_backend::exec_fetch_result |
| 256 | postgresql_statement_backend::execute(int number) |
| 257 | { |
| 258 | if (single_row_mode_ && (number > 1)) |
| 259 | { |
| 260 | throw soci_error("Bulk operations are not supported with single-row mode."); |
| 261 | } |
| 262 | |
| 263 | // If the statement was "just described", then we know that |
| 264 | // it was actually executed with all the use elements |
| 265 | // already bound and pre-used. This means that the result of the |
| 266 | // query is already on the client side, so there is no need |
| 267 | // to re-execute it. |
| 268 | // The optimization based on the existing results |
| 269 | // from the row description can be performed only once. |
| 270 | // If the same statement is re-executed, |
| 271 | // it will be *really* re-executed, without reusing existing data. |
| 272 | |
| 273 | if (justDescribed_ == false) |
| 274 | { |
| 275 | // This object could have been already filled with data before. |
| 276 | clean_up(); |
| 277 | |
| 278 | if ((number > 1) && hasIntoElements_) |
| 279 | { |
| 280 | throw soci_error( |
| 281 | "Bulk use with single into elements is not supported."); |
| 282 | } |
| 283 | |
| 284 | // Since the bulk operations are not natively supported by postgresql_, |
| 285 | // we have to explicitly loop to achieve the bulk operations. |
| 286 | // On the other hand, looping is not needed if there are single |
| 287 | // use elements, even if there is a bulk fetch. |
| 288 | // We know that single use and bulk use elements in the same query are |
| 289 | // not supported anyway, so in the effect the 'number' parameter here |
| 290 | // specifies the size of vectors (into/use), but 'numberOfExecutions' |
| 291 | // specifies the number of loops that need to be performed. |
| 292 | |
| 293 | int numberOfExecutions = 1; |
| 294 | if (number > 0) |
| 295 | { |
| 296 | numberOfExecutions = hasUseElements_ ? 1 : number; |
| 297 | } |
| 298 | |
| 299 | if ((useByPosBuffers_.empty() == false) || |
| 300 | (useByNameBuffers_.empty() == false)) |
| 301 | { |
| 302 | if ((useByPosBuffers_.empty() == false) && |
| 303 | (useByNameBuffers_.empty() == false)) |
| 304 | { |
| 305 | throw soci_error( |
| 306 | "Binding for use elements must be either by position " |
| 307 | "or by name."); |
| 308 | } |
| 309 | |
| 310 | rowsAffectedBulk_ = 0; |
| 311 | for (current_row_ = 0; current_row_ != numberOfExecutions; ++current_row_) |
| 312 | { |
nothing calls this directly
no test coverage detected