Skip to content

Commit 42d30d3

Browse files
committed
Revert "WL#15605 MLE Milestone 2"
This reverts commit 8b62ef53df9e09327b72dd722de6f9fed8a75886. gerrit: 24910 Change-Id: I53f20e13c96545fd3a18b1e88f500321126db2ae
1 parent 1b28404 commit 42d30d3

File tree

8 files changed

+1
-210
lines changed

8 files changed

+1
-210
lines changed

include/mysql/components/services/mysql_stored_program.h

-97
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,6 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
3232
DEFINE_SERVICE_HANDLE(stored_program_handle);
3333
DEFINE_SERVICE_HANDLE(stored_program_runtime_context);
3434
DEFINE_SERVICE_HANDLE(time_zone_handle);
35-
DEFINE_SERVICE_HANDLE(external_program_handle);
36-
37-
/**
38-
@file
39-
Services for reading and storing various stored program properties
40-
of the server stored program's object and its contexts.
41-
*/
4235

4336
BEGIN_SERVICE_DEFINITION(mysql_stored_program_metadata_query)
4437

@@ -794,94 +787,4 @@ DECLARE_BOOL_METHOD(set, (stored_program_runtime_context sp_runtime_context,
794787
double value));
795788

796789
END_SERVICE_DEFINITION(mysql_stored_program_return_value_float)
797-
798-
/**
799-
@ingroup group_components_services_stored_programs
800-
801-
Service to get and change the stored program's external language handle.
802-
803-
In general, the server stored program object does handle
804-
the lifetime of the external language objects.
805-
It initiates the creation, parsing, execution and destruction of such objects.
806-
But, in rare cases, the external language component may request the server to
807-
change its external language object. Example of such cases are:
808-
* The stored program is aborted. The external language object needs to be
809-
destroyed and detached from the server object.
810-
* The session was reset. Either by explicit user demand, or when incompatible
811-
changes happen such as timezone change. All of its objects need to be
812-
destroyed and detached.
813-
* The limit of external language objects is reached. The oldest objects
814-
may be destroyed and detached.
815-
* The limit of external language sessions is reached. The oldest sessions
816-
may be destroyed, together with their language objects.
817-
* The external language object is changed. The new object needs to replace
818-
the existing one.
819-
@note Both the external language session and external language object
820-
services support lazy (re)initialization. The current object may be
821-
detached and destroyed. When another request to
822-
the same stored program comes, a new object will be created.
823-
824-
Used approximately as follows:
825-
826-
@code
827-
// Get the current external_program_handle.
828-
external_program_handle old_sp = nullptr;
829-
if (SERVICE_PLACEHOLDER(mysql_stored_program_external_program_handle)
830-
->get(stored_program_handle, &old_sp))
831-
return 1;
832-
833-
// Detach and destroy the current external_program_handle.
834-
if (SERVICE_PLACEHOLDER(mysql_stored_program_external_program_handle)
835-
->set(stored_program_handle, nullptr))
836-
return 1;
837-
if (old_sp) destroy_stored_program(old_sp);
838-
839-
// Create and attach a new external_program_handle.
840-
external_program_handle old_sp = create_stored_program();
841-
return SERVICE_PLACEHOLDER(mysql_stored_program_external_program_handle)
842-
->set(stored_program_handle, nullptr);
843-
844-
external_program_handle new_sp = create_stored_program();
845-
return SERVICE_PLACEHOLDER(mysql_stored_program_external_program_handle)
846-
->set(stored_program_handle, new_sp);
847-
848-
@endcode
849-
*/
850-
BEGIN_SERVICE_DEFINITION(mysql_stored_program_external_program_handle)
851-
852-
/**
853-
Obtain the currently attached Language Component's Stored Program
854-
from the server object.
855-
@note: Only stored_program_handle belonging to current thread are supported.
856-
857-
@param [in] sp stored_program_handle
858-
@param [out] value Language Component's Stored Program.
859-
860-
@returns Status of operation
861-
@retval false Success
862-
@retval true Error
863-
*/
864-
865-
DECLARE_BOOL_METHOD(get,
866-
(stored_program_handle sp, external_program_handle *value));
867-
868-
/**
869-
Attach or detach the Language Component's Stored Program from the server
870-
object. In order to detach the current Stored Program from the server
871-
- provide nullptr value.
872-
@note: Only stored_program_handle belonging to current thread are supported.
873-
874-
@param [in] sp stored_program_handle
875-
@param [in] value Language Component's Stored Program.
876-
Use nullptr to detach the current value from the server.
877-
878-
@returns Status of operation
879-
@retval false Success
880-
@retval true Error
881-
*/
882-
883-
DECLARE_BOOL_METHOD(set,
884-
(stored_program_handle sp, external_program_handle value));
885-
886-
END_SERVICE_DEFINITION(mysql_stored_program_external_program_handle)
887790
#endif /* MYSQL_STORED_PROGRAM_H */

