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