MySQL 26.7.0
Source Code Documentation
mysql_statement_service.h
Go to the documentation of this file.
1/* Copyright (c) 2023, 2026, Oracle and/or its affiliates.
2
3This program is free software; you can redistribute it and/or modify
4it under the terms of the GNU General Public License, version 2.0,
5as published by the Free Software Foundation.
6
7This program is designed to work with certain software (including
8but not limited to OpenSSL) that is licensed under separate terms,
9as designated in a particular file or component or in included license
10documentation. The authors of MySQL hereby grant you an additional
11permission to link the program and your derivative works with the
12separately licensed software that they have either included with
13the program or referenced in the documentation.
14
15This program is distributed in the hope that it will be useful,
16but WITHOUT ANY WARRANTY; without even the implied warranty of
17MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18GNU General Public License, version 2.0, for more details.
19
20You should have received a copy of the GNU General Public License
21along with this program; if not, write to the Free Software
22Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
23
24#ifndef MYSQL_STATEMENT_SERVICE_H
25#define MYSQL_STATEMENT_SERVICE_H
26
28#include <stddef.h>
29#include <stdint.h>
34
39
40/**
41 * @note Users of the service can set the expected charset e.g
42 * SERVICE_PLACEHOLDER(mysql_stmt_attributes)->set("charset_name", "utf8mb4");
43 * The service expects all the input strings to be in this charset and all the
44 * output strings from the service will be in this charset.
45 *
46 */
47
48// clang-format off
49/**
50 @ingroup group_components_services_inventory
51
52 A service that provides the API to create, and deallocate a
53 statement. The statement can be either a regular or a prepared statement.
54
55 Usage example for prepared statement:
56 my_h_statement statement = nullptr;
57 SERVICE_PLACEHOLDER(mysql_stmt_factory)->init(&statement);
58
59 SERVICE_PLACEHOLDER(mysql_stmt_attributes)->set("charset_name", "utf8mb4");
60
61 SERVICE_PLACEHOLDER(mysql_stmt_execute)->prepare("SELECT * FROM ?", statement);
62
63 uint32_t parameter_count;
64 SERVICE_PLACEHOLDER(mysql_stmt_metadata)->param_count(statement, &parameter_count);
65
66 // For first parameter
67 SERVICE_PLACEHOLDER(mysql_stmt_bind)->bind_param(statement, 0, false,
68 MYSQL_SP_ARG_TYPE_LONG,
69 false, 4, 1, nullptr, 0);
70
71 SERVICE_PLACEHOLDER(mysql_stmt_execute)->execute(statement)
72
73 my_h_row row = nullptr;
74 SERVICE_PLACEHOLDER(mysql_stmt_result)->fetch(statement, &row);
75 SERVICE_PLACEHOLDER(mysql_stmt_factory)->close(statement)
76
77 Usage example for regular statement:
78 my_h_statement statement = nullptr;
79 SERVICE_PLACEHOLDER(mysql_stmt_factory)->init(&statement);
80
81 SERVICE_PLACEHOLDER(mysql_stmt_attributes)->set("charset_name", "utf8mb4");
82
83 SERVICE_PLACEHOLDER(mysql_stmt_execute_direct)->execute("SELECT * FROM my_table", statement);
84
85 my_h_row row = nullptr;
86 SERVICE_PLACEHOLDER(mysql_stmt_result)->fetch(statement, &row);
87 SERVICE_PLACEHOLDER(mysql_stmt_factory)->close(statement)
88 */
89
90// clang-format on
91
92BEGIN_SERVICE_DEFINITION(mysql_stmt_factory)
93/**
94 @brief Construct a new statement object.
95
96 @note if the statement already exists, it is overwritten.
97
98 @param [out] statement A handle to the statement
99 @return Status of the performed operation
100 @retval false success
101 @retval true failure
102 */
104
105/**
106 @brief Close and clean up resource related to a statement.
107
108 @param [in] statement A handle to the statement
109 @return Status of the performed operation
110 @retval false success
111 @retval true failure
112 */
114END_SERVICE_DEFINITION(mysql_stmt_factory)
115
116/**
117 @ingroup group_components_services_inventory
118
119 A service that provides the API to execute prepared statements.
120
121 Usage example:
122 // Prepare a statement
123 my_h_statement statement = nullptr;
124 SERVICE_PLACEHOLDER(mysql_stmt_factory)->init(&statement);
125 SERVICE_PLACEHOLDER(mysql_stmt_execute)->prepare("SELECT * FROM my_table WHERE
126 col_c = ?", statement)
127 SERVICE_PLACEHOLDER(mysql_stmt_bind)->bind_param(statement, 0, false,
128 MYSQL_SP_ARG_TYPE_LONG,
129 false, 4, 1, nullptr, 0);
130
131 // To reset the parameter to bind it with new values
132 SERVICE_PLACEHOLDER(mysql_stmt_execute)->reset(statement)
133
134 // Execute the statement
135 SERVICE_PLACEHOLDER(mysql_stmt_execute)->execute(statement)
136
137
138*/
140/**
141 @brief Execute the prepared statement.
142
143 @note Execute will fail if all parameters are not bound.
144 @note To execute regular statement, use mysql_stmt_execute_direct::execute
145 instead.
146
147 @param [in] statement A handle to the statement
148 @return Status of the performed operation
149 @retval false success
150 @retval true failure
151 */
153
154/**
155 @brief Prepare the statement with the query.
156
157 @note Re-preparation is not allowed after the statement has been created. To
158 prepare a new query, create a new statement instead.
159 @note Calling this on regular statements would fail.
160
161 @param [in] query The query string to be prepared
162 @param [in] statement A handle to the statement
163 @return Status of the performed operation
164 @retval false success
165 @retval true failure
166 */
169
170/**
171 @brief For prepared statements, calling reset would reset the binding
172 parameters, close the cursor if one is open and frees the result sets.
173 For regular statements, calling reset is not supported. To close
174 and clean up the statement, use mysql_stmt_factory::close.
175
176 @note For prepared statements, the statement still exists, only the result
177 sets are destroyed.
178 @note Calling this on regular statements would fail.
179
180 @param [in] statement A handle to the statement
181 @return Status of the performed operation
182 @retval false success
183 @retval true failure
184 */
186
188
189BEGIN_SERVICE_DEFINITION(mysql_stmt_execute_direct)
190/**
191 @brief Execute the regular statement with the specified query using execute
192 direct.
193
194 @param [in] query The query string to be executed
195 @param [in] statement A handle to the statement
196 @return Status of the performed operation
197 @retval false success
198 @retval true failure
199 */
202END_SERVICE_DEFINITION(mysql_stmt_execute_direct)
203
204// clang-format off
205/**
206 @ingroup group_components_services_inventory
207
208 A service that provides the API to bind the parameters in prepared statements.
209
210 Usage example:
211
212 // For first parameter
213 SERVICE_PLACEHOLDER(mysql_stmt_bind)->bind_param(statement, 0, false,
214 MYSQL_SP_ARG_TYPE_LONG,
215 false, 4, 1, nullptr, 0);
216
217*/
218
219// clang-format on
221/**
222 @brief Bind a parameter
223
224 @note Calling bind with regular statements results in failure.
225 @note Bound values are cached. To update only some parameters, call bind on
226 these, the rest will use the cached values.
227 @note Calling bind with the same index multiple times, only the last value is
228 kept.
229 @note The type argument uses the statement-service MYSQL_SP_ARG_TYPE_* domain,
230 not raw MYSQL_TYPE_* or MYSQL_FIELD_TYPE_* values.
231
232 @param [in] statement A handle to the statement
233 @param [in] index 0-based index of the parameter to be bound
234 @param [in] is_null Whether the parameter can be null
235 @param [in] type Type of the parameter. Must be a MYSQL_SP_ARG_TYPE_* value.
236 @param [in] bool Whether the value is unsigned
237 @param [in] data The data argument is the value for the member
238 @param [in] data_length Length of the data
239 @param [in] name Name of the parameter
240 @param [in] name_length Name length of the parameter
241 @return Status of the performed operation
242 @retval false success
243 @retval true failure
244
245 */
247 bool is_null, uint64_t type, bool is_unsigned,
248 const void *data, unsigned long data_length,
249 const char *name, unsigned long name_length));
250
252
253// clang-format off
254/**
255 @ingroup group_components_services_inventory
256
257 A service that provides the API to manage and get info about a result set including fetch row(s)
258 from a result set, get next result set. A result set contains the result of an execution.
259 It is a list of rows, each row is a list of values where each value corresponds to a column.
260
261 Usage example:
262 // Iterate over the rows in a result set for result set with data (num_fields != 0)
263 // For in-depth example, check test_execute_prepared_statement.cc and test_execute_regular_statement.cc
264 my_h_row row = nullptr;
265 do {
266 SERVICE_PLACEHOLDER(mysql_stmt_result)->fetch(statement, &row);
267 if (row == nullptr) {
268 break;
269 }
270 // Get data from a row using row services
271 } while (true)
272
273 // Iterate over result sets
274 auto has_next_result_set = bool{};
275 do {
276 SERVICE_PLACEHOLDER(mysql_stmt_result)->next_result(statement, &has_next_result_set);
277 } while(has_next_result_set);
278
279 */
280// clang-format on
281
282BEGIN_SERVICE_DEFINITION(mysql_stmt_result)
283
284/**
285 @brief Check if there is more result set and move to next result set if there
286 is.
287
288 @param [in] statement A handle to the statement
289 @param [out] has_next Whether there is more result set
290 @return Status of the performed operation
291 @retval false success
292 @retval true failure
293 */
294DECLARE_BOOL_METHOD(next_result, (my_h_statement statement, bool *has_next));
295
296/**
297 @brief Fetch one row from the current result set
298
299 @note If there is no more rows, the returned row handle will be a nullptr.
300 This is not considered a failure case.
301
302 @param [in] statement A handle to the statement
303 @param [out] row The row handle
304 @return Status of the performed operation
305 @retval false success if there is no error in fetching the row including no
306 more rows.
307 @retval true failure in case of any error in fetching the row
308 */
310
311END_SERVICE_DEFINITION(mysql_stmt_result)
312
313// clang-format off
314/**
315 @ingroup group_components_services_inventory
316
317 A service that provides the API to get the errors and warnings including
318 fetching the warning, getting error/warning number, error/warning level,
319 error/warning message, SQL state. In addition, for INSERT/UPDATE/DELETE,
320 the service provides the API to get the number of affected rows and
321 last insert ID.
322
323 Usage example:
324 // For INSERT/UPDATE/DELETE/... statements, to get the number of affected rows
325 // and last insert id.
326
327 uint64_t num_affected_rows;
328 SERVICE_PLACEHOLDER(mysql_stmt_diagnostics)->affected_rows(statement,
329 &num_affected_rows)
330
331 auto last_insert_id = uint64_t{};
332 SERVICE_PLACEHOLDER(mysql_stmt_diagnostics)->insert_id(statement,
333 &last_insert_id)
334
335 // To get the diagnostics information
336 auto error_number = uint64_t{};
337 SERVICE_PLACEHOLDER(mysql_stmt_diagnostics)->error_id(statement,
338 &error_number);
339 char const *sql_errmsg = nullptr;
340 SERVICE_PLACEHOLDER(mysql_stmt_diagnostics)->error(statement,
341 &sql_errmsg);
342 char const *sql_state = nullptr;
343 SERVICE_PLACEHOLDER(mysql_stmt_diagnostics)->get_sql_state(statement,
344 &sql_state);
345 auto warning_count = uint32_t{};
346 SERVICE_PLACEHOLDER(mysql_stmt_diagnostics)->num_warnings(statement,
347 &warning_count);
348
349 for(size_t warn_index = 0; warn_index < warning_count; warn_index++) {
350 my_h_warning warning = nullptr;
351 SERVICE_PLACEHOLDER(mysql_stmt_diagnostics)->get_warning(statement,
352 warn_index, &warning);
353 auto level = uint32_t{};
354 SERVICE_PLACEHOLDER(mysql_stmt_diagnostics)->warning_level(warning,
355 &level);
356
357 // Similarly for code and message
358 }
359
360 */
361// clang-format on
362BEGIN_SERVICE_DEFINITION(mysql_stmt_diagnostics)
363/**
364 @brief Get the number of affected rows for DDL e.g. UPDATE/DELETE/INSERT
365 statements.
366
367 @param [in] statement A handle to the statement
368 @param [out] num_rows Number of rows affected
369 @return Status of the performed operation
370 @retval false success
371 @retval true failure
372 */
373DECLARE_BOOL_METHOD(affected_rows,
374 (my_h_statement statement, uint64_t *num_rows));
375/**
376 @brief Get the last insert id which is the ID generated for an AUTO_INCREMENT
377 column.
378
379 @param [in] statement A handle to the statement
380 @param [out] last_id The last insert id
381 @return Status of the performed operation
382 @retval false success
383 @retval true failure
384 */
385DECLARE_BOOL_METHOD(insert_id, (my_h_statement statement, uint64_t *last_id));
386/**
387 @brief Get the error number of the last error.
388
389 @param [in] statement The statement handle
390 @param [out] error_number The error number
391 @return Status of the performed operation
392 @retval false success
393 @retval true failure
394 */
395DECLARE_BOOL_METHOD(error_number,
396 (my_h_statement statement, uint64_t *error_number));
397
398/**
399 @brief Get the error message of the last error.
400
401 @param [in] statement The statement handle
402 @param [out] error_message The error message
403 @return Status of the performed operation
404 @retval false success
405 @retval true failure
406 */
409
410/**
411 @brief Get SQLSTATE error code for the last error similar to
412 https://dev.mysql.com/doc/c-api/8.0/en/mysql-stmt-sqlstate.html
413
414 @param [in] statement The statement handle
415 @param [out] sqlstate Stores the SQLSTATE status of the most
416 recently executed SQL stmt.
417 @return Status of the performed operation
418 @retval false success
419 @retval true failure
420 */
423
424/**
425 @brief Get the number of warnings of the recently invoked statement.
426
427 @param [in] statement The statement handle
428 @param [out] count The number of warnings
429 @return Status of the performed operation
430 @retval false success
431 @retval true failure
432 */
434
435/**
436 @brief Get the warning at the index.
437
438 @param [in] statement The statement handle
439 @param [in] warning_index 0-based index of the warning
440 @param [out] warning The warning
441 @return Status of the performed operation
442 @retval false success
443 @retval true failure
444 */
445DECLARE_BOOL_METHOD(get_warning,
446 (my_h_statement statement, uint32_t warning_index,
448
449/**
450 @brief Get the severity level of the warning.
451
452 @param [in] warning The warning
453 @param [out] level The level
454 @return Status of the performed operation
455 @retval false success
456 @retval true failure
457 */
458DECLARE_BOOL_METHOD(warning_level, (my_h_warning warning, uint32_t *level));
459
460/**
461 @brief Get the code of the warning.
462
463 @param [in] warning The warning
464 @param [out] code The code
465 @return Status of the performed operation
466 @retval false success
467 @retval true failure
468 */
469DECLARE_BOOL_METHOD(warning_code, (my_h_warning warning, uint32_t *code));
470
471/**
472 @brief Get the message of the warning.
473
474 @param [in] warning The warning
475 @param [out] code The message
476 @return Status of the performed operation
477 @retval false success
478 @retval true failure
479 */
480DECLARE_BOOL_METHOD(warning_message,
483END_SERVICE_DEFINITION(mysql_stmt_diagnostics)
484
485BEGIN_SERVICE_DEFINITION(mysql_stmt_attributes)
486
487// clang-format off
488/**
489 @brief Get the current value for a statement attribute.
490
491 @param [in] statement A handle to the statement
492 @param [in] name Attribute name to get
493
494 The following attributes are supported:
495 - Buffer capacity of the statement ("buffer_capacity" of the input size_t type, default: 500)
496 - Number of prefetch rows for prepared statements ("prefetch_rows" of the input size_t type, default: 1)
497 - Expected charset name ("charset_name" of the input mysql_cstring_with_length type, default: utf8mb4)
498 - Use the existing protocol from thd ("use_thd_protocol" of the input bool type, default: false)
499
500 @param [out] value The value of the attribute
501 @retval false success
502 @retval true failure
503 */
504// clang-format on
505
508
509/**
510 @brief Set the value of a statement attribute.
511
512 @note Setting the attribute is only allowed after init and before
513 prepare/execute.
514
515 @param [in] statement A handle to the statement
516 @param [in] name Attribute name to be set
517 @param [in] value The value of the attribute
518 @retval false success
519 @retval true failure
520 */
523
524END_SERVICE_DEFINITION(mysql_stmt_attributes)
525
526// clang-format off
527/**
528 @ingroup group_components_services_inventory
529
530 A service that provides the API to get information about statement metadata
531 including the number of the parameters in a prepared statement and their metatdata.
532
533 // For prepared statement, to get the number of parameters
534 uint64_t num_parameters;
535 SERVICE_PLACEHOLDER(mysql_stmt_metadata)->param_count(statement,
536 &num_parameters)
537
538
539 */
540// clang-format on
541
542BEGIN_SERVICE_DEFINITION(mysql_stmt_metadata)
543
544/**
545 @brief Get the number of parameters in the prepared statement.
546
547 @note Calling this on regular statements would fail.
548
549 @param [in] statement A handle to the statement
550 @param [out] parameter_count The number of parameters
551 @return Status of the performed operation
552 @retval false success
553 @retval true failure
554
555 */
556DECLARE_BOOL_METHOD(param_count,
557 (my_h_statement statement, uint32_t *parameter_count));
558
559// clang-format off
560
561/**
562 @brief Get the metadata of a parameter in a prepared statement. The metadata specifies
563 whether the parameter can be null, the type of the parameter, whether the value is signed.
564
565 For example, in this query, "SELECT * FROM table WHERE col = ?", we need to know the parameter
566 specified by '?' is null or not, its type, and if it is integer, whether it is signed. MySQL
567 will provide this information and this function is to get these info.
568
569 auto is_nullable = bool{};
570 if (SERVICE_PLACEHOLDER(mysql_stmt_metadata)
571 ->param_metadata(statement, index, "null_bit", &is_nullable))
572 return {};
573 auto sql_type = Sql_type{};
574 if (SERVICE_PLACEHOLDER(mysql_stmt_metadata)
575 ->param_metadata(statement, index, "type", &sql_type))
576 return {};
577 auto is_unsigned = bool{};
578 if (SERVICE_PLACEHOLDER(mysql_stmt_metadata)
579 ->param_metadata(statement, index, "is_unsigned", &is_unsigned))
580 return {};
581 auto charset = static_cast<char const *>(nullptr);
582 if (SERVICE_PLACEHOLDER(mysql_stmt_metadata)
583 ->param_metadata(statement, index, "charset", &charset))
584 return {};
585
586 @note Calling this on regular statements would fail.
587
588 @param [in] statement A handle to the statement
589 @param [in] index 0-based index of the parameter
590 @param [in] metadata The metadata argument is the attribute that you want to get
591
592 The following attributes are supported:
593
594 - Parameter is null ("null_bit" of the returned bool type)
595 - Parameter type ("type" of the returned uint64_t MYSQL_SP_ARG_TYPE_* type)
596 - Parameter is unsigned ("is_unsigned" of the returned bool type)
597 - Parameter charset ("charset" of the returned const char* type)
598 - Parameter max_byte_length ("max_byte_length" of the returned size_t type)
599
600 @param [out] data The data argument is the value for the member
601 @return Status of the performed operation
602 @retval false success
603 @retval true failure
604
605 */
606// clang-format on
607
608DECLARE_BOOL_METHOD(param_metadata, (my_h_statement statement, uint32_t index,
609 const char *metadata, void *data));
610END_SERVICE_DEFINITION(mysql_stmt_metadata)
611
612// clang-format off
613/**
614 @ingroup group_components_services_inventory
615
616 A service that provides the API to get information about a field or column in a result
617 set including get the number of fields, fetch a field and get information of a field.
618 More info: https://dev.mysql.com/doc/c-api/8.0/en/mysql-stmt-field-count.html
619
620 Usage example:
621
622 auto num_fields = uint32_t{};
623 SERVICE_PLACEHOLDER(mysql_stmt_resultset_metadata)->field_count(statement, &num_fields);
624
625 my_h_field field = nullptr;
626 for(size_t field_index = 0; field_index < num_fields; field_index++) {
627 SERVICE_PLACEHOLDER(mysql_stmt_resultset_metadata)->fetch_field(statement,
628 field_index, &field);
629
630 char* field_name = nullptr;
631 SERVICE_PLACEHOLDER(mysql_stmt_resultset_metadata)->field_info(field,
632 "col_name", &field_name);
633
634 // Do similarly for other field metadata
635 }
636 */
637// clang-format on
638BEGIN_SERVICE_DEFINITION(mysql_stmt_resultset_metadata)
639
640/**
641 @brief Get the field handle by the index.
642
643 @param [in] statement A handle to the statement
644 @param [in] column_index 0-based index of the column
645 @param [out] field The field handle
646 @return Status of the performed operation
647 @retval false success
648 @retval true failure
649 */
651 uint32_t column_index, my_h_field *field));
652
653/**
654 @brief Get the number of fields in the current result set.
655
656 @param [in] statement A handle to the statement
657 @param [out] num_fields The number of fields in this result set
658 @return Status of the performed operation
659 @retval false success
660 @retval true failure
661 */
662DECLARE_BOOL_METHOD(field_count,
663 (my_h_statement statement, uint32_t *num_fields));
664
665// clang-format off
666/**
667 @brief Get the information about the field.
668
669 @param [in] field The field to get information from
670 @param [in] name Name of the attributes to get from the field
671
672 Currently, following attributes are supported:
673
674 - Column name ("col_name" of the returned const char* type)
675 - Original column name ("org_col_name" of the returned const char* type)
676 - Database name ("db_name" of the returned const char* type)
677 - Table name ("table_name" of the returned const char* type)
678 - Original table name ("org_table_name" of the returned const char* type)
679 - Field type ("type" of the returned uint64_t MYSQL_SP_ARG_TYPE_* type)
680 - Raw MySQL field type ("mysql_type" of the returned mysql_field_type_t
681 MYSQL_FIELD_TYPE_* type)
682 - Charset number ("charsetnr" of the returned uint type)
683 - Charset name ("charset_name" of the returned const char* type)
684 - Collation name ("collation_name" of the returned const char* type)
685 - Field flags ("flags" of the returned uint type)
686 - Field decimals ("decimals" of the returned uint type)
687 - Field length ("length" of the returned ulong type)
688 - Whether the field is unsigned ("is_unsigned" of the returned bool type)
689 - Whether the field is zerofill ("is_zerofill" of the returned bool type)
690
691 @note "type" and "mysql_type" use different ABI domains. "type" returns the
692 legacy statement-service MYSQL_SP_ARG_TYPE_* value. "mysql_type" returns the
693 raw MYSQL_FIELD_TYPE_* value corresponding to enum_field_types.
694
695 @param [out] data The returned information
696 @return Status of the performed operation
697 @retval false success
698 @retval true failure
699 */
700// clang-format on
701
703 (my_h_field field, const char *name, void *data));
704END_SERVICE_DEFINITION(mysql_stmt_resultset_metadata)
705
706// clang-format off
707/**
708 @ingroup group_components_services_inventory
709
710 A service that provides the API for get integer.
711
712 Usage example:
713
714 autp int_val = int64_t{};
715 bool is_null;
716 SERVICE_PLACEHOLDER(mysql_stmt_get_integer)->get(row, column_index,
717 &int_val, &is_null)
718*/
719// clang-format on
720
721BEGIN_SERVICE_DEFINITION(mysql_stmt_get_integer)
722/**
723 @brief Get signed integer at column_index from a row.
724
725 @param [in] row The row handle
726 @param [in] column_index 0-based index at which the data is extracted
727 @param [out] data The extracted integer
728 @param [out] is_null Flag to indicate if value is null
729 @return Status of the performed operation
730 @retval false success
731 @retval true failure
732 */
733DECLARE_BOOL_METHOD(get, (my_h_row row, uint32_t column_index, int64_t *data,
734 bool *is_null));
735END_SERVICE_DEFINITION(mysql_stmt_get_integer)
736
737/**
738 @ingroup group_components_services_inventory
739
740 A service that provides the API for get unsigned integer.
741*/
742BEGIN_SERVICE_DEFINITION(mysql_stmt_get_unsigned_integer)
743/**
744 @brief Get unsigned integer at column_index from a row.
745
746 @param [in] row The row handle
747 @param [in] column_index 0-based index at which the data is extracted
748 @param [out] data The extracted unsigned integer
749 @param [out] is_null Flag to indicate if value is null
750 @return Status of the performed operation
751 @retval false success
752 @retval true failure
753 */
754DECLARE_BOOL_METHOD(get, (my_h_row row, uint32_t column_index, uint64_t *data,
755 bool *is_null));
756END_SERVICE_DEFINITION(mysql_stmt_get_unsigned_integer)
757
758/**
759 @ingroup group_components_services_inventory
760
761 A service that provides the API for get double.
762*/
763BEGIN_SERVICE_DEFINITION(mysql_stmt_get_double)
764/**
765 @brief Get float at column_index from a row.
766
767 @param [in] row The row handle
768 @param [in] column_index 0-based index at which the data is extracted
769 @param [out] data The extracted double
770 @param [out] is_null Flag to indicate if value is null
771 @return Status of the performed operation
772 @retval false success
773 @retval true failure
774 */
775DECLARE_BOOL_METHOD(get, (my_h_row row, uint32_t column_index, double *data,
776 bool *is_null));
777END_SERVICE_DEFINITION(mysql_stmt_get_double)
778
779/**
780 @ingroup group_components_services_inventory
781
782 A service that provides the API for get time value from a row.
783
784 auto result = Time_t{};
785 auto is_null = false;
786
787 if (SERVICE_PLACEHOLDER(mysql_stmt_get_time)
788 ->get(row, column_index, &result.hour, &result.minute, &result.second,
789 &result.microseconds, &result.negative,
790 &is_null) == MYSQL_FAILURE)
791 return {};
792*/
793
794BEGIN_SERVICE_DEFINITION(mysql_stmt_get_time)
795/**
796 @brief Get time at column_index from a row.
797
798 @param [in] row The row handle
799 @param [in] column_index 0-based index at which the data is extracted
800 @param [out] time structure representing temporal type
801 @param [out] is_null Flag to indicate if value is null
802 @return Status of the performed operation
803 @retval false success
804 @retval true failure
805*/
806DECLARE_BOOL_METHOD(get, (my_h_row row, uint32_t column_index, mle_time *time,
807 bool *is_null));
808END_SERVICE_DEFINITION(mysql_stmt_get_time)
809
810/**
811 @ingroup group_components_services_inventory
812
813 A service that provides the API for get string value from a row.
814
815 auto result = mysql_cstring_with_length{};
816 auto is_null = false;
817 if (SERVICE_PLACEHOLDER(mysql_stmt_get_string)
818 ->get(row, column_index, &result, &is_null) == MYSQL_FAILURE) {
819 return {};
820 }
821*/
822BEGIN_SERVICE_DEFINITION(mysql_stmt_get_string)
823/**
824 @brief Get string at column_index from a row.
825
826 @param [in] row The row handle
827 @param [in] column_index 0-based index at which the data is extracted
828 @param [out] data The extracted string
829 @param [out] is_null Flag to indicate if value is null
830 @return Status of the performed operation
831 @retval false success
832 @retval true failure
833 */
834DECLARE_BOOL_METHOD(get, (my_h_row row, uint32_t column_index,
836END_SERVICE_DEFINITION(mysql_stmt_get_string)
837
838#endif /* MYSQL_STATEMENT_SERVICE_H */
static mysql_service_status_t init()
Component initialization.
Definition: audit_api_message_emit.cc:566
int execute(const vector< string > &positional_options)
Definition: mysqlcheck_core.cc:508
static int count
Definition: myisam_ftdump.cc:45
static char * query
Definition: myisam_ftdump.cc:47
int STDCALL mysql_stmt_execute(MYSQL_STMT *stmt)
Definition: libmysql.cc:2312
struct my_h_warning_imp * my_h_warning
Definition: mysql_statement_service.h:38
struct my_h_row_imp * my_h_row
Definition: mysql_statement_service.h:36
struct my_h_statement_imp * my_h_statement
Definition: mysql_statement_service.h:35
struct my_h_field_imp * my_h_field
Definition: mysql_statement_service.h:37
String related data structures.
void warning(const char *format,...)
void error(const char *format,...)
std::string HARNESS_EXPORT reset()
get 'reset attributes' ESC sequence.
Definition: vt100.cc:37
constexpr value_type is_unsigned
Definition: classic_protocol_constants.h:273
bool index(const std::string &value, const String &search_for, uint32_t *idx)
Definition: contains.h:76
ValueType value(const std::optional< ValueType > &v)
Definition: gtid.h:83
static mysql_service_status_t get(THD **thd) noexcept
Definition: mysql_current_thread_reader_all_empty.cc:31
stdx::expected< void, std::error_code > close(file_handle_type native_handle)
close file handle.
Definition: file.h:239
bool is_null(poly_thread thread, poly_value value)
Definition: jit_executor_type_conversion.cc:46
std::set< Key, Compare, ut::allocator< Key > > set
Specialization of set which uses ut_allocator.
Definition: ut0new.h:2732
required string type
Definition: replication_group_member_actions.proto:34
#define END_SERVICE_DEFINITION(name)
A macro to end the last Service definition started with the BEGIN_SERVICE_DEFINITION macro.
Definition: service.h:91
#define BEGIN_SERVICE_DEFINITION(name)
Declares a new Service.
Definition: service.h:86
#define DEFINE_SERVICE_HANDLE(name)
Defines an object type that is meant for carrying handles to the implementation-specific objects used...
Definition: service.h:129
#define DECLARE_BOOL_METHOD(name, args)
Declares a method that returns bool as a part of the Service definition.
Definition: service.h:112
static const LEX_CSTRING field_info
Definition: sql_show_processlist.cc:63
case opt name
Definition: sslopt-case.h:29
Definition: mle_time_bits.h:37
String with length information.
Definition: mysql_string_defs.h:35
Definition: mysqlslap.cc:222
static void prepare(pax_msg *p, pax_op op)
Definition: xcom_base.cc:1592