Quantcast
Channel: Active questions tagged debugging - Database Administrators Stack Exchange
Viewing all articles
Browse latest Browse all 47

How to get the name of a variable instead of its value in plpgsql?

$
0
0

I write a lot of debugging code in plpgsql along the lines:

RAISE NOTICE 'var1 = %', var1;

(there can be more than one variable to print out).

Is it possible to avoid having to repeat the variable var1 every time by writing a PostgreSQL function (say myprint) so that

SELECT myprint(var1);

will generate the same output as RAISE NOTICE 'var1 = %', var1;?

The problem is that I know how to get the value of var1 in the function but I don't know how to get the name var1. Is there some call-stack or context magic in plpgsql that can provide the name of the variable passed to myprint?

(This is with PostgreSQL 12.1 or later)


Viewing all articles
Browse latest Browse all 47

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>