Newer
Older
From 99f29bd6d03d166af8fb29564cd2781f397861ae Mon Sep 17 00:00:00 2001
From: Georgy Moshkin <gmoshkin@picodata.io>
Date: Thu, 14 Jul 2022 17:51:03 +0300
Subject: [PATCH] picodata: add support for static stored procedures using
src/box/module_cache.c | 26 ++++++++++++++++++++++++++
1 file changed, 26 insertions(+)
diff --git a/src/box/module_cache.c b/src/box/module_cache.c
index 76685ed86..eeaff73c2 100644
--- a/src/box/module_cache.c
+++ b/src/box/module_cache.c
return NULL;
}
+struct module *
+module_current_exe()
+{
+ struct module *m = cache_find(NULL, 0);
+ if (m != NULL)
+ return m;
+
+ size_t size = sizeof(struct module) + 1;
+ m = malloc(size);
+ if (m == NULL) {
+ diag_set(OutOfMemory, size, "malloc", "module");
+ return NULL;
+ }
+ memset(m, 0, size);
+ m->handle = dlopen(0, RTLD_NOW);
+ module_ref(m);
+ return m;
+}
+
struct module *
module_load_force(const char *package, size_t package_len)
{
+ if (package_len == 0)
+ return module_current_exe();
+
char path[PATH_MAX];
size_t size = sizeof(path);
@@ -400,6 +423,9 @@ module_load_force(const char *package, size_t package_len)
struct module *
module_load(const char *package, size_t package_len)
{
+ if (package_len == 0)
+ return module_current_exe();
+
char path[PATH_MAX];
if (find_package(package, package_len, path, sizeof(path)) != 0)
--
2.25.1