MySQL 9.0.0
Source Code Documentation
mysql_statement_service.h
Go to the documentation of this file.
1/* Copyright (c) 2023, 2024, 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>
30#include <cstddef>
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_TYPE_LONG, false, 4, 1, nullptr, 0);
69
70 SERVICE_PLACEHOLDER(mysql_stmt_execute)->execute(statement)
71
72 my_h_row row = nullptr;
73 SERVICE_PLACEHOLDER(mysql_stmt_result)->fetch(statement, &row);
74 SERVICE_PLACEHOLDER(mysql_stmt_factory)->close(statement)
75
76 Usage example for regular statement:
77 my_h_statement statement = nullptr;
78 SERVICE_PLACEHOLDER(mysql_stmt_factory)->init(&statement);
79
80 SERVICE_PLACEHOLDER(mysql_stmt_attributes)->set("charset_name", "utf8mb4");
81
82 SERVICE_PLACEHOLDER(mysql_stmt_execute_direct)->execute("SELECT * FROM my_table", statement);
83
84 my_h_row row = nullptr;
85 SERVICE_PLACEHOLDER(mysql_stmt_result)->fetch(statement, &row);
86 SERVICE_PLACEHOLDER(mysql_stmt_factory)->close(statement)
87 */
88
89// clang-format on
90
91BEGIN_SERVICE_DEFINITION(mysql_stmt_factory)
92/**
93 @brief Construct a new statement object.
94
95 @note if the statement already exists, it is overwritten.
96
97 @param [out] statement A handle to the statement
98 @return Status of the performed operation
99 @retval false success
100 @retval true failure
101 */
103
104/**
105 @brief Close and clean up resource related to a statement.
106
107 @param [in] statement A handle to the statement
108 @return Status of the performed operation
109 @retval false success
110 @retval true failure
111 */
113END_SERVICE_DEFINITION(mysql_stmt_factory)
114
115/**
116 @ingroup group_components_services_inventory
117
118 A service that provides the API to execute prepared statements.
119
120 Usage example:
121 // Prepare a statement
122 my_h_statement statement = nullptr;
123 SERVICE_PLACEHOLDER(mysql_stmt_factory)->init(&statement);
124 SERVICE_PLACEHOLDER(mysql_stmt_execute)->prepare("SELECT * FROM my_table WHERE
125 col_c = ?", statement)
126 SERVICE_PLACEHOLDER(mysql_stmt_bind)->bind_param(statement, 0, false,
127 MYSQL_TYPE_LONG, false, 4, 1, nullptr, 0);
128
129 // To reset the parameter to bind it with new values
130 SERVICE_PLACEHOLDER(mysql_stmt_execute)->reset(statement)
131
132 // Execute the statement
133 SERVICE_PLACEHOLDER(mysql_stmt_execute)->execute(statement)
134
135
136*/
138/**
139 @brief Execute the prepared statement.
140
141 @note Execute will fail if all parameters are not bound.
142 @note To execute regular statement, use mysql_stmt_execute_direct::execute
143 instead.
144
145 @param [in] statement A handle to the statement
146 @return Status of the performed operation
147 @retval false success
148 @retval true failure
149 */
151
152/**
153 @brief Prepare the statement with the query.
154
155 @note Re-preparation is not allowed after the statement has been created. To
156 prepare a new query, create a new statement instead.
157 @note Calling this on regular statements would fail.
158
159 @param [in] query The query string to be prepared
160 @param [in] statement A handle to the statement
161 @return Status of the performed operation
162 @retval false success
163 @retval true failure
164 */
167
168/**
169 @brief For prepared statements, calling reset would reset the binding
170 parameters, close the cursor if one is open and frees the result sets.
171 For regular statements, calling reset is not supported. To close
172 and clean up the statement, use mysql_stmt_factory::close.
173
174 @note For prepared statements, the statement still exists, only the result
175 sets are destroyed.
176 @note Calling this on regular statements would fail.
177
178 @param [in] statement A handle to the statement
179 @return Status of the performed operation
180 @retval false success
181 @retval true failure
182 */
184
186
187BEGIN_SERVICE_DEFINITION(mysql_stmt_execute_direct)
188/**
189 @brief Execute the regular statement with the specified query using execute
190 direct.
191
192 @param [in] query The query string to be executed
193 @param [in] statement A handle to the statement
194 @return Status of the performed operation
195 @retval false success
196 @retval true failure
197 */
200END_SERVICE_DEFINITION(mysql_stmt_execute_direct)
201
202// clang-format off
203/**
204 @ingroup group_components_services_inventory
205
206 A service that provides the API to bind the parameters in prepared statements.
207
208 Usage example:
209
210 // For first parameter
211 SERVICE_PLACEHOLDER(mysql_stmt_bind)->bind_param(statement, 0, false,
212 MYSQL_TYPE_LONG, false, 4, 1, nullptr, 0);
213
214*/
215
216// clang-format on
218/**
219 @brief Bind a parameter
220
221 @note Calling bind with regular statements results in failure.
222 @note Bound values are cached. To update only some parameters, call bind on
223 these, the rest will use the cached values.
224 @note Calling bind with the same index multiple times, only the last value is
225 kept.
226
227 @param [in] statement A handle to the statement
228 @param [in] index 0-based index of the parameter to be bound
229 @param [in] is_null Whether the parameter can be null
230 @param [in] type Type of the parameter. List of supported types: Table 6.1 at
231 https://dev.mysql.com/doc/c-api/8.0/en/c-api-prepared-statement-type-codes.html
232 @param [in] bool Whether the value is unsigned
233 @param [in] data The data argument is the value for the member
234 @param [in] data_length Length of the data
235 @param [in] name Name of the parameter
236 @param [in] name_length Name length of the parameter
237 @return Status of the performed operation
238 @retval false success
239 @retval true failure
240
241 */
242DECLARE_BOOL_METHOD(bind_param, (my_h_statement statement, uint32_t index,
243 bool is_null, uint64_t type, bool is_unsigned,
244 const void *data, unsigned long data_length,
245 const char *name, unsigned long name_length));
246
248
249// clang-format off
250/**
251 @ingroup group_components_services_inventory
252
253 A service that provides the API to manage and get info about a result set including fetch row(s)
254 from a result set, get next result set. A result set contains the result of an execution.
255 It is a list of rows, each row is a list of values where each value corresponds to a column.
256
257 Usage example:
258 // Iterate over the rows in a result set for result set with data (num_fields != 0)
259 // For in-depth example, check test_execute_prepared_statement.cc and test_execute_regular_statement.cc
260 my_h_row row = nullptr;
261 do {
262 SERVICE_PLACEHOLDER(mysql_stmt_result)->fetch(statement, &row);
263 if (row == nullptr) {
264 break;
265 }
266 // Get data from a row using row services
267 } while (true)
268
269 // Iterate over result sets
270 auto has_next_result_set = bool{};
271 do {
272 SERVICE_PLACEHOLDER(mysql_stmt_result)->next_result(statement, &has_next_result_set);
273 } while(has_next_result_set);
274
275 */
276// clang-format on
277
278BEGIN_SERVICE_DEFINITION(mysql_stmt_result)
279
280/**
281 @brief Check if there is more result set and move to next result set if there
282 is.
283
284 @param [in] statement A handle to the statement
285 @param [out] has_next Whether there is more result set
286 @return Status of the performed operation
287 @retval false success
288 @retval true failure
289 */
290DECLARE_BOOL_METHOD(next_result, (my_h_statement statement, bool *has_next));
291
292/**
293 @brief Fetch one row from the current result set
294
295 @note If there is no more rows, the returned row handle will be a nullptr.
296 This is not considered a failure case.
297
298 @param [in] statement A handle to the statement
299 @param [out] row The row handle
300 @return Status of the performed operation
301 @retval false success if there is no error in fetching the row including no
302 more rows.
303 @retval true failure in case of any error in fetching the row
304 */
306
307END_SERVICE_DEFINITION(mysql_stmt_result)
308
309// clang-format off
310/**
311 @ingroup group_components_services_inventory
312
313 A service that provides the API to get the errors and warnings including
314 fetching the warning, getting error/warning number, error/warning level,
315 error/warning message, SQL state. In addition, for INSERT/UPDATE/DELETE,
316 the service provides the API to get the number of affected rows and
317 last insert ID.
318
319 Usage example:
320 // For INSERT/UPDATE/DELETE/... statements, to get the number of affected rows
321 // and last insert id.
322
323 uint64_t num_affected_rows;
324 SERVICE_PLACEHOLDER(mysql_stmt_diagnostics)->affected_rows(statement,
325 &num_affected_rows)
326
327 auto last_insert_id = uint64_t{};
328 SERVICE_PLACEHOLDER(mysql_stmt_diagnostics)->insert_id(statement,
329 &last_insert_id)
330
331 // To get the diagnostics information
332 auto error_number = uint64_t{};
333 SERVICE_PLACEHOLDER(mysql_stmt_diagnostics)->error_id(statement,
334 &error_number);
335 char const *sql_errmsg = nullptr;
336 SERVICE_PLACEHOLDER(mysql_stmt_diagnostics)->error(statement,
337 &sql_errmsg);
338 char const *sql_state = nullptr;
339 SERVICE_PLACEHOLDER(mysql_stmt_diagnostics)->get_sql_state(statement,
340 &sql_state);
341 auto warning_count = uint32_t{};
342 SERVICE_PLACEHOLDER(mysql_stmt_diagnostics)->num_warnings(statement,
343 &warning_count);
344
345 for(size_t warn_index = 0; warn_index < warning_count; warn_index++) {
346 my_h_warning warning = nullptr;
347 SERVICE_PLACEHOLDER(mysql_stmt_diagnostics)->get_warning(statement,
348 warn_index, &warning);
349 auto level = uint32_t{};
350 SERVICE_PLACEHOLDER(mysql_stmt_diagnostics)->warning_level(warning,
351 &level);
352
353 // Similarly for code and message
354 }
355
356 */
357// clang-format on
358BEGIN_SERVICE_DEFINITION(mysql_stmt_diagnostics)
359/**
360 @brief Get the number of affected rows for DDL e.g. UPDATE/DELETE/INSERT
361 statements.
362
363 @param [in] statement A handle to the statement
364 @param [out] num_rows Number of rows affected
365 @return Status of the performed operation
366 @retval false success
367 @retval true failure
368 */
369DECLARE_BOOL_METHOD(affected_rows,
370 (my_h_statement statement, uint64_t *num_rows));
371/**
372 @brief Get the last insert id which is the ID generated for an AUTO_INCREMENT
373 column.
374
375 @param [in] statement A handle to the statement
376 @param [out] last_id The last insert id
377 @return Status of the performed operation
378 @retval false success
379 @retval true failure
380 */
381DECLARE_BOOL_METHOD(insert_id, (my_h_statement statement, uint64_t *last_id));
382/**
383 @brief Get the error number of the last error.
384
385 @param [in] statement The statement handle
386 @param [out] error_number The error number
387 @return Status of the performed operation
388 @retval false success
389 @retval true failure
390 */
391DECLARE_BOOL_METHOD(error_number,
392 (my_h_statement statement, uint64_t *error_number));
393
394/**
395 @brief Get the error message of the last error.
396
397 @param [in] statement The statement handle
398 @param [out] error_message The error message
399 @return Status of the performed operation
400 @retval false success
401 @retval true failure
402 */
405
406/**
407 @brief Get SQLSTATE error code for the last error similar to
408 https://dev.mysql.com/doc/c-api/8.0/en/mysql-stmt-sqlstate.html
409
410 @param [in] statement The statement handle
411 @param [out] sqlstate Stores the SQLSTATE status of the most
412 recently executed SQL stmt.
413 @return Status of the performed operation
414 @retval false success
415 @retval true failure
416 */
419
420/**
421 @brief Get the number of warnings of the recently invoked statement.
422
423 @param [in] statement The statement handle
424 @param [out] count The number of warnings
425 @return Status of the performed operation
426 @retval false success
427 @retval true failure
428 */
430
431/**
432 @brief Get the warning at the index.
433
434 @param [in] statement The statement handle
435 @param [in] warning_index 0-based index of the warning
436 @param [out] warning The warning
437 @return Status of the performed operation
438 @retval false success
439 @retval true failure
440 */
441DECLARE_BOOL_METHOD(get_warning,
442 (my_h_statement statement, uint32_t warning_index,
444
445/**
446 @brief Get the severity level of the warning.
447
448 @param [in] warning The warning
449 @param [out] level The level
450 @return Status of the performed operation
451 @retval false success
452 @retval true failure
453 */
454DECLARE_BOOL_METHOD(warning_level, (my_h_warning warning, uint32_t *level));
455
456/**
457 @brief Get the code of the warning.
458
459 @param [in] warning The warning
460 @param [out] code The code
461 @return Status of the performed operation
462 @retval false success
463 @retval true failure
464 */
465DECLARE_BOOL_METHOD(warning_code, (my_h_warning warning, uint32_t *code));
466
467/**
468 @brief Get the message of the warning.
469
470 @param [in] warning The warning
471 @param [out] code The message
472 @return Status of the performed operation
473 @retval false success
474 @retval true failure
475 */
476DECLARE_BOOL_METHOD(warning_message,
479END_SERVICE_DEFINITION(mysql_stmt_diagnostics)
480
481BEGIN_SERVICE_DEFINITION(mysql_stmt_attributes)
482
483// clang-format off
484/**
485 @brief Get the current value for a statement attribute.
486
487 @param [in] statement A handle to the statement
488 @param [in] name Attribute name to get
489
490 The following attributes are supported:
491 - Buffer capacity of the statement ("buffer_capacity" of the input size_t type, default: 500)
492 - Number of prefetch rows for prepared statements ("prefetch_rows" of the input size_t type, default: 1)
493 - Expected charset name ("charset_name" of the input mysql_cstring_with_length type, default: utf8mb4)
494 - Use the existing protocol from thd ("use_thd_protocol" of the input bool type, default: false)
495
496 @param [out] value The value of the attribute
497 @retval false success
498 @retval true failure
499 */
500// clang-format on
501
504
505/**
506 @brief Set the value of a statement attribute.
507
508 @note Setting the attribute is only allowed after init and before
509 prepare/execute.
510
511 @param [in] statement A handle to the statement
512 @param [in] name Attribute name to be set
513 @param [in] value The value of the attribute
514 @retval false success
515 @retval true failure
516 */
518 mysql_cstring_with_length name, const void *value));
519
520END_SERVICE_DEFINITION(mysql_stmt_attributes)
521
522// clang-format off
523/**
524 @ingroup group_components_services_inventory
525
526 A service that provides the API to get information about statement metadata
527 including the number of the parameters in a prepared statement and their metatdata.
528
529 // For prepared statement, to get the number of parameters
530 uint64_t num_parameters;
531 SERVICE_PLACEHOLDER(mysql_stmt_metadata)->param_count(statement,
532 &num_parameters)
533
534
535 */
536// clang-format on
537
538BEGIN_SERVICE_DEFINITION(mysql_stmt_metadata)
539
540/**
541 @brief Get the number of parameters in the prepared statement.
542
543 @note Calling this on regular statements would fail.
544
545 @param [in] statement A handle to the statement
546 @param [out] parameter_count The number of parameters
547 @return Status of the performed operation
548 @retval false success
549 @retval true failure
550
551 */
552DECLARE_BOOL_METHOD(param_count,
553 (my_h_statement statement, uint32_t *parameter_count));
554
555// clang-format off
556
557/**
558 @brief Get the metadata of a parameter in a prepared statement. The metadata specifies
559 whether the parameter can be null, the type of the parameter, whether the value is signed.
560
561 For example, in this query, "SELECT * FROM table WHERE col = ?", we need to know the parameter
562 specified by '?' is null or not, its type, and if it is integer, whether it is signed. MySQL
563 will provide this information and this function is to get these info.
564
565 auto is_nullable = bool{};
566 if (SERVICE_PLACEHOLDER(mysql_stmt_metadata)
567 ->param_metadata(statement, index, "null_bit", &is_nullable))
568 return {};
569 auto sql_type = Sql_type{};
570 if (SERVICE_PLACEHOLDER(mysql_stmt_metadata)
571 ->param_metadata(statement, index, "type", &sql_type))
572 return {};
573 auto is_unsigned = bool{};
574 if (SERVICE_PLACEHOLDER(mysql_stmt_metadata)
575 ->param_metadata(statement, index, "is_unsigned", &is_unsigned))
576 return {};
577 auto charset = static_cast<char const *>(nullptr);
578 if (SERVICE_PLACEHOLDER(mysql_stmt_metadata)
579 ->param_metadata(statement, index, "charset", &charset))
580 return {};
581
582 @note Calling this on regular statements would fail.
583
584 @param [in] statement A handle to the statement
585 @param [in] index 0-based index of the parameter
586 @param [in] metadata The metadata argument is the attribute that you want to get
587
588 The following attributes are supported:
589
590 - Parameter is null ("null_bit" of the returned bool type)
591 - Parameter type ("type" of the returned uint64_t type)
592 - Parameter is unsigned ("is_unsigned" of the returned bool type)
593 - Parameter charset ("charset" of the returned const char* type)
594
595 @param [out] data The data argument is the value for the member
596 @return Status of the performed operation
597 @retval false success
598 @retval true failure
599
600 */
601// clang-format on
602
603DECLARE_BOOL_METHOD(param_metadata, (my_h_statement statement, uint32_t index,
604 const char *metadata, void *data));
605END_SERVICE_DEFINITION(mysql_stmt_metadata)
606
607// clang-format off
608/**
609 @ingroup group_components_services_inventory
610
611 A service that provides the API to get information about a field or column in a result
612 set including get the number of fields, fetch a field and get information of a field.
613 More info: https://dev.mysql.com/doc/c-api/8.0/en/mysql-stmt-field-count.html
614
615 Usage example:
616
617 auto num_fields = uint32_t{};
618 SERVICE_PLACEHOLDER(mysql_stmt_resultset_metadata)->field_count(statement, &num_fields);
619
620 my_h_field field = nullptr;
621 for(size_t field_index = 0; field_index < num_fields; field_index++) {
622 SERVICE_PLACEHOLDER(mysql_stmt_resultset_metadata)->fetch_field(statement,
623 field_index, &field);
624
625 char* field_name = nullptr;
626 SERVICE_PLACEHOLDER(mysql_stmt_resultset_metadata)->field_info(field,
627 "col_name", &field_name);
628
629 // Do similarly for other field metadata
630 }
631 */
632// clang-format on
633BEGIN_SERVICE_DEFINITION(mysql_stmt_resultset_metadata)
634
635/**
636 @brief Get the field handle by the index.
637
638 @param [in] statement A handle to the statement
639 @param [in] column_index 0-based index of the column
640 @param [out] field The field handle
641 @return Status of the performed operation
642 @retval false success
643 @retval true failure
644 */
646 uint32_t column_index, my_h_field *field));
647
648/**
649 @brief Get the number of fields in the current result set.
650
651 @param [in] statement A handle to the statement
652 @param [out] num_fields The number of fields in this result set
653 @return Status of the performed operation
654 @retval false success
655 @retval true failure
656 */
657DECLARE_BOOL_METHOD(field_count,
658 (my_h_statement statement, uint32_t *num_fields));
659
660// clang-format off
661/**
662 @brief Get the information about the field.
663
664 @param [in] field The field to get information from
665 @param [in] name Name of the attributes to get from the field
666
667 Currently, following attributes are supported:
668
669 - Column name ("col_name" of the returned const char* type)
670 - Original column name ("org_col_name" of the returned const char* type)
671 - Database name ("db_name" of the returned const char* type)
672 - Table name ("table_name" of the returned const char* type)
673 - Original table name ("org_table_name" of the returned const char* type)
674 - Field type ("type" of the returned uint64_t type)
675 - Charset number ("charsetnr" of the returned uint type)
676 - Charset name ("charset_name" of the returned const char* type)
677 - Collation name ("collation_name" of the returned const char* type)
678 - Field flags ("flags" of the returned uint type)
679 - Field decimals ("decimals" of the returned uint type)
680 - Field length ("length" of the returned ulong type)
681 - Whether the field is unsigned ("is_unsigned" of the returned bool type)
682 - Whether the field is zerofill ("is_zerofill" of the returned bool type)
683
684 @param [out] data The returned information
685 @return Status of the performed operation
686 @retval false success
687 @retval true failure
688 */
689// clang-format on
690
692 (my_h_field field, const char *name, void *data));
693END_SERVICE_DEFINITION(mysql_stmt_resultset_metadata)
694
695// clang-format off
696/**
697 @ingroup group_components_services_inventory
698
699 A service that provides the API for get integer.
700
701 Usage example:
702
703 autp int_val = int64_t{};
704 bool is_null;
705 SERVICE_PLACEHOLDER(mysql_stmt_get_integer)->get(row, column_index,
706 &int_val, &is_null)
707*/
708// clang-format on
709
710BEGIN_SERVICE_DEFINITION(mysql_stmt_get_integer)
711/**
712 @brief Get signed integer at column_index from a row.
713
714 @param [in] row The row handle
715 @param [in] column_index 0-based index at which the data is extracted
716 @param [out] data The extracted integer
717 @param [out] is_null Flag to indicate if value is null
718 @return Status of the performed operation
719 @retval false success
720 @retval true failure
721 */
722DECLARE_BOOL_METHOD(get, (my_h_row row, uint32_t column_index, int64_t *data,
723 bool *is_null));
724END_SERVICE_DEFINITION(mysql_stmt_get_integer)
725
726/**
727 @ingroup group_components_services_inventory
728
729 A service that provides the API for get unsigned integer.
730*/
731BEGIN_SERVICE_DEFINITION(mysql_stmt_get_unsigned_integer)
732/**
733 @brief Get unsigned integer at column_index from a row.
734
735 @param [in] row The row handle
736 @param [in] column_index 0-based index at which the data is extracted
737 @param [out] data The extracted unsigned integer
738 @param [out] is_null Flag to indicate if value is null
739 @return Status of the performed operation
740 @retval false success
741 @retval true failure
742 */
743DECLARE_BOOL_METHOD(get, (my_h_row row, uint32_t column_index, uint64_t *data,
744 bool *is_null));
745END_SERVICE_DEFINITION(mysql_stmt_get_unsigned_integer)
746
747/**
748 @ingroup group_components_services_inventory
749
750 A service that provides the API for get double.
751*/
752BEGIN_SERVICE_DEFINITION(mysql_stmt_get_double)
753/**
754 @brief Get float at column_index from a row.
755
756 @param [in] row The row handle
757 @param [in] column_index 0-based index at which the data is extracted
758 @param [out] data The extracted double
759 @param [out] is_null Flag to indicate if value is null
760 @return Status of the performed operation
761 @retval false success
762 @retval true failure
763 */
764DECLARE_BOOL_METHOD(get, (my_h_row row, uint32_t column_index, double *data,
765 bool *is_null));
766END_SERVICE_DEFINITION(mysql_stmt_get_double)
767
768/**
769 @ingroup group_components_services_inventory
770
771 A service that provides the API for get time value from a row.
772
773 auto result = Time_t{};
774 auto is_null = false;
775
776 if (SERVICE_PLACEHOLDER(mysql_stmt_get_time)
777 ->get(row, column_index, &result.hour, &result.minute, &result.second,
778 &result.microseconds, &result.negative,
779 &is_null) == MYSQL_FAILURE)
780 return {};
781*/
782
783BEGIN_SERVICE_DEFINITION(mysql_stmt_get_time)
784/**
785 @brief Get time at column_index from a row.
786
787 @param [in] row The row handle
788 @param [in] column_index 0-based index at which the data is extracted
789 @param [out] time structure representing temporal type
790 @param [out] is_null Flag to indicate if value is null
791 @return Status of the performed operation
792 @retval false success
793 @retval true failure
794*/
795DECLARE_BOOL_METHOD(get, (my_h_row row, uint32_t column_index, mle_time *time,
796 bool *is_null));
797END_SERVICE_DEFINITION(mysql_stmt_get_time)
798
799/**
800 @ingroup group_components_services_inventory
801
802 A service that provides the API for get string value from a row.
803
804 auto result = mysql_cstring_with_length{};
805 auto is_null = false;
806 if (SERVICE_PLACEHOLDER(mysql_stmt_get_string)
807 ->get(row, column_index, &result, &is_null) == MYSQL_FAILURE) {
808 return {};
809 }
810*/
811BEGIN_SERVICE_DEFINITION(mysql_stmt_get_string)
812/**
813 @brief Get string at column_index from a row.
814
815 @param [in] row The row handle
816 @param [in] column_index 0-based index at which the data is extracted
817 @param [out] data The extracted string
818 @param [out] is_null Flag to indicate if value is null
819 @return Status of the performed operation
820 @retval false success
821 @retval true failure
822 */
823DECLARE_BOOL_METHOD(get, (my_h_row row, uint32_t column_index,
824 mysql_cstring_with_length *data, bool *is_null));
825END_SERVICE_DEFINITION(mysql_stmt_get_string)
826
827#endif /* MYSQL_STATEMENT_SERVICE_H */
static mysql_service_status_t init()
Component initialization.
Definition: audit_api_message_emit.cc:571
int execute(const vector< string > &positional_options)
Definition: mysqlcheck_core.cc:507
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:2214
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
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
std::set< Key, Compare, ut::allocator< Key > > set
Specialization of set which uses ut_allocator.
Definition: ut0new.h:2883
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:33
Definition: mysqlslap.cc:219
static void prepare(pax_msg *p, pax_op op)
Definition: xcom_base.cc:1588