What is the 'E' in RAISE NOTICE E'msg %', mymsg?
I've seen it used in various Postgres tutorial pages, even in Postgres documentation itself, but I can't find an actual explanation of what it is or does.
It's usually used with messages that use GET STACKED DIAGNOSTICS, but the message itself only looks to me like a normal
RAISE NOTICE 'foo: %, bar: %',foo_value, bar_value;
type of message where the foo and bar values are simply assigned to the specific diagnostic values in the lines before the RAISE NOTICE.
So, what's magic about the E'...'?
From the documentation about what goes after the
RAISElevel:Another name for a string literal is a string constant documented here. Those can use C-like backslash escape sequences: doc
'E' in
RAISE NOTICE E'msg %', mymsgin your opening example is just syntax noise - not particularly magical, not very useful.mymsgargument contains newlines, or anything requiring some special action to put it there, it will be inserted in place of%placeholder regardless of whether you useE'...'or not.mymsgargument contains backslash escape sequences, those won't be interpreted as such.In the doc you linked it does make sense since the
\nsequence is in the literal/constant:Note that
stackvariable also holds newlines of its own and those end up being inserted into the message even if there's noEout front.Cheatsheet: