MySQL 9.1.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 - Parameter max_byte_length ("max_byte_length" of the returned size_t type)
595
596 @param [out] data The data argument is the value for the member
597 @return Status of the performed operation
598 @retval false success
599 @retval true failure
600
601 */
602// clang-format on
603
604DECLARE_BOOL_METHOD(param_metadata, (my_h_statement statement, uint32_t index,
605 const char *metadata, void *data));
606END_SERVICE_DEFINITION(mysql_stmt_metadata)
607
608// clang-format off
609/**
610 @ingroup group_components_services_inventory
611
612 A service that provides the API to get information about a field or column in a result
613 set including get the number of fields, fetch a field and get information of a field.
614 More info: https://dev.mysql.com/doc/c-api/8.0/en/mysql-stmt-field-count.html
615
616 Usage example:
617
618 auto num_fields = uint32_t{};
619 SERVICE_PLACEHOLDER(mysql_stmt_resultset_metadata)->field_count(statement, &num_fields);
620
621 my_h_field field = nullptr;
622 for(size_t field_index = 0; field_index < num_fields; field_index++) {
623 SERVICE_PLACEHOLDER(mysql_stmt_resultset_metadata)->fetch_field(statement,
624 field_index, &field);
625
626 char* field_name = nullptr;
627 SERVICE_PLACEHOLDER(mysql_stmt_resultset_metadata)->field_info(field,
628 "col_name", &field_name);
629
630 // Do similarly for other field metadata
631 }
632 */
633// clang-format on
634BEGIN_SERVICE_DEFINITION(mysql_stmt_resultset_metadata)
635
636/**
637 @brief Get the field handle by the index.
638
639 @param [in] statement A handle to the statement
640 @param [in] column_index 0-based index of the column
641 @param [out] field The field handle
642 @return Status of the performed operation
643 @retval false success
644 @retval true failure
645 */
647 uint32_t column_index, my_h_field *field));
648
649/**
650 @brief Get the number of fields in the current result set.
651
652 @param [in] statement A handle to the statement
653 @param [out] num_fields The number of fields in this result set
654 @return Status of the performed operation
655 @retval false success
656 @retval true failure
657 */
658DECLARE_BOOL_METHOD(field_count,
659 (my_h_statement statement, uint32_t *num_fields));
660
661// clang-format off
662/**
663 @brief Get the information about the field.
664
665 @param [in] field The field to get information from
666 @param [in] name Name of the attributes to get from the field
667
668 Currently, following attributes are supported:
669
670 - Column name ("col_name" of the returned const char* type)
671 - Original column name ("org_col_name" of the returned const char* type)
672 - Database name ("db_name" of the returned const char* type)
673 - Table name ("table_name" of the returned const char* type)
674 - Original table name ("org_table_name" of the returned const char* type)
675 - Field type ("type" of the returned uint64_t type)
676 - Charset number ("charsetnr" of the returned uint type)
677 - Charset name ("charset_name" of the returned const char* type)
678 - Collation name ("collation_name" of the returned const char* type)
679 - Field flags ("flags" of the returned uint type)
680 - Field decimals ("decimals" of the returned uint type)
681 - Field length ("length" of the returned ulong type)
682 - Whether the field is unsigned ("is_unsigned" of the returned bool type)
683 - Whether the field is zerofill ("is_zerofill" of the returned bool type)
684
685 @param [out] data The returned information
686 @return Status of the performed operation
687 @retval false success
688 @retval true failure
689 */
690// clang-format on
691
693 (my_h_field field, const char *name, void *data));
694END_SERVICE_DEFINITION(mysql_stmt_resultset_metadata)
695
696// clang-format off
697/**
698 @ingroup group_components_services_inventory
699
700 A service that provides the API for get integer.
701
702 Usage example:
703
704 autp int_val = int64_t{};
705 bool is_null;
706 SERVICE_PLACEHOLDER(mysql_stmt_get_integer)->get(row, column_index,
707 &int_val, &is_null)
708*/
709// clang-format on
710
711BEGIN_SERVICE_DEFINITION(mysql_stmt_get_integer)
712/**
713 @brief Get signed integer at column_index from a row.
714
715 @param [in] row The row handle
716 @param [in] column_index 0-based index at which the data is extracted
717 @param [out] data The extracted integer
718 @param [out] is_null Flag to indicate if value is null
719 @return Status of the performed operation
720 @retval false success
721 @retval true failure
722 */
723DECLARE_BOOL_METHOD(get, (my_h_row row, uint32_t column_index, int64_t *data,
724 bool *is_null));
725END_SERVICE_DEFINITION(mysql_stmt_get_integer)
726
727/**
728 @ingroup group_components_services_inventory
729
730 A service that provides the API for get unsigned integer.
731*/
732BEGIN_SERVICE_DEFINITION(mysql_stmt_get_unsigned_integer)
733/**
734 @brief Get unsigned integer at column_index from a row.
735
736 @param [in] row The row handle
737 @param [in] column_index 0-based index at which the data is extracted
738 @param [out] data The extracted unsigned integer
739 @param [out] is_null Flag to indicate if value is null
740 @return Status of the performed operation
741 @retval false success
742 @retval true failure
743 */
744DECLARE_BOOL_METHOD(get, (my_h_row row, uint32_t column_index, uint64_t *data,
745 bool *is_null));
746END_SERVICE_DEFINITION(mysql_stmt_get_unsigned_integer)
747
748/**
749 @ingroup group_components_services_inventory
750
751 A service that provides the API for get double.
752*/
753BEGIN_SERVICE_DEFINITION(mysql_stmt_get_double)
754/**
755 @brief Get float at column_index from a row.
756
757 @param [in] row The row handle
758 @param [in] column_index 0-based index at which the data is extracted
759 @param [out] data The extracted double
760 @param [out] is_null Flag to indicate if value is null
761 @return Status of the performed operation
762 @retval false success
763 @retval true failure
764 */
765DECLARE_BOOL_METHOD(get, (my_h_row row, uint32_t column_index, double *data,
766 bool *is_null));
767END_SERVICE_DEFINITION(mysql_stmt_get_double)
768
769/**
770 @ingroup group_components_services_inventory
771
772 A service that provides the API for get time value from a row.
773
774 auto result = Time_t{};
775 auto is_null = false;
776
777 if (SERVICE_PLACEHOLDER(mysql_stmt_get_time)
778 ->get(row, column_index, &result.hour, &result.minute, &result.second,
779 &result.microseconds, &result.negative,
780 &is_null) == MYSQL_FAILURE)
781 return {};
782*/
783
784BEGIN_SERVICE_DEFINITION(mysql_stmt_get_time)
785/**
786 @brief Get time at column_index from a row.
787
788 @param [in] row The row handle
789 @param [in] column_index 0-based index at which the data is extracted
790 @param [out] time structure representing temporal type
791 @param [out] is_null Flag to indicate if value is null
792 @return Status of the performed operation
793 @retval false success
794 @retval true failure
795*/
796DECLARE_BOOL_METHOD(get, (my_h_row row, uint32_t column_index, mle_time *time,
797 bool *is_null));
798END_SERVICE_DEFINITION(mysql_stmt_get_time)
799
800/**
801 @ingroup group_components_services_inventory
802
803 A service that provides the API for get string value from a row.
804
805 auto result = mysql_cstring_with_length{};
806 auto is_null = false;
807 if (SERVICE_PLACEHOLDER(mysql_stmt_get_string)
808 ->get(row, column_index, &result, &is_null) == MYSQL_FAILURE) {
809 return {};
810 }
811*/
812BEGIN_SERVICE_DEFINITION(mysql_stmt_get_string)
813/**
814 @brief Get string at column_index from a row.
815
816 @param [in] row The row handle
817 @param [in] column_index 0-based index at which the data is extracted
818 @param [out] data The extracted string
819 @param [out] is_null Flag to indicate if value is null
820 @return Status of the performed operation
821 @retval false success
822 @retval true failure
823 */
824DECLARE_BOOL_METHOD(get, (my_h_row row, uint32_t column_index,
825 mysql_cstring_with_length *data, bool *is_null));
826END_SERVICE_DEFINITION(mysql_stmt_get_string)
827
828#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:2285
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:2884
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