1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129
|
/* This file is automatically generated by sql_to_c.awk */
#include "sqlnode.h"
#include "sqlfn.h"
#include "sqltype.h"
/* autoexec.sql */
static const char *proc0 =
"#line 23 \"[executable]/autoexec.sql\"\n"
"create procedure DB.DBA.ddl_load_script (in _filename varchar)\n"
"{\n"
"declare cnt, parts, errors any;\n"
"cnt := file_to_string (_filename);\n"
"parts := sql_split_text (cnt);\n"
"foreach (varchar s in parts) do\n"
"{\n"
"declare stat, msg any;\n"
"stat := \'00000\';\n"
"exec (s, stat, msg);\n"
"if (stat <> \'00000\')\n"
"{\n"
"log_message (sprintf (\'Error in autoexec.isql: [%s] %s\', stat, msg));\n"
"rollback work;\n"
"}\n"
"else\n"
"{\n"
"commit work;\n"
"}\n"
"}\n"
"}\n"
"--src autoexec.sql:21\n";
static const char *proc1 =
"#line 46 \"[executable]/autoexec.sql\"\n"
"create procedure DB.DBA.ddl_load_script_safe (in _filename varchar)\n"
"{\n"
"declare _status, _message varchar;\n"
"_status := \'\';\n"
"_message := \'OK\';\n"
"if (not file_stat (_filename))\n"
"return;\n"
"exec (concat (\'DB.DBA.ddl_load_script (\', WS.WS.STR_SQL_APOS(_filename), \')\'), _status, _message);\n"
"if (_message<>\'OK\')\n"
"{\n"
"dbg_printf (\'\\nError on loading file \\\'%s\\\'\', _filename );\n"
"dbg_printf (\'Status returned: %s %s\', _status, _message);\n"
"}\n"
"}\n"
"--src autoexec.sql:44\n";
static const char *proc2 =
"#line 62 \"[executable]/autoexec.sql\"\n"
"create procedure ddl_autoexec (in _filename varchar)\n"
"{\n"
"if (_filename = \'\')\n"
"_filename := \'autoexec.isql\';\n"
"\n"
"DB.DBA.ddl_load_script_safe (_filename);\n"
"}\n"
"--src autoexec.sql:60\n";
static const char *proc3 =
"#line 71 \"[executable]/autoexec.sql\"\n"
"create procedure ddl_dav_replicate_rdf_quad ()\n"
"{\n"
"if (1 <> sys_stat (\'cl_run_local_only\'))\n"
"return;\n"
"DB.DBA.DAV_AUTO_REPLICATE_TO_RDF_QUAD ();\n"
"}\n"
"--src autoexec.sql:69\n";
static const char *other0 =
" ddl_dav_replicate_rdf_quad ()\n";
static const char *other1 =
" VAD.DBA.VAD_AUTO_UPGRADE ()\n";
static const char *other2 =
" ddl_autoexec (\'\')\n";
static int
sch_proc_def_exists (client_connection_t *cli, const char *proc_name, const int report)
{
query_t *proc = NULL;
char *full_name = sch_full_proc_name (isp_schema(NULL), proc_name,
cli->cli_qualifier, CLI_OWNER (cli));
if (full_name)
proc = sch_proc_def (isp_schema(NULL), full_name);
if (report && proc != NULL)
log_debug ("built-in procedure \"%s\" overruled by the RDBMS", proc_name);
return (proc != NULL);
}
#define DEFINE_PROC(name, proc) \
if (!sch_proc_def_exists (bootstrap_cli, (name), log_proc_overwrite)) \
ddl_std_proc_1 (proc, 0x0, 1)
#define DEFINE_PUBLIC_PROC(name, proc) \
if (!sch_proc_def_exists (bootstrap_cli, (name), log_proc_overwrite)) \
ddl_std_proc_1 (proc, 0x1, 1)
#define DEFINE_OVERWRITE_PROC(name, proc) \
ddl_std_proc_1 (proc, 0x1, 1)
void
sqls_define_auto (void)
{
/* autoexec.sql */
DEFINE_PROC ("DB.DBA.ddl_load_script", proc0);
DEFINE_PROC ("DB.DBA.ddl_load_script_safe", proc1);
DEFINE_PROC ("ddl_autoexec", proc2);
DEFINE_PROC ("ddl_dav_replicate_rdf_quad", proc3);
}
void
sqls_arfw_define_auto (void)
{
/* ./autoexec.sql */
ddl_ensure_table ("do this always", other0);
ddl_ensure_table ("do this always", other1);
ddl_ensure_table ("do this always", other2);
}
|