Expose a few more PL/pgSQL functions to debugger plugins.
Add exec_assign_value, exec_eval_datum, and exec_cast_value to the set of functions a PL/pgSQL debugger plugin can conveniently call. This allows more convenient manipulation of the values of PL/pgSQL function variables. Pavel Stehule, reviewed by Aleksander Alekseev and myself Discussion: https://postgr.es/m/CAFj8pRD+dBPU0T-KrkP7ef6QNPDEsjYCejEsBe07NDq8TybOkA@mail.gmail.com
This commit is contained in:
parent
9f91344223
commit
53ef6c40f1
|
@ -4077,15 +4077,18 @@ plpgsql_estate_setup(PLpgSQL_execstate *estate,
|
||||||
plpgsql_create_econtext(estate);
|
plpgsql_create_econtext(estate);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Let the plugin see this function before we initialize any local
|
* Let the plugin, if any, see this function before we initialize local
|
||||||
* PL/pgSQL variables - note that we also give the plugin a few function
|
* PL/pgSQL variables. Note that we also give the plugin a few function
|
||||||
* pointers so it can call back into PL/pgSQL for doing things like
|
* pointers, so it can call back into PL/pgSQL for doing things like
|
||||||
* variable assignments and stack traces
|
* variable assignments and stack traces.
|
||||||
*/
|
*/
|
||||||
if (*plpgsql_plugin_ptr)
|
if (*plpgsql_plugin_ptr)
|
||||||
{
|
{
|
||||||
(*plpgsql_plugin_ptr)->error_callback = plpgsql_exec_error_callback;
|
(*plpgsql_plugin_ptr)->error_callback = plpgsql_exec_error_callback;
|
||||||
(*plpgsql_plugin_ptr)->assign_expr = exec_assign_expr;
|
(*plpgsql_plugin_ptr)->assign_expr = exec_assign_expr;
|
||||||
|
(*plpgsql_plugin_ptr)->assign_value = exec_assign_value;
|
||||||
|
(*plpgsql_plugin_ptr)->eval_datum = exec_eval_datum;
|
||||||
|
(*plpgsql_plugin_ptr)->cast_value = exec_cast_value;
|
||||||
|
|
||||||
if ((*plpgsql_plugin_ptr)->func_setup)
|
if ((*plpgsql_plugin_ptr)->func_setup)
|
||||||
((*plpgsql_plugin_ptr)->func_setup) (estate, func);
|
((*plpgsql_plugin_ptr)->func_setup) (estate, func);
|
||||||
|
|
|
@ -1120,9 +1120,17 @@ typedef struct PLpgSQL_execstate
|
||||||
* statement.
|
* statement.
|
||||||
*
|
*
|
||||||
* Also, immediately before any call to func_setup, PL/pgSQL fills in the
|
* Also, immediately before any call to func_setup, PL/pgSQL fills in the
|
||||||
* error_callback and assign_expr fields with pointers to its own
|
* remaining fields with pointers to some of its own functions, allowing the
|
||||||
* plpgsql_exec_error_callback and exec_assign_expr functions. This is
|
* plugin to invoke those functions conveniently. The exposed functions are:
|
||||||
* a somewhat ad-hoc expedient to simplify life for debugger plugins.
|
* plpgsql_exec_error_callback
|
||||||
|
* exec_assign_expr
|
||||||
|
* exec_assign_value
|
||||||
|
* exec_eval_datum
|
||||||
|
* exec_cast_value
|
||||||
|
* (plpgsql_exec_error_callback is not actually meant to be called by the
|
||||||
|
* plugin, but rather to allow it to identify PL/pgSQL error context stack
|
||||||
|
* frames. The others are useful for debugger-like plugins to examine and
|
||||||
|
* set variables.)
|
||||||
*/
|
*/
|
||||||
typedef struct PLpgSQL_plugin
|
typedef struct PLpgSQL_plugin
|
||||||
{
|
{
|
||||||
|
@ -1135,8 +1143,20 @@ typedef struct PLpgSQL_plugin
|
||||||
|
|
||||||
/* Function pointers set by PL/pgSQL itself */
|
/* Function pointers set by PL/pgSQL itself */
|
||||||
void (*error_callback) (void *arg);
|
void (*error_callback) (void *arg);
|
||||||
void (*assign_expr) (PLpgSQL_execstate *estate, PLpgSQL_datum *target,
|
void (*assign_expr) (PLpgSQL_execstate *estate,
|
||||||
|
PLpgSQL_datum *target,
|
||||||
PLpgSQL_expr *expr);
|
PLpgSQL_expr *expr);
|
||||||
|
void (*assign_value) (PLpgSQL_execstate *estate,
|
||||||
|
PLpgSQL_datum *target,
|
||||||
|
Datum value, bool isNull,
|
||||||
|
Oid valtype, int32 valtypmod);
|
||||||
|
void (*eval_datum) (PLpgSQL_execstate *estate, PLpgSQL_datum *datum,
|
||||||
|
Oid *typeid, int32 *typetypmod,
|
||||||
|
Datum *value, bool *isnull);
|
||||||
|
Datum (*cast_value) (PLpgSQL_execstate *estate,
|
||||||
|
Datum value, bool *isnull,
|
||||||
|
Oid valtype, int32 valtypmod,
|
||||||
|
Oid reqtype, int32 reqtypmod);
|
||||||
} PLpgSQL_plugin;
|
} PLpgSQL_plugin;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
Loading…
Reference in New Issue