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