MySQL 9.2.0
Source Code Documentation
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages Concepts
mysql_stored_program.h
Go to the documentation of this file.
1/* Copyright (c) 2022, 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_STORED_PROGRAM_H
25#define MYSQL_STORED_PROGRAM_H
26
29#include <cstddef> // size_t
30#include <cstdint> // intXX_t
33
38
39/**
40 @file
41 Services for reading and storing various stored program properties
42 of the server stored program's object and its contexts.
43*/
44
45BEGIN_SERVICE_DEFINITION(mysql_stored_program_metadata_query)
46
47/**
48 Get stored program data
49
50 Accepted keys and corresponding data type
51
52 "sp_name" -> mysql_cstring_with_length *
53 "database_name" -> mysql_cstring_with_length *
54 "qualified_name" -> mysql_cstring_with_length *
55 "sp_language" -> mysql_cstring_with_length *
56 "sp_body" -> mysql_cstring_with_length *
57 "sp_type" -> uint16_t
58 "argument_count" -> uint32_t
59 "import_count" -> uint32_t
60
61 @param [in] sp_handle Handle to stored procedure structure
62 @param [in] key Metadata name
63 @param [out] value Metadata value
64
65 @returns Status of operation
66 @retval false Success
67 @retval true Failure
68*/
69
70DECLARE_BOOL_METHOD(get, (stored_program_handle sp_handle, const char *key,
71 void *value));
72
73END_SERVICE_DEFINITION(mysql_stored_program_metadata_query)
74
75/*
76 * Argument-related services:
77 */
78
79BEGIN_SERVICE_DEFINITION(mysql_stored_program_argument_metadata_query)
80
81/**
82 Get stored program argument metadata
83
84 "argument_name" -> const char *
85 "sql_type" -> uint64_t
86 "in_variable" -> boolean
87 "out_variable" -> boolean
88 "is_signed" -> boolean (Applicable to numeric data types)
89 "is_nullable" -> boolean
90 "byte_length" -> uint64_t
91 "char_length" -> uint64_t (Applicable to string data types)
92 "charset" -> char const *
93
94 @param [in] sp_handle Handle to stored procedure structure
95 @param [in] index Argument index
96 @param [in] key Metadata name
97 @param [out] value Metadata value
98
99
100 @returns status of get operation
101 @retval false Success
102 @retval true Failure
103*/
104
105DECLARE_BOOL_METHOD(get, (stored_program_handle sp_handle, uint16_t index,
106 const char *key, void *value));
107
108END_SERVICE_DEFINITION(mysql_stored_program_argument_metadata_query)
109
110BEGIN_SERVICE_DEFINITION(mysql_stored_program_return_metadata_query)
111
112/**
113 Get stored program return value metadata
114
115 "argument_name" -> const char *
116 "sql_type" -> uint64_t
117 "is_signed" -> boolean (Applicable to numeric data types)
118 "is_nullable" -> boolean
119 "byte_length" -> uint64_t
120 "char_length" -> uint64_t (Applicable to string data types)
121 "charset" -> char const *
122
123 @param [in] sp_handle Handle to stored procedure structure
124 @param [in] key Metadata name
125 @param [out] value Metadata value
126
127
128 @returns status of get operation
129 @retval false Success
130 @retval true Failure
131*/
132
133DECLARE_BOOL_METHOD(get, (stored_program_handle sp_handle, const char *key,
134 void *value));
135
136END_SERVICE_DEFINITION(mysql_stored_program_return_metadata_query)
137
138BEGIN_SERVICE_DEFINITION(mysql_stored_program_field_name)
139
140/**
141 Returns the field name of the return value
142 @param [in] sp_runtime_context stored program runtime context.
143 If null, current runtime context
144 will be used.
145 @param [out] value The field name of the return value
146
147
148 @returns status of get operation
149 @retval false Success
150 @retval true Failure
151*/
152
154 char const **value));
155
156END_SERVICE_DEFINITION(mysql_stored_program_field_name)
157
158BEGIN_SERVICE_DEFINITION(mysql_stored_program_runtime_argument_year)
159
160/**
161 @param [in] sp_runtime_context stored program runtime context.
162 If null, current runtime context will
163 be used.
164 @param [in] index Argument position
165 @param [out] year Year
166 @param [out] is_null Flag to indicate if value is null
167
168 @returns Status of operation
169 @retval false Success
170 @retval true Error
171*/
172
174 uint16_t index, uint32_t *year, bool *is_null));
175
176/**
177 @param [in] sp_runtime_context stored program runtime context.
178 If null, current runtime context will be
179 used.
180 @param [in] index Argument location
181 @param [in] year Year
182
183 @returns Status of operation
184 @retval false Success
185 @retval true Error
186*/
187
189 uint16_t index, uint32_t year));
190
191END_SERVICE_DEFINITION(mysql_stored_program_runtime_argument_year)
192
193BEGIN_SERVICE_DEFINITION(mysql_stored_program_runtime_argument_time)
194
195/**
196 @param [in] sp_runtime_context stored program runtime context.
197 If null, current runtime context will
198 be used.
199 @param [in] index Argument position
200 @param [out] hour Hour of the day
201 @param [out] minute Minute of the hour
202 @param [out] second Second of the minute
203 @param [out] micro Micro second of the second
204 @param [out] negative Is negative
205 @param [out] is_null Flag to indicate if value is null
206
207 @returns Status of operation
208 @retval false Success
209 @retval true Error
210*/
211
213 uint16_t index, uint32_t *hour, uint32_t *minute,
214 uint32_t *second, uint64_t *micro, bool *negative,
215 bool *is_null));
216
217/**
218 @param [in] sp_runtime_context stored program runtime context.
219 If null, current runtime context will be
220 used.
221 @param [in] index Argument location
222 @param [in] hour Hour of the day
223 @param [in] minute Minute of the hour
224 @param [in] second Second of the minute
225 @param [in] micro Micro second of the second
226 @param [in] negative Is negative
227 @param [in] decimals Precision information
228
229 @returns Status of operation
230 @retval false Success
231 @retval true Error
232*/
233
235 uint16_t index, uint32_t hour, uint32_t minute,
236 uint32_t second, uint64_t micro, bool negative,
237 uint8_t decimals));
238
239END_SERVICE_DEFINITION(mysql_stored_program_runtime_argument_time)
240
241BEGIN_SERVICE_DEFINITION(mysql_stored_program_runtime_argument_date)
242
243/**
244 @param [in] sp_runtime_context stored program runtime context.
245 If null, current runtime context will be
246 used.
247 @param [in] index Argument position
248 @param [out] year Year information
249 @param [out] month Month of the year
250 @param [out] day Day of the month
251 @param [out] is_null Flag to indicate if value is null
252
253 @returns Status of operation
254 @retval false Success
255 @retval true Error
256*/
257
259 uint16_t index, uint32_t *year, uint32_t *month,
260 uint32_t *day, bool *is_null));
261
262/**
263 @param [in] sp_runtime_context stored program runtime context.
264 If null, current runtime context will be
265 used.
266 @param [in] index Argument position
267 @param [in] year Year information
268 @param [in] month Month of the year
269 @param [in] day Day of the month
270
271 @returns Status of operation
272 @retval false Success
273 @retval true Error
274*/
275
277 uint16_t index, uint32_t year, uint32_t month,
278 uint32_t day));
279
280END_SERVICE_DEFINITION(mysql_stored_program_runtime_argument_date)
281
282BEGIN_SERVICE_DEFINITION(mysql_stored_program_runtime_argument_datetime)
283
284/**
285 @param [in] sp_runtime_context stored program runtime context.
286 If null, current runtime context will
287 be used.
288 @param [in] index Argument position
289 @param [out] year Year part
290 @param [out] month Month of the year
291 @param [out] day Day of the month
292 @param [out] hour Hour of the day
293 @param [out] minute Minute of the hour
294 @param [out] second Second of the minute
295 @param [out] micro Micro second of the second
296 @param [out] negative Is negative
297 @param [out] time_zone_offset Time zone offset in seconds
298 @param [out] is_null Flag to indicate if value is null
299
300 @returns Status of operation
301 @retval false Success
302 @retval true Error
303*/
304
306 uint16_t index, uint32_t *year, uint32_t *month,
307 uint32_t *day, uint32_t *hour, uint32_t *minute,
308 uint32_t *second, uint64_t *micro, bool *negative,
309 int32_t *time_zone_offset, bool *is_null));
310
311/**
312 @param [in] sp_runtime_context stored program runtime context.
313 If null, current runtime context will be
314 used.
315 @param [in] index Argument position
316 @param [in] year Year part
317 @param [in] month Month of the year
318 @param [in] day Day of the month
319 @param [in] hour Hour of the day
320 @param [in] minute Minute of the hour
321 @param [in] second Second of the minute
322 @param [in] micro Micro second of the second
323 @param [in] negative Is negative
324 @param [in] decimals Precision information
325 @param [in] time_zone_offset Time zone offset in seconds
326 @param [in] time_zone_aware Is time zone aware
327
328 @returns Status of operation
329 @retval false Success
330 @retval true Error
331*/
332
334 uint16_t index, uint32_t year, uint32_t month,
335 uint32_t day, uint32_t hour, uint32_t minute,
336 uint32_t second, uint64_t micro, bool negative,
337 uint32_t decimals, int32_t time_zone_offset,
338 bool time_zone_aware));
339
340END_SERVICE_DEFINITION(mysql_stored_program_runtime_argument_datetime)
341
342BEGIN_SERVICE_DEFINITION(mysql_stored_program_runtime_argument_timestamp)
343
344/**
345 @param [in] sp_runtime_context stored program runtime context.
346 If null, current runtime context will
347 be used.
348 @param [in] index Argument position
349 @param [out] year Year part
350 @param [out] month Month of the year
351 @param [out] day Day of the month
352 @param [out] hour Hour of the day
353 @param [out] minute Minute of the hour
354 @param [out] second Second of the minute
355 @param [out] micro Micro second of the second
356 @param [out] negative Is negative
357 @param [out] time_zone_offset Time zone offset in seconds
358 @param [out] is_null Flag to indicate if value is null
359
360 @returns Status of operation
361 @retval false Success
362 @retval true Error
363*/
364
366 uint16_t index, uint32_t *year, uint32_t *month,
367 uint32_t *day, uint32_t *hour, uint32_t *minute,
368 uint32_t *second, uint64_t *micro, bool *negative,
369 int32_t *time_zone_offset, bool *is_null));
370
371/**
372 @param [in] sp_runtime_context stored program runtime context.
373 If null, current runtime context will be
374 used.
375 @param [in] index Argument position
376 @param [in] year Year part
377 @param [in] month Month of the year
378 @param [in] day Day of the month
379 @param [in] hour Hour of the day
380 @param [in] minute Minute of the hour
381 @param [in] second Second of the minute
382 @param [in] micro Micro second of the second
383 @param [in] negative Is negative
384 @param [in] decimals Precision information
385 @param [in] time_zone_offset Time zone offset in seconds
386 @param [in] time_zone_aware Is time zone aware
387
388 @returns Status of operation
389 @retval false Success
390 @retval true Error
391*/
392
394 uint16_t index, uint32_t year, uint32_t month,
395 uint32_t day, uint32_t hour, uint32_t minute,
396 uint32_t second, uint64_t micro, bool negative,
397 uint32_t decimals, int32_t time_zone_offset,
398 bool time_zone_aware));
399
400END_SERVICE_DEFINITION(mysql_stored_program_runtime_argument_timestamp)
401
402BEGIN_SERVICE_DEFINITION(mysql_stored_program_runtime_argument_null)
403
404/**
405 Set null value
406
407 @param [in] sp_runtime_context stored program runtime context.
408 If null, current runtime context will be
409 used.
410 @param [in] index Argument position
411
412 @returns Status of operation
413 @retval false Success
414 @retval true Error
415*/
416
418 uint16_t index));
419END_SERVICE_DEFINITION(mysql_stored_program_runtime_argument_null)
420
421BEGIN_SERVICE_DEFINITION(mysql_stored_program_runtime_argument_string)
422
423/**
424 Get value of a string argument
425
426 @param [in] sp_runtime_context stored program runtime context.
427 If null, current runtime context will be
428 used.
429 @param [in] index Argument position
430 @param [out] value A pointer to the current value
431 @param [out] length Length of the current value
432 @param [out] is_null Flag to indicate if value is null
433
434 @returns Status of operation
435 @retval false Success
436 @retval true Error
437*/
438
440 uint16_t index, char const **value, size_t *length,
441 bool *is_null));
442/**
443 Set value of a string argument with utf8mb4 as charset
444
445 @param [in] sp_runtime_context stored program runtime context.
446 If null, current runtime context will be
447 used.
448 @param [in] index Argument position
449 @param [in] string Value of the argument
450 @param [in] length Length of the string
451
452 @returns Status of operation
453 @retval false Success
454 @retval true Error
455*/
456
458 uint16_t index, char const *string, size_t length));
459
460END_SERVICE_DEFINITION(mysql_stored_program_runtime_argument_string)
461
462BEGIN_SERVICE_DEFINITION(mysql_stored_program_runtime_argument_string_charset)
463/**
464 Set value of a string argument
465
466 @param [in] sp_runtime_context stored program runtime context.
467 If null, current runtime context will be
468 used.
469 @param [in] index Argument position
470 @param [in] string Value of the argument
471 @param [in] length Length of the string
472 @param [in] charset The character set of the string
473
474 @returns Status of operation
475 @retval false Success
476 @retval true Error
477*/
479 uint16_t index, char const *string, size_t length,
481END_SERVICE_DEFINITION(mysql_stored_program_runtime_argument_string_charset)
482
483BEGIN_SERVICE_DEFINITION(mysql_stored_program_runtime_argument_int)
484
485/**
486 Get value of an int argument
487
488 @param [in] sp_runtime_context stored program runtime context.
489 If null, current runtime context will be
490 used.
491 @param [in] index Argument position
492 @param [out] result Value of the argument
493 @param [out] is_null Flag to indicate if value is null
494
495 @returns Status of operation
496 @retval false Success
497 @retval true Error
498*/
499
501 uint16_t index, int64_t *result, bool *is_null));
502
503/**
504 Set value of an int argument
505
506 @param [in] sp_runtime_context stored program runtime context.
507 If null, current runtime context will be
508 used.
509 @param [in] index Argument position
510 @param [in] value Value to be set
511
512 @returns Status of operation
513 @retval false Success
514 @retval true Error
515*/
516
518 uint16_t index, int64_t value));
519
520END_SERVICE_DEFINITION(mysql_stored_program_runtime_argument_int)
521
522BEGIN_SERVICE_DEFINITION(mysql_stored_program_runtime_argument_unsigned_int)
523
524/**
525 Get value of an unsigned int argument
526
527 @param [in] sp_runtime_context stored program runtime context.
528 If null, current runtime context will be
529 used.
530 @param [in] index Argument position
531 @param [out] result Value of the argument
532 @param [out] is_null Flag to indicate if value is null
533
534 @returns Status of operation
535 @retval false Success
536 @retval true Error
537*/
538
540 uint16_t index, uint64_t *result, bool *is_null));
541
542/**
543 Set value of an unsigned int argument
544
545 @param [in] sp_runtime_context stored program runtime context.
546 If null, current runtime context will be
547 used.
548 @param [in] index Argument position
549 @param [in] value Value to be set
550
551 @returns Status of operation
552 @retval false Success
553 @retval true Error
554*/
555
557 uint16_t index, uint64_t value));
558
559END_SERVICE_DEFINITION(mysql_stored_program_runtime_argument_unsigned_int)
560
561BEGIN_SERVICE_DEFINITION(mysql_stored_program_runtime_argument_float)
562
563/**
564 Get a float value
565
566 @param [in] sp_runtime_context stored program runtime context.
567 If null, current runtime context will be
568 used.
569 @param [in] index Argument position
570 @param [out] result Value of the argument
571 @param [out] is_null Flag to indicate if value is null
572
573 @returns Status of operation
574 @retval false Success
575 @retval true Error
576*/
577
579 uint16_t index, double *result, bool *is_null));
580
581/**
582 Set value of a float argument
583
584 @param [in] sp_runtime_context stored program runtime context.
585 If null, current runtime context will be
586 used.
587 @param [in] index Argument position
588 @param [in] value value to be set
589
590 @returns Status of operation
591 @retval false Success
592 @retval true Error
593*/
594
596 uint16_t index, double value));
597
598END_SERVICE_DEFINITION(mysql_stored_program_runtime_argument_float)
599
600BEGIN_SERVICE_DEFINITION(mysql_stored_program_return_value_year)
601
602/**
603 @param [in] sp_runtime_context stored program runtime context.
604 If null, current runtime context will be
605 used.
606 @param [in] year Year
607
608 @returns Status of operation
609 @retval false Success
610 @retval true Error
611*/
612
614 uint32_t year));
615
616END_SERVICE_DEFINITION(mysql_stored_program_return_value_year)
617
618BEGIN_SERVICE_DEFINITION(mysql_stored_program_return_value_time)
619
620/**
621 @param [in] sp_runtime_context stored program runtime context.
622 If null, current runtime context will be
623 used.
624 @param [in] hour Hour of the day
625 @param [in] minute Minute of the hour
626 @param [in] second Second of the minute
627 @param [in] micro Micro second of the second
628 @param [in] negative Is negative
629 @param [in] decimals Precision information
630
631 @returns Status of operation
632 @retval false Success
633 @retval true Error
634*/
635
637 uint32_t hour, uint32_t minute, uint32_t second,
638 uint64_t micro, bool negative, uint8_t decimals));
639
640END_SERVICE_DEFINITION(mysql_stored_program_return_value_time)
641
642BEGIN_SERVICE_DEFINITION(mysql_stored_program_return_value_date)
643
644/**
645 @param [in] sp_runtime_context stored program runtime context.
646 If null, current runtime context will be
647 used.
648 @param [in] year Year information
649 @param [in] month Month of the year
650 @param [in] day Day of the month
651
652 @returns Status of operation
653 @retval false Success
654 @retval true Error
655*/
656
658 uint32_t year, uint32_t month, uint32_t day));
659
660END_SERVICE_DEFINITION(mysql_stored_program_return_value_date)
661
662BEGIN_SERVICE_DEFINITION(mysql_stored_program_return_value_datetime)
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_datetime)
692
693BEGIN_SERVICE_DEFINITION(mysql_stored_program_return_value_timestamp)
694
695/**
696 @param [in] sp_runtime_context stored program runtime context.
697 If null, current runtime context will be
698 used.
699 @param [in] year Year part
700 @param [in] month Month of the year
701 @param [in] day Day of the month
702 @param [in] hour Hour of the day
703 @param [in] minute Minute of the hour
704 @param [in] second Second of the minute
705 @param [in] micro Micro second of the second
706 @param [in] negative Is negative
707 @param [in] decimals Precision information
708 @param [in] time_zone_offset Time zone offset in seconds
709 @param [in] time_zone_aware Is time zone aware
710
711 @returns Status of operation
712 @retval false Success
713 @retval true Error
714*/
715
717 uint32_t year, uint32_t month, uint32_t day,
718 uint32_t hour, uint32_t minute, uint32_t second,
719 uint64_t micro, bool negative, uint32_t decimals,
720 int32_t time_zone_offset, bool time_zone_aware));
721
722END_SERVICE_DEFINITION(mysql_stored_program_return_value_timestamp)
723
724BEGIN_SERVICE_DEFINITION(mysql_stored_program_return_value_null)
725
726/**
727 Set null value
728
729 @param [in] sp_runtime_context stored program runtime context.
730 If null, current runtime context will be
731 used.
732
733 @returns Status of operation
734 @retval false Success
735 @retval true Error
736*/
737
739END_SERVICE_DEFINITION(mysql_stored_program_return_value_null)
740
741BEGIN_SERVICE_DEFINITION(mysql_stored_program_return_value_string)
742
743/**
744 Set value of a string return value with utf8mb4 as charset
745
746 @param [in] sp_runtime_context stored program runtime context.
747 If null, current runtime context will be
748 used.
749 @param [in] string Value of the argument
750 @param [in] length Length of the string
751
752 @returns Status of operation
753 @retval false Success
754 @retval true Error
755*/
756
758 char const *string, size_t length));
759
760END_SERVICE_DEFINITION(mysql_stored_program_return_value_string)
761
762BEGIN_SERVICE_DEFINITION(mysql_stored_program_return_value_string_charset)
763/**
764 Set value of a string return value
765
766 @param [in] sp_runtime_context stored program runtime context.
767 If null, current runtime context will be
768 used.
769 @param [in] string Value of the argument
770 @param [in] length Length of the string
771 @param [in] charset The character set of the input string
772
773 @returns Status of operation
774 @retval false Success
775 @retval true Error
776*/
778 char const *string, size_t length,
780END_SERVICE_DEFINITION(mysql_stored_program_return_value_string_charset)
781
782BEGIN_SERVICE_DEFINITION(mysql_stored_program_return_value_int)
783
784/**
785 Set value of an int return value
786
787 @param [in] sp_runtime_context stored program runtime context.
788 If null, current runtime context will be
789 used.
790 @param [in] value Value to be set
791
792 @returns Status of operation
793 @retval false Success
794 @retval true Error
795*/
796
798 int64_t value));
799
800END_SERVICE_DEFINITION(mysql_stored_program_return_value_int)
801
802BEGIN_SERVICE_DEFINITION(mysql_stored_program_return_value_unsigned_int)
803
804/**
805 Set value of an unsigned int return value
806
807 @param [in] sp_runtime_context stored program runtime context.
808 If null, current runtime context will be
809 used.
810 @param [in] value Value to be set
811
812 @returns Status of operation
813 @retval false Success
814 @retval true Error
815*/
816
818 uint64_t value));
819
820END_SERVICE_DEFINITION(mysql_stored_program_return_value_unsigned_int)
821
822BEGIN_SERVICE_DEFINITION(mysql_stored_program_return_value_float)
823
824/**
825 Set value of a float return value
826
827 @param [in] sp_runtime_context stored program runtime context.
828 If null, current runtime context will be
829 used.
830 @param [in] value value to be set
831
832 @returns Status of operation
833 @retval false Success
834 @retval true Error
835*/
836
838 double value));
839
840END_SERVICE_DEFINITION(mysql_stored_program_return_value_float)
841
842/**
843 @ingroup group_components_services_stored_programs
844
845 Service to get and change the stored program's external language handle.
846
847 In general, the server stored program object does handle
848 the lifetime of the external language objects.
849 It initiates the creation, parsing, execution and destruction of such objects.
850 But, in rare cases, the external language component may request the server to
851 change its external language object. Example of such cases are:
852 * The stored program is aborted. The external language object needs to be
853 destroyed and detached from the server object.
854 * The session was reset. Either by explicit user demand, or when incompatible
855 changes happen such as timezone change. All of its objects need to be
856 destroyed and detached.
857 * The limit of external language objects is reached. The oldest objects
858 may be destroyed and detached.
859 * The limit of external language sessions is reached. The oldest sessions
860 may be destroyed, together with their language objects.
861 * The external language object is changed. The new object needs to replace
862 the existing one.
863 @note Both the external language session and external language object
864 services support lazy (re)initialization. The current object may be
865 detached and destroyed. When another request to
866 the same stored program comes, a new object will be created.
867
868 Used approximately as follows:
869
870 @code
871 // Get the current external_program_handle.
872 external_program_handle old_sp = nullptr;
873 if (SERVICE_PLACEHOLDER(mysql_stored_program_external_program_handle)
874 ->get(stored_program_handle, &old_sp))
875 return 1;
876
877 // Detach and destroy the current external_program_handle.
878 if (SERVICE_PLACEHOLDER(mysql_stored_program_external_program_handle)
879 ->set(stored_program_handle, nullptr))
880 return 1;
881 if (old_sp) destroy_stored_program(old_sp);
882
883 // Create and attach a new external_program_handle.
884 external_program_handle old_sp = create_stored_program();
885 return SERVICE_PLACEHOLDER(mysql_stored_program_external_program_handle)
886 ->set(stored_program_handle, nullptr);
887
888 external_program_handle new_sp = create_stored_program();
889 return SERVICE_PLACEHOLDER(mysql_stored_program_external_program_handle)
890 ->set(stored_program_handle, new_sp);
891
892 @endcode
893*/
894BEGIN_SERVICE_DEFINITION(mysql_stored_program_external_program_handle)
895
896/**
897 Obtain the currently attached Language Component's Stored Program
898 from the server object.
899 @note: Only stored_program_handle belonging to current thread are supported.
900
901 @param [in] sp stored_program_handle
902 @param [out] value Language Component's Stored Program.
903
904 @returns Status of operation
905 @retval false Success
906 @retval true Error
907*/
908
911
912/**
913 Attach or detach the Language Component's Stored Program from the server
914 object. In order to detach the current Stored Program from the server
915 - provide nullptr value.
916 @note: Only stored_program_handle belonging to current thread are supported.
917
918 @param [in] sp stored_program_handle
919 @param [in] value Language Component's Stored Program.
920 Use nullptr to detach the current value from the server.
921
922 @returns Status of operation
923 @retval false Success
924 @retval true Error
925*/
926
929
930END_SERVICE_DEFINITION(mysql_stored_program_external_program_handle)
931
932/*
933 * Import-related services:
934 */
935BEGIN_SERVICE_DEFINITION(mysql_stored_program_import_metadata_query)
936
937/**
938 Get stored program import metadata
939
940 @param [in] sp_handle Handle to stored procedure structure
941 @param [in] index Argument index
942 @param [out] schema_name Name of the schema where library is defined
943 @param [out] library_name Name of the library
944 @param [out] version Version of the library
945 @param [out] alias Alias, if provided. Returns nullptr if not
946 @param [out] extension Not used
947
948 @returns status of get operation
949 @retval false Success
950 @retval true Failure
951*/
952DECLARE_BOOL_METHOD(get, (stored_program_handle sp_handle, uint32_t index,
953 mysql_cstring_with_length *schema_name,
954 mysql_cstring_with_length *library_name,
956 mysql_cstring_with_length *alias, void *extension));
957
958END_SERVICE_DEFINITION(mysql_stored_program_import_metadata_query)
959
960#endif /* MYSQL_STORED_PROGRAM_H */
struct external_program_handle_imp * external_program_handle
The handle is created by the caller of external_program_execution service.
Definition: language_service.h:38
struct stored_program_handle_imp * stored_program_handle
The handle is an opaque pointer to a sp_head item.
Definition: language_service.h:43
struct stored_program_runtime_context_imp * stored_program_runtime_context
Definition: mysql_stored_program.h:35
struct time_zone_handle_imp * time_zone_handle
Definition: mysql_stored_program.h:36
struct CHARSET_INFO_h_imp * CHARSET_INFO_h
Definition: mysql_string.h:41
String related data structures.
const std::string charset("charset")
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:76
static mysql_service_status_t get(THD **thd) noexcept
Definition: mysql_current_thread_reader_all_empty.cc:31
std::set< Key, Compare, ut::allocator< Key > > set
Specialization of set which uses ut_allocator.
Definition: ut0new.h:2884
required string key
Definition: replication_asynchronous_connection_failover.proto:60
required uint64 version
Definition: replication_group_member_actions.proto:41
#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
String with length information.
Definition: mysql_string_defs.h:33
Definition: result.h:30