MySQL 8.3.0
Source Code Documentation
mysql_stored_program.h
Go to the documentation of this file.
1/* Copyright (c) 2022, 2023, 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 also distributed 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 included with MySQL.
13
14This program is distributed in the hope that it will be useful,
15but WITHOUT ANY WARRANTY; without even the implied warranty of
16MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17GNU General Public License, version 2.0, for more details.
18
19You should have received a copy of the GNU General Public License
20along with this program; if not, write to the Free Software
21Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
22
23#ifndef MYSQL_STORED_PROGRAM_H
24#define MYSQL_STORED_PROGRAM_H
25
27#include <cstddef> // size_t
28#include <cstdint> // intXX_t
31
35
36BEGIN_SERVICE_DEFINITION(mysql_stored_program_metadata_query)
37
38/**
39 Get stored program data
40
41 Accepted keys and corresponding data type
42
43 "sp_name" -> mysql_cstring_with_length *
44 "database_name" -> mysql_cstring_with_length *
45 "qualified_name" -> mysql_cstring_with_length *
46 "sp_language" -> mysql_cstring_with_length *
47 "sp_body" -> mysql_cstring_with_length *
48 "sp_type" -> uint16_t
49 "argument_count" -> uint32_t
50
51 @param [in] sp_handle Handle to stored procedure structure
52 @param [in] key Metadata name
53 @param [out] value Metadata value
54
55 @returns Status of operation
56 @retval false Success
57 @retval true Failure
58*/
59
60DECLARE_BOOL_METHOD(get, (stored_program_handle sp_handle, const char *key,
61 void *value));
62
63END_SERVICE_DEFINITION(mysql_stored_program_metadata_query)
64
65/*
66 * Argument-related services:
67 */
68
69BEGIN_SERVICE_DEFINITION(mysql_stored_program_argument_metadata_query)
70
71/**
72 Get stored program argument metadata
73
74 "argument_name" -> const char *
75 "sql_type" -> uint64_t
76 "in_variable" -> boolean
77 "out_variable" -> boolean
78 "is_signed" -> boolean (Applicable to numeric data types)
79 "is_nullable" -> boolean
80 "byte_length" -> uint64_t
81 "char_length" -> uint64_t (Applicable to string data types)
82 "charset" -> char const *
83
84 @param [in] sp_handle Handle to stored procedure structure
85 @param [in] index Argument index
86 @param [in] key Metadata name
87 @param [out] value Metadata value
88
89
90 @returns status of get operation
91 @retval false Success
92 @retval true Failure
93*/
94
95DECLARE_BOOL_METHOD(get, (stored_program_handle sp_handle, uint16_t index,
96 const char *key, void *value));
97
98END_SERVICE_DEFINITION(mysql_stored_program_argument_metadata_query)
99
100BEGIN_SERVICE_DEFINITION(mysql_stored_program_return_metadata_query)
101
102/**
103 Get stored program return value metadata
104
105 "argument_name" -> const char *
106 "sql_type" -> uint64_t
107 "is_signed" -> boolean (Applicable to numeric data types)
108 "is_nullable" -> boolean
109 "byte_length" -> uint64_t
110 "char_length" -> uint64_t (Applicable to string data types)
111 "charset" -> char const *
112
113 @param [in] sp_handle Handle to stored procedure structure
114 @param [in] key Metadata name
115 @param [out] value Metadata value
116
117
118 @returns status of get operation
119 @retval false Success
120 @retval true Failure
121*/
122
123DECLARE_BOOL_METHOD(get, (stored_program_handle sp_handle, const char *key,
124 void *value));
125
126END_SERVICE_DEFINITION(mysql_stored_program_return_metadata_query)
127
128BEGIN_SERVICE_DEFINITION(mysql_stored_program_field_name)
129
130/**
131 Returns the field name of the return value
132 @param [in] sp_runtime_context stored program runtime context.
133 If null, current runtime context
134 will be used.
135 @param [out] value The field name of the return value
136
137
138 @returns status of get operation
139 @retval false Success
140 @retval true Failure
141*/
142
144 char const **value));
145
146END_SERVICE_DEFINITION(mysql_stored_program_field_name)
147
148BEGIN_SERVICE_DEFINITION(mysql_stored_program_runtime_argument_year)
149
150/**
151 @param [in] sp_runtime_context stored program runtime context.
152 If null, current runtime context will
153 be used.
154 @param [in] index Argument position
155 @param [out] year Year
156 @param [out] is_null Flag to indicate if value is null
157
158 @returns Status of operation
159 @retval false Success
160 @retval true Error
161*/
162
164 uint16_t index, uint32_t *year, bool *is_null));
165
166/**
167 @param [in] sp_runtime_context stored program runtime context.
168 If null, current runtime context will be
169 used.
170 @param [in] index Argument location
171 @param [in] year Year
172
173 @returns Status of operation
174 @retval false Success
175 @retval true Error
176*/
177
179 uint16_t index, uint32_t year));
180
181END_SERVICE_DEFINITION(mysql_stored_program_runtime_argument_year)
182
183BEGIN_SERVICE_DEFINITION(mysql_stored_program_runtime_argument_time)
184
185/**
186 @param [in] sp_runtime_context stored program runtime context.
187 If null, current runtime context will
188 be used.
189 @param [in] index Argument position
190 @param [out] hour Hour of the day
191 @param [out] minute Minute of the hour
192 @param [out] second Second of the minute
193 @param [out] micro Micro second of the second
194 @param [out] negative Is negative
195 @param [out] is_null Flag to indicate if value is null
196
197 @returns Status of operation
198 @retval false Success
199 @retval true Error
200*/
201
203 uint16_t index, uint32_t *hour, uint32_t *minute,
204 uint32_t *second, uint64_t *micro, bool *negative,
205 bool *is_null));
206
207/**
208 @param [in] sp_runtime_context stored program runtime context.
209 If null, current runtime context will be
210 used.
211 @param [in] index Argument location
212 @param [in] hour Hour of the day
213 @param [in] minute Minute of the hour
214 @param [in] second Second of the minute
215 @param [in] micro Micro second of the second
216 @param [in] negative Is negative
217 @param [in] decimals Precision information
218
219 @returns Status of operation
220 @retval false Success
221 @retval true Error
222*/
223
225 uint16_t index, uint32_t hour, uint32_t minute,
226 uint32_t second, uint64_t micro, bool negative,
227 uint8_t decimals));
228
229END_SERVICE_DEFINITION(mysql_stored_program_runtime_argument_time)
230
231BEGIN_SERVICE_DEFINITION(mysql_stored_program_runtime_argument_date)
232
233/**
234 @param [in] sp_runtime_context stored program runtime context.
235 If null, current runtime context will be
236 used.
237 @param [in] index Argument position
238 @param [out] year Year information
239 @param [out] month Month of the year
240 @param [out] day Day of the month
241 @param [out] is_null Flag to indicate if value is null
242
243 @returns Status of operation
244 @retval false Success
245 @retval true Error
246*/
247
249 uint16_t index, uint32_t *year, uint32_t *month,
250 uint32_t *day, bool *is_null));
251
252/**
253 @param [in] sp_runtime_context stored program runtime context.
254 If null, current runtime context will be
255 used.
256 @param [in] index Argument position
257 @param [in] year Year information
258 @param [in] month Month of the year
259 @param [in] day Day of the month
260
261 @returns Status of operation
262 @retval false Success
263 @retval true Error
264*/
265
267 uint16_t index, uint32_t year, uint32_t month,
268 uint32_t day));
269
270END_SERVICE_DEFINITION(mysql_stored_program_runtime_argument_date)
271
272BEGIN_SERVICE_DEFINITION(mysql_stored_program_runtime_argument_datetime)
273
274/**
275 @param [in] sp_runtime_context stored program runtime context.
276 If null, current runtime context will
277 be used.
278 @param [in] index Argument position
279 @param [out] year Year part
280 @param [out] month Month of the year
281 @param [out] day Day of the month
282 @param [out] hour Hour of the day
283 @param [out] minute Minute of the hour
284 @param [out] second Second of the minute
285 @param [out] micro Micro second of the second
286 @param [out] negative Is negative
287 @param [out] time_zone_offset Time zone offset in seconds
288 @param [out] is_null Flag to indicate if value is null
289
290 @returns Status of operation
291 @retval false Success
292 @retval true Error
293*/
294
296 uint16_t index, uint32_t *year, uint32_t *month,
297 uint32_t *day, uint32_t *hour, uint32_t *minute,
298 uint32_t *second, uint64_t *micro, bool *negative,
299 int32_t *time_zone_offset, bool *is_null));
300
301/**
302 @param [in] sp_runtime_context stored program runtime context.
303 If null, current runtime context will be
304 used.
305 @param [in] index Argument position
306 @param [in] year Year part
307 @param [in] month Month of the year
308 @param [in] day Day of the month
309 @param [in] hour Hour of the day
310 @param [in] minute Minute of the hour
311 @param [in] second Second of the minute
312 @param [in] micro Micro second of the second
313 @param [in] negative Is negative
314 @param [in] decimals Precision information
315 @param [in] time_zone_offset Time zone offset in seconds
316 @param [in] time_zone_aware Is time zone aware
317
318 @returns Status of operation
319 @retval false Success
320 @retval true Error
321*/
322
324 uint16_t index, uint32_t year, uint32_t month,
325 uint32_t day, uint32_t hour, uint32_t minute,
326 uint32_t second, uint64_t micro, bool negative,
327 uint32_t decimals, int32_t time_zone_offset,
328 bool time_zone_aware));
329
330END_SERVICE_DEFINITION(mysql_stored_program_runtime_argument_datetime)
331
332BEGIN_SERVICE_DEFINITION(mysql_stored_program_runtime_argument_timestamp)
333
334/**
335 @param [in] sp_runtime_context stored program runtime context.
336 If null, current runtime context will
337 be used.
338 @param [in] index Argument position
339 @param [out] year Year part
340 @param [out] month Month of the year
341 @param [out] day Day of the month
342 @param [out] hour Hour of the day
343 @param [out] minute Minute of the hour
344 @param [out] second Second of the minute
345 @param [out] micro Micro second of the second
346 @param [out] negative Is negative
347 @param [out] time_zone_offset Time zone offset in seconds
348 @param [out] is_null Flag to indicate if value is null
349
350 @returns Status of operation
351 @retval false Success
352 @retval true Error
353*/
354
356 uint16_t index, uint32_t *year, uint32_t *month,
357 uint32_t *day, uint32_t *hour, uint32_t *minute,
358 uint32_t *second, uint64_t *micro, bool *negative,
359 int32_t *time_zone_offset, bool *is_null));
360
361/**
362 @param [in] sp_runtime_context stored program runtime context.
363 If null, current runtime context will be
364 used.
365 @param [in] index Argument position
366 @param [in] year Year part
367 @param [in] month Month of the year
368 @param [in] day Day of the month
369 @param [in] hour Hour of the day
370 @param [in] minute Minute of the hour
371 @param [in] second Second of the minute
372 @param [in] micro Micro second of the second
373 @param [in] negative Is negative
374 @param [in] decimals Precision information
375 @param [in] time_zone_offset Time zone offset in seconds
376 @param [in] time_zone_aware Is time zone aware
377
378 @returns Status of operation
379 @retval false Success
380 @retval true Error
381*/
382
384 uint16_t index, uint32_t year, uint32_t month,
385 uint32_t day, uint32_t hour, uint32_t minute,
386 uint32_t second, uint64_t micro, bool negative,
387 uint32_t decimals, int32_t time_zone_offset,
388 bool time_zone_aware));
389
390END_SERVICE_DEFINITION(mysql_stored_program_runtime_argument_timestamp)
391
392BEGIN_SERVICE_DEFINITION(mysql_stored_program_runtime_argument_null)
393
394/**
395 Set null value
396
397 @param [in] sp_runtime_context stored program runtime context.
398 If null, current runtime context will be
399 used.
400 @param [in] index Argument position
401
402 @returns Status of operation
403 @retval false Success
404 @retval true Error
405*/
406
408 uint16_t index));
409END_SERVICE_DEFINITION(mysql_stored_program_runtime_argument_null)
410
411BEGIN_SERVICE_DEFINITION(mysql_stored_program_runtime_argument_string)
412
413/**
414 Get value of a string argument
415
416 @param [in] sp_runtime_context stored program runtime context.
417 If null, current runtime context will be
418 used.
419 @param [in] index Argument position
420 @param [out] value A pointer to the current value
421 @param [out] length Length of the current value
422 @param [out] is_null Flag to indicate if value is null
423
424 @returns Status of operation
425 @retval false Success
426 @retval true Error
427*/
428
430 uint16_t index, char const **value, size_t *length,
431 bool *is_null));
432/**
433 Set value of a string argument
434
435 @param [in] sp_runtime_context stored program runtime context.
436 If null, current runtime context will be
437 used.
438 @param [in] index Argument position
439 @param [in] string Value of the argument
440 @param [in] length Length of the string
441
442 @returns Status of operation
443 @retval false Success
444 @retval true Error
445*/
446
448 uint16_t index, char const *string, size_t length));
449
450END_SERVICE_DEFINITION(mysql_stored_program_runtime_argument_string)
451
452BEGIN_SERVICE_DEFINITION(mysql_stored_program_runtime_argument_int)
453
454/**
455 Get value of an int argument
456
457 @param [in] sp_runtime_context stored program runtime context.
458 If null, current runtime context will be
459 used.
460 @param [in] index Argument position
461 @param [out] result Value of the argument
462 @param [out] is_null Flag to indicate if value is null
463
464 @returns Status of operation
465 @retval false Success
466 @retval true Error
467*/
468
470 uint16_t index, int64_t *result, bool *is_null));
471
472/**
473 Set value of an int argument
474
475 @param [in] sp_runtime_context stored program runtime context.
476 If null, current runtime context will be
477 used.
478 @param [in] index Argument position
479 @param [in] value Value to be set
480
481 @returns Status of operation
482 @retval false Success
483 @retval true Error
484*/
485
487 uint16_t index, int64_t value));
488
489END_SERVICE_DEFINITION(mysql_stored_program_runtime_argument_int)
490
491BEGIN_SERVICE_DEFINITION(mysql_stored_program_runtime_argument_unsigned_int)
492
493/**
494 Get value of an unsigned int argument
495
496 @param [in] sp_runtime_context stored program runtime context.
497 If null, current runtime context will be
498 used.
499 @param [in] index Argument position
500 @param [out] result Value of the argument
501 @param [out] is_null Flag to indicate if value is null
502
503 @returns Status of operation
504 @retval false Success
505 @retval true Error
506*/
507
509 uint16_t index, uint64_t *result, bool *is_null));
510
511/**
512 Set value of an unsigned int argument
513
514 @param [in] sp_runtime_context stored program runtime context.
515 If null, current runtime context will be
516 used.
517 @param [in] index Argument position
518 @param [in] value Value to be set
519
520 @returns Status of operation
521 @retval false Success
522 @retval true Error
523*/
524
526 uint16_t index, uint64_t value));
527
528END_SERVICE_DEFINITION(mysql_stored_program_runtime_argument_unsigned_int)
529
530BEGIN_SERVICE_DEFINITION(mysql_stored_program_runtime_argument_float)
531
532/**
533 Get a float value
534
535 @param [in] sp_runtime_context stored program runtime context.
536 If null, current runtime context will be
537 used.
538 @param [in] index Argument position
539 @param [out] result Value of the argument
540 @param [out] is_null Flag to indicate if value is null
541
542 @returns Status of operation
543 @retval false Success
544 @retval true Error
545*/
546
548 uint16_t index, double *result, bool *is_null));
549
550/**
551 Set value of a float argument
552
553 @param [in] sp_runtime_context stored program runtime context.
554 If null, current runtime context will be
555 used.
556 @param [in] index Argument position
557 @param [in] value value to be set
558
559 @returns Status of operation
560 @retval false Success
561 @retval true Error
562*/
563
565 uint16_t index, double value));
566
567END_SERVICE_DEFINITION(mysql_stored_program_runtime_argument_float)
568
569BEGIN_SERVICE_DEFINITION(mysql_stored_program_return_value_year)
570
571/**
572 @param [in] sp_runtime_context stored program runtime context.
573 If null, current runtime context will be
574 used.
575 @param [in] year Year
576
577 @returns Status of operation
578 @retval false Success
579 @retval true Error
580*/
581
583 uint32_t year));
584
585END_SERVICE_DEFINITION(mysql_stored_program_return_value_year)
586
587BEGIN_SERVICE_DEFINITION(mysql_stored_program_return_value_time)
588
589/**
590 @param [in] sp_runtime_context stored program runtime context.
591 If null, current runtime context will be
592 used.
593 @param [in] hour Hour of the day
594 @param [in] minute Minute of the hour
595 @param [in] second Second of the minute
596 @param [in] micro Micro second of the second
597 @param [in] negative Is negative
598 @param [in] decimals Precision information
599
600 @returns Status of operation
601 @retval false Success
602 @retval true Error
603*/
604
606 uint32_t hour, uint32_t minute, uint32_t second,
607 uint64_t micro, bool negative, uint8_t decimals));
608
609END_SERVICE_DEFINITION(mysql_stored_program_return_value_time)
610
611BEGIN_SERVICE_DEFINITION(mysql_stored_program_return_value_date)
612
613/**
614 @param [in] sp_runtime_context stored program runtime context.
615 If null, current runtime context will be
616 used.
617 @param [in] year Year information
618 @param [in] month Month of the year
619 @param [in] day Day of the month
620
621 @returns Status of operation
622 @retval false Success
623 @retval true Error
624*/
625
627 uint32_t year, uint32_t month, uint32_t day));
628
629END_SERVICE_DEFINITION(mysql_stored_program_return_value_date)
630
631BEGIN_SERVICE_DEFINITION(mysql_stored_program_return_value_datetime)
632
633/**
634 @param [in] sp_runtime_context stored program runtime context.
635 If null, current runtime context will be
636 used.
637 @param [in] year Year part
638 @param [in] month Month of the year
639 @param [in] day Day of the month
640 @param [in] hour Hour of the day
641 @param [in] minute Minute of the hour
642 @param [in] second Second of the minute
643 @param [in] micro Micro second of the second
644 @param [in] negative Is negative
645 @param [in] decimals Precision information
646 @param [in] time_zone_offset Time zone offset in seconds
647 @param [in] time_zone_aware Is time zone aware
648
649 @returns Status of operation
650 @retval false Success
651 @retval true Error
652*/
653
655 uint32_t year, uint32_t month, uint32_t day,
656 uint32_t hour, uint32_t minute, uint32_t second,
657 uint64_t micro, bool negative, uint32_t decimals,
658 int32_t time_zone_offset, bool time_zone_aware));
659
660END_SERVICE_DEFINITION(mysql_stored_program_return_value_datetime)
661
662BEGIN_SERVICE_DEFINITION(mysql_stored_program_return_value_timestamp)
663
664/**
665 @param [in] sp_runtime_context stored program runtime context.
666 If null, current runtime context will be
667 used.
668 @param [in] year Year part
669 @param [in] month Month of the year
670 @param [in] day Day of the month
671 @param [in] hour Hour of the day
672 @param [in] minute Minute of the hour
673 @param [in] second Second of the minute
674 @param [in] micro Micro second of the second
675 @param [in] negative Is negative
676 @param [in] decimals Precision information
677 @param [in] time_zone_offset Time zone offset in seconds
678 @param [in] time_zone_aware Is time zone aware
679
680 @returns Status of operation
681 @retval false Success
682 @retval true Error
683*/
684
686 uint32_t year, uint32_t month, uint32_t day,
687 uint32_t hour, uint32_t minute, uint32_t second,
688 uint64_t micro, bool negative, uint32_t decimals,
689 int32_t time_zone_offset, bool time_zone_aware));
690
691END_SERVICE_DEFINITION(mysql_stored_program_return_value_timestamp)
692
693BEGIN_SERVICE_DEFINITION(mysql_stored_program_return_value_null)
694
695/**
696 Set null value
697
698 @param [in] sp_runtime_context stored program runtime context.
699 If null, current runtime context will be
700 used.
701
702 @returns Status of operation
703 @retval false Success
704 @retval true Error
705*/
706
708END_SERVICE_DEFINITION(mysql_stored_program_return_value_null)
709
710BEGIN_SERVICE_DEFINITION(mysql_stored_program_return_value_string)
711
712/**
713 Set value of a string return value
714
715 @param [in] sp_runtime_context stored program runtime context.
716 If null, current runtime context will be
717 used.
718 @param [in] string Value of the argument
719 @param [in] length Length of the string
720
721 @returns Status of operation
722 @retval false Success
723 @retval true Error
724*/
725
727 char const *string, size_t length));
728
729END_SERVICE_DEFINITION(mysql_stored_program_return_value_string)
730
731BEGIN_SERVICE_DEFINITION(mysql_stored_program_return_value_int)
732
733/**
734 Set value of an int return value
735
736 @param [in] sp_runtime_context stored program runtime context.
737 If null, current runtime context will be
738 used.
739 @param [in] value Value to be set
740
741 @returns Status of operation
742 @retval false Success
743 @retval true Error
744*/
745
747 int64_t value));
748
749END_SERVICE_DEFINITION(mysql_stored_program_return_value_int)
750
751BEGIN_SERVICE_DEFINITION(mysql_stored_program_return_value_unsigned_int)
752
753/**
754 Set value of an unsigned int return value
755
756 @param [in] sp_runtime_context stored program runtime context.
757 If null, current runtime context will be
758 used.
759 @param [in] value Value to be set
760
761 @returns Status of operation
762 @retval false Success
763 @retval true Error
764*/
765
767 uint64_t value));
768
769END_SERVICE_DEFINITION(mysql_stored_program_return_value_unsigned_int)
770
771BEGIN_SERVICE_DEFINITION(mysql_stored_program_return_value_float)
772
773/**
774 Set value of a float return value
775
776 @param [in] sp_runtime_context stored program runtime context.
777 If null, current runtime context will be
778 used.
779 @param [in] value value to be set
780
781 @returns Status of operation
782 @retval false Success
783 @retval true Error
784*/
785
787 double value));
788
789END_SERVICE_DEFINITION(mysql_stored_program_return_value_float)
790#endif /* MYSQL_STORED_PROGRAM_H */
struct stored_program_handle_imp * stored_program_handle
The handle is an opaque pointer to a sp_head item.
Definition: language_service.h:41
struct stored_program_runtime_context_imp * stored_program_runtime_context
Definition: mysql_stored_program.h:33
struct time_zone_handle_imp * time_zone_handle
Definition: mysql_stored_program.h:34
String related data structures.
bool length(const dd::Spatial_reference_system *srs, const Geometry *g1, double *length, bool *null) noexcept
Computes the length of linestrings and multilinestrings.
Definition: length.cc:75
void get(PSI_field *, PSI_longlong *) noexcept
Definition: pfs_plugin_column_bigint_v1_all_empty.cc:31
std::set< Key, Compare, ut::allocator< Key > > set
Specialization of set which uses ut_allocator.
Definition: ut0new.h:2881
required string key
Definition: replication_asynchronous_connection_failover.proto:59
#define END_SERVICE_DEFINITION(name)
A macro to end the last Service definition started with the BEGIN_SERVICE_DEFINITION macro.
Definition: service.h:90
#define BEGIN_SERVICE_DEFINITION(name)
Declares a new Service.
Definition: service.h:85
#define DEFINE_SERVICE_HANDLE(name)
Defines an object type that is meant for carrying handles to the implementation-specific objects used...
Definition: service.h:128
#define DECLARE_BOOL_METHOD(name, args)
Declares a method that returns bool as a part of the Service definition.
Definition: service.h:111
Definition: result.h:29