sql/server_component/mysql_stored_program_imp.cc

-40
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
2424
#include <cstring> // strcmp
2525
#include "mysql/components/services/bits/stored_program_bits.h" // stored_program_argument_type
2626
#include "mysql_time.h"
27-
#include "sql/current_thd.h"
2827
#include "sql/item_timefunc.h" // Item_time_literal
29-
#include "sql/sp_cache.h" // sp_cache
3028
#include "sql/sp_head.h" // sp_head
3129
#include "sql/sp_pcontext.h" // sp_runtime_ctx
3230
#include "sql/sp_rcontext.h"
@@ -1307,41 +1305,3 @@ DEFINE_BOOL_METHOD(mysql_stored_program_return_value_float_imp::set,
13071305
return MYSQL_FAILURE;
13081306
return MYSQL_SUCCESS;
13091307
}
1310-
1311-
/**
1312-
* @brief Ensure the modified sp_head is part of the current THD.
1313-
*
1314-
* @param sp_handle - opaque pointer.
1315-
* @return sp_head* if the opaque pointer's sp_head representation is part of
1316-
the current THD.
1317-
* @return nullptr if not.
1318-
*/
1319-
static auto is_sp_in_current_thd(stored_program_handle sp_handle) -> sp_head * {
1320-
assert(sp_handle);
1321-
if (!sp_handle) return {};
1322-
auto sp = reinterpret_cast<sp_head *>(sp_handle);
1323-
if (sp_cache_has(current_thd->sp_func_cache, sp)) return sp;
1324-
if (sp_cache_has(current_thd->sp_proc_cache, sp)) return sp;
1325-
assert(false);
1326-
return {};
1327-
}
1328-
1329-
DEFINE_BOOL_METHOD(mysql_stored_program_external_program_handle_imp::get,
1330-
(stored_program_handle sp_handle,
1331-
external_program_handle *value)) {
1332-
assert(value);
1333-
if (!value) return MYSQL_FAILURE;
1334-
1335-
auto sp = is_sp_in_current_thd(sp_handle);
1336-
if (!sp) return MYSQL_FAILURE;
1337-
*value = sp->get_external_program_handle();
1338-
return MYSQL_SUCCESS;
1339-
}
1340-
1341-
DEFINE_BOOL_METHOD(mysql_stored_program_external_program_handle_imp::set,
1342-
(stored_program_handle sp_handle,
1343-
external_program_handle value)) {
1344-
auto sp = is_sp_in_current_thd(sp_handle);
1345-
if (!sp) return MYSQL_FAILURE;
1346-
return sp->set_external_program_handle(value);
1347-
}

sql/server_component/mysql_stored_program_imp.h

-9
Original file line numberDiff line numberDiff line change
@@ -251,13 +251,4 @@ class mysql_stored_program_return_value_float_imp {
251251
(stored_program_runtime_context sp_runtime_context,
252252
double value));
253253
};
254-
255-
class mysql_stored_program_external_program_handle_imp {
256-
public:
257-
static DEFINE_BOOL_METHOD(get, (stored_program_handle sp,
258-
external_program_handle *value));
259-
260-
static DEFINE_BOOL_METHOD(set, (stored_program_handle sp,
261-
external_program_handle value));
262-
};
263254
#endif /* MYSQL_STORED_PROGRAM_IMP_H */

sql/server_component/server_component.cc

-8
Original file line numberDiff line numberDiff line change
@@ -656,12 +656,6 @@ BEGIN_SERVICE_IMPLEMENTATION(mysql_server, mysql_debug_sync_service)
656656
mysql_debug_sync_service_imp::debug_sync END_SERVICE_IMPLEMENTATION();
657657
#endif
658658

659-
BEGIN_SERVICE_IMPLEMENTATION(mysql_server,
660-
mysql_stored_program_external_program_handle)
661-
mysql_stored_program_external_program_handle_imp::get,
662-
mysql_stored_program_external_program_handle_imp::set,
663-
END_SERVICE_IMPLEMENTATION();
664-
665659
BEGIN_SERVICE_IMPLEMENTATION(mysql_server, mysql_stored_program_metadata_query)
666660
mysql_stored_program_metadata_query_imp::get END_SERVICE_IMPLEMENTATION();
667661

