fix: hemar & hectic: nothing

This commit is contained in:
2025-05-13 02:30:15 +00:00
parent 609bae352f
commit 88327be038
5 changed files with 363 additions and 293 deletions

View File

@@ -297,6 +297,8 @@
''ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAICrbBG+U07f7OKvOxYIGYCaNvyozzxQF+I9Fb5TYZErK yukkop vm-postgres''
];
services.postgresql =
let
package = pkgs.postgresql_15;
@@ -318,12 +320,16 @@
initialScript = pkgs.writeText "init-sql-script" ''
CREATE EXTENSION "hemar";
SELECT hemar.parse('{% zalupa %}');
SELECT hemar.parse('{% zalupa %}');
-- SELECT hemar.parse('{% zalupa %}');
-- SELECT hemar.parse('{% zalupa %}');
-- SELECT hemar.parse('zalupa {% her %} davalka')::JSON;
-- SELECT hemar.parse('zalupa {% her %} davalka')::JSON;
-- SELECT hemar.parse('zalupa {% her %} davalka')::JSON;
-- SELECT hemar.parse('zalupa {% her %} davalka')::JSON;
'';
};
environment.systemPackages = with pkgs; [ ];
environment.systemPackages = with pkgs; [ gdb ];
programs.zsh.shellAliases = self.lib.sharedShellAliases // {
conn = "sudo su postgres -c 'psql -p 64317'";
check = "journalctl -u postgresql";

File diff suppressed because it is too large Load Diff

View File

