MCPcopy Create free account
hub / github.com/apache/cloudberry / plpgsql_compile_inline

Function plpgsql_compile_inline

src/pl/plpgsql/src/pl_comp.c:865–994  ·  view source on GitHub ↗

---------- * plpgsql_compile_inline Make an execution tree for an anonymous code block. * * Note: this is generally parallel to do_compile(); is it worth trying to * merge the two? * * Note: we assume the block will be thrown away so there is no need to build * persistent data structures. * ---------- */

Source from the content-addressed store, hash-verified

863 * ----------
864 */
865PLpgSQL_function *
866plpgsql_compile_inline(char *proc_source)
867{
868 char *func_name = "inline_code_block";
869 PLpgSQL_function *function;
870 ErrorContextCallback plerrcontext;
871 PLpgSQL_variable *var;
872 int parse_rc;
873 MemoryContext func_cxt;
874
875 /*
876 * Setup the scanner input and error info. We assume that this function
877 * cannot be invoked recursively, so there's no need to save and restore
878 * the static variables used here.
879 */
880 plpgsql_scanner_init(proc_source);
881
882 plpgsql_error_funcname = func_name;
883
884 /*
885 * Setup error traceback support for ereport()
886 */
887 plerrcontext.callback = plpgsql_compile_error_callback;
888 plerrcontext.arg = proc_source;
889 plerrcontext.previous = error_context_stack;
890 error_context_stack = &plerrcontext;
891
892 /* Do extra syntax checking if check_function_bodies is on */
893 plpgsql_check_syntax = check_function_bodies;
894
895 /* Function struct does not live past current statement */
896 function = (PLpgSQL_function *) palloc0(sizeof(PLpgSQL_function));
897
898 plpgsql_curr_compile = function;
899
900 /*
901 * All the rest of the compile-time storage (e.g. parse tree) is kept in
902 * its own memory context, so it can be reclaimed easily.
903 */
904 func_cxt = AllocSetContextCreate(CurrentMemoryContext,
905 "PL/pgSQL inline code context",
906 ALLOCSET_DEFAULT_SIZES);
907 plpgsql_compile_tmp_cxt = MemoryContextSwitchTo(func_cxt);
908
909 function->fn_signature = pstrdup(func_name);
910 function->fn_is_trigger = PLPGSQL_NOT_TRIGGER;
911 function->fn_input_collation = InvalidOid;
912 function->fn_cxt = func_cxt;
913 function->out_param_varno = -1; /* set up for no OUT param */
914 function->resolve_option = plpgsql_variable_conflict;
915 function->print_strict_params = plpgsql_print_strict_params;
916
917 /*
918 * don't do extra validation for inline code as we don't want to add spam
919 * at runtime
920 */
921 function->extra_warnings = 0;
922 function->extra_errors = 0;

Callers 1

plpgsql_inline_handlerFunction · 0.85

Calls 12

plpgsql_scanner_initFunction · 0.85
MemoryContextSwitchToFunction · 0.85
plpgsql_ns_initFunction · 0.85
plpgsql_ns_pushFunction · 0.85
plpgsql_start_datumsFunction · 0.85
plpgsql_build_variableFunction · 0.85
plpgsql_build_datatypeFunction · 0.85
plpgsql_scanner_finishFunction · 0.85
add_dummy_returnFunction · 0.85
plpgsql_finish_datumsFunction · 0.85
palloc0Function · 0.50
pstrdupFunction · 0.50

Tested by

no test coverage detected