@@ -968,8 +962,6 @@ PROVIDES_SERVICE(mysql_server_path_filter, dynamic_loader_scheme_file),
968962
PROVIDES_SERVICE(mysql_server, mysql_command_field_metadata),
969963
PROVIDES_SERVICE(mysql_server, dynamic_loader_services_loaded_notification),
970964
PROVIDES_SERVICE(mysql_server, dynamic_loader_services_unload_notification),
971-
PROVIDES_SERVICE(mysql_server,
972-
mysql_stored_program_external_program_handle),
973965
PROVIDES_SERVICE(mysql_server, mysql_stored_program_metadata_query),
974966
PROVIDES_SERVICE(mysql_server,
975967
mysql_stored_program_argument_metadata_query),

sql/sp_cache.cc

-22
Original file line numberDiff line numberDiff line change
@@ -74,19 +74,6 @@ class sp_cache {
7474
if (m_hashtable.size() > upper_limit_for_elements) m_hashtable.clear();
7575
}
7676

77-
/**
78-
* @brief Check if the sp_cache contains the specified element.
79-
*
80-
* @param sp
81-
* @return true if the element is in the cache.
82-
* @return false if not.
83-
*/
84-
bool has(sp_head *sp) {
85-
for (auto &element : m_hashtable)
86-
if (element.second.get() == sp) return true;
87-
return false;
88-
}
89-
9077
private:
9178
struct sp_head_deleter {
9279
void operator()(sp_head *sp) const { sp_head::destroy(sp); }
@@ -221,12 +208,3 @@ int64 sp_cache_version() { return atomic_Cversion; }
221208
void sp_cache_enforce_limit(sp_cache *c, ulong upper_limit_for_elements) {
222209
if (c) c->enforce_limit(upper_limit_for_elements);
223210
}
224-
225-
/**
226-
* @brief Check if the sp_cache contains the specified element.
227-
*
228-
* @param sp
229-
* @return true if the element is in the cache.
230-
* @return false if not.
231-
*/
232-
bool sp_cache_has(sp_cache *cp, sp_head *sp) { return cp->has(sp); }

sql/sp_cache.h

-1
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,5 @@ void sp_cache_invalidate();
6464
void sp_cache_flush_obsolete(sp_cache **cp, sp_head **sp);
6565
int64 sp_cache_version();
6666
void sp_cache_enforce_limit(sp_cache *cp, ulong upper_limit_for_elements);
67-
bool sp_cache_has(sp_cache *cp, sp_head *sp);
6867

6968
#endif /* _SP_CACHE_H_ */

sql/sp_head.cc

-13
Original file line numberDiff line numberDiff line change
@@ -2569,19 +2569,6 @@ bool sp_head::execute_trigger(THD *thd, const LEX_CSTRING &db_name,
25692569
return err_status;
25702570
}
25712571

2572-
external_program_handle sp_head::get_external_program_handle() {
2573-
return m_language_stored_program;
2574-
}
2575-
2576-
bool sp_head::set_external_program_handle(external_program_handle sp) {
2577-
assert(m_language_stored_program && !sp);
2578-
assert(!m_language_stored_program && sp);
2579-
if (m_language_stored_program && !sp) return true;
2580-
if (!m_language_stored_program && sp) return true;
2581-
m_language_stored_program = sp;
2582-
return false;
2583-
}
2584-
25852572
bool sp_head::init_external_routine(
25862573
my_service<SERVICE_TYPE(external_program_execution)> &service) {
25872574
assert(!is_sql());

sql/sp_head.h

+1-20
Original file line numberDiff line numberDiff line change
@@ -955,31 +955,12 @@ class sp_head {
955955
/// Flags of LEX::enum_binlog_stmt_unsafe.
956956
uint32 unsafe_flags;
957957

958-
private:
958+
public:
959959
/**
960960
language component related state of this sp.
961961
*/
962962
external_program_handle m_language_stored_program;
963963

964-
public:
965-
/**
966-
* @brief Get the external program handle object
967-
*
968-
* @return external_program_handle
969-
*/
970-
external_program_handle get_external_program_handle();
971-
972-
/**
973-
* @brief Set the external program handle object
974-
*
975-
* @param external_program_handle The new external program handle object.
976-
* Use nullptr to unset the current one.
977-
*
978-
* @return true on errors
979-
* @return false on success
980-
*/
981-
bool set_external_program_handle(external_program_handle);
982-
983964
/**
984965
Initialize and parse an external routine
985966

0 commit comments

Comments
 (0)