@@ -298,6 +298,48 @@ char* raise_message(LogLevel level, const char *file, const char *func, int line
#define PRECOMPILED_LOG_LEVEL LOG_LEVEL_TRACE // default level
#endif
#if PRECOMPILED_LOG_LEVEL > LOG_LEVEL_TRACE
#define raise_trace__(...) ((void)0) // log removed at compile time
#else
#define raise_trace__(file, func, line, ...) raise_message(LOG_LEVEL_TRACE, file, func, line, ##__VA_ARGS__)
#endif
#if PRECOMPILED_LOG_LEVEL > LOG_LEVEL_DEBUG
#define raise_debug__(...) ((void)0)
#else
#define raise_debug__(file, func, line, ...) raise_message(LOG_LEVEL_DEBUG, file, func, line, ##__VA_ARGS__)
#endif
#if PRECOMPILED_LOG_LEVEL > LOG_LEVEL_LOG
#define raise_log__(...) ((void)0)
#else
#define raise_log__(file, func, line, ...) raise_message(LOG_LEVEL_LOG, file, func, line, ##__VA_ARGS__)
#endif
#if PRECOMPILED_LOG_LEVEL > LOG_LEVEL_INFO
#define raise_info__(...) ((void)0)
#else
#define raise_info__(file, func, line, ...) raise_message(LOG_LEVEL_INFO, file, func, line, ##__VA_ARGS__)
#endif
#if PRECOMPILED_LOG_LEVEL > LOG_LEVEL_NOTICE
#define raise_notice__(...) ((void)0)
#else
#define raise_notice__(file, func, line, ...) raise_message(LOG_LEVEL_NOTICE, file, func, line, ##__VA_ARGS__)
#endif
#if PRECOMPILED_LOG_LEVEL > LOG_LEVEL_WARN
#define raise_warn__(...) ((void)0)
#else
#define raise_warn__(file, func, line, ...) raise_message(LOG_LEVEL_WARN, file, func, line, ##__VA_ARGS__)
#endif
#if PRECOMPILED_LOG_LEVEL > LOG_LEVEL_EXCEPTION
#define raise_exception__(...) ((void)0)
#else
#define raise_exception__(fine, func, line, ...) raise_message(LOG_LEVEL_EXCEPTION, file, func, line, ##__VA_ARGS__)
#endif
#if PRECOMPILED_LOG_LEVEL > LOG_LEVEL_TRACE
#define raise_trace(...) ((void)0) // log removed at compile time
#else

View File

@@ -171,6 +171,19 @@ static void simplest_test_template_parse(Arena *arena, TemplateConfig *config) {
"]") == 0);
}
static void simplest_interpolation_that_crash_db_test_template_parse(Arena *arena, TemplateConfig *config) {
const char *template_str = "zalupa {% her %} davalka";
template_parse(arena, &template_str, config);
arena_reset(arena);
template_parse(arena, &template_str, config);
template_parse(arena, &template_str, config);
arena_reset(arena);
template_parse(arena, &template_str, config);
template_parse(arena, &template_str, config);
template_parse(arena, &template_str, config);
}
static void simplest_interpolation_test_template_parse(Arena *arena, TemplateConfig *config) {
const char *template_str = "{% name %} {% name2 %}";
@@ -345,12 +358,16 @@ int main(void) {
printf("%sTest 3: simplest_interpolation_test_template_parse passed%s\n", OPTIONAL_COLOR(COLOR_GREEN), OPTIONAL_COLOR(COLOR_RESET));
arena_reset(&arena);
simplest_interpolation_that_crash_db_test_template_parse(&arena, &config);
printf("%sTest 4: simplest_interpolation_that_crash_db_test_template_parse passed%s\n", OPTIONAL_COLOR(COLOR_GREEN), OPTIONAL_COLOR(COLOR_RESET));
arena_reset(&arena);
simplest_separator_test_template_parse(&arena, &config);
printf("%sTest 4: simplest_separator_test_template_parse passed%s\n", OPTIONAL_COLOR(COLOR_GREEN), OPTIONAL_COLOR(COLOR_RESET));
printf("%sTest 5: simplest_separator_test_template_parse passed%s\n", OPTIONAL_COLOR(COLOR_GREEN), OPTIONAL_COLOR(COLOR_RESET));
arena_reset(&arena);
simplest_execute_test_template_parse(&arena, &config);
printf("%sTest 5: simplest_execute_test_template_parse passed%s\n", OPTIONAL_COLOR(COLOR_GREEN), OPTIONAL_COLOR(COLOR_RESET));
printf("%sTest 6: simplest_execute_test_template_parse passed%s\n", OPTIONAL_COLOR(COLOR_GREEN), OPTIONAL_COLOR(COLOR_RESET));
arena_reset(&arena);
logger_free();

View File

@@ -14,6 +14,9 @@
#include "utils/memutils.h"
#include "utils/regproc.h"
#include <string.h>
#define PRECOMPILED_LOG_LEVEL LOG_LEVEL_EXCEPTION
#include "hectic.h"
#ifdef PG_MODULE_MAGIC
@@ -27,9 +30,10 @@ static MemoryContext HemarContext = NULL;
#define INIT \
MemoryContext oldctx; \
oldctx = MemoryContextSwitchTo(HemarContext); \
logger_init(); \
/* logger_init(); \
logger_level(LOG_LEVEL_TRACE); \
logger_set_file(LOG_FILE); \
logger_set_output_mode(LOG_OUTPUT_BOTH); \
logger_set_output_mode(LOG_OUTPUT_BOTH);*/ \
Arena arena = arena_init(MEM_MiB);
@@ -37,6 +41,7 @@ static MemoryContext HemarContext = NULL;
/*DISPOSABLE_ARENA_FREE*/; \
/*arena_free(&arena);*/ \
/*logger_free();*/ \
arena_reset(&arena); \
MemoryContextSwitchTo(oldctx); \
MemoryContextReset(HemarContext);
@@ -65,7 +70,7 @@ Datum pg_template_parse(PG_FUNCTION_ARGS) {
text *template_text = PG_GETARG_TEXT_PP(0);
const char *template_str = text_to_cstring(template_text);
raise_notice("%s", template_str);
raise_notice("template_str: %s", template_str);
TemplateResult template_result;
TemplateConfig config = template_default_config(&arena);