in sources/gen_sql.c [2890:2948]
cql_noexport void gen_declare_proc_from_create_proc(ast_node *ast) {
Contract(is_ast_create_proc_stmt(ast));
EXTRACT_STRING(name, ast->left);
EXTRACT_NOTNULL(proc_params_stmts, ast->right);
EXTRACT(params, proc_params_stmts->left);
gen_printf("DECLARE PROC %s (", name);
if (params) {
gen_params(params);
}
gen_printf(")");
#if defined(CQL_AMALGAM_LEAN) && !defined(CQL_AMALGAM_SEM)
// if no SEM then we can't do the full declaration, do the best we can with just AST
#else
if (ast->sem) {
if (has_out_stmt_result(ast)) {
gen_printf(" OUT");
}
if (has_out_union_stmt_result(ast)) {
gen_printf(" OUT UNION");
}
if (is_struct(ast->sem->sem_type)) {
sem_struct *sptr = ast->sem->sptr;
gen_printf(" (");
for (int32_t i = 0; i < sptr->count; i++) {
gen_printf("%s ", sptr->names[i]);
sem_t sem_type = sptr->semtypes[i];
gen_printf("%s", coretype_string(sem_type));
if (is_not_nullable(sem_type)) {
gen_printf(" NOT NULL");
}
if (sensitive_flag(sem_type) && !for_sqlite()) {
gen_printf(" @SENSITIVE");
}
if (i + 1 < sptr->count) {
gen_printf(", ");
}
}
gen_printf(")");
if ((has_out_stmt_result(ast) || has_out_union_stmt_result(ast)) && is_dml_proc(ast->sem->sem_type)) {
// out [union] can be DML or not, so we have to specify
gen_printf(" USING TRANSACTION");
}
}
else if (is_dml_proc(ast->sem->sem_type)) {
gen_printf(" USING TRANSACTION");
}
}
#endif
}