pltcl problem
Hi,
I'm trying to debug a pltcl procedure (being used as a trigger), and I'm
having trouble generating useful debug output.
I'm using elog, and I want the output to contain the value of an array.
So, I'm using a command like this:
elog DEBUG "Trigger Call $vchtablename"
Trouble is, it's appearing in the error log exactly like that (including
the 'elog DEBUG' part.
If I indent the line, the spaces at the start appear in the error log also.
I've tried removing the quotes and I get the same output (minus the quotes)
I'm probably doing something wrong that pretty obvious (been staring at
the code for too long, plus this is the first time I've ever used TCL, so
it could be a very obvious mistake!). If anyone can give me a hint as to
what my error might be, that would be great.
Thanks,
--
Russell Brown
Russ Brown <postgres@dot4dot.plus.com> writes:
So, I'm using a command like this:
elog DEBUG "Trigger Call $vchtablename"
Trouble is, it's appearing in the error log exactly like that (including
the 'elog DEBUG' part.
Can we see the whole function definition? I think you are somehow
managing to include this string in a quoted argument of some other elog
command, but without context it's hard to say more.
regards, tom lane
Can we see the whole function definition? I think you are somehow
managing to include this string in a quoted argument of some other elog
command, but without context it's hard to say more.regards, tom lane
I thought that too but I can't see anything obvious (but then I am a tcl
novice :-). The function definition is as follows:
CREATE OR REPLACE FUNCTION HierarchyAddTrigger() RETURNS trigger AS '
# Debug to make sure Im getting back what I think I am from the
subselect
spi_exec "SELECT relname FROM pg_class WHERE oid = ''$TG_relid''::oid"
elog DEBUG "$relname"
# Get data on this hierarchy structure
spi_exec "SELECT vchtablename, vchtableid, vchtablepid, vchlookupname,
vchlookupid, vchlookuppid, vchlevel FROM fnGetHierarchyData((SELECT
relname FROM pg_class WHERE oid = ''$TG_relid''::oid))"
elog DEBUG "Trigger Call $vchtablename"
# First check that the level is correct
if [ info exists NEW($vchtablepid) ] {
elog DEBUG "MAIN ADD"
elog DEBUG "SELECT $vchlevel + 1 AS new_level FROM $vchtablename
WHERE intGroupID=$NEW($vchtablepid)"
spi_exec "SELECT $vchlevel + 1 AS new_level FROM $vchtablename
WHERE intGroupID=$NEW($vchtablepid)"
# Set the correct level in the new row. We dont ever need to know
# what value the original insert set the level to.
set NEW($vchlevel) $new_level
# Now add the parents of this new row
spi_exec "SELECT HierarchyAdd(\'$vchtablename\',
$NEW($vchtablepid), $NEW($vchtableid))"
} else {
elog DEBUG "INITIAL ADD"
set NEW($vchlevel) 1
spi_exec "INSERT INTO $vchlookupname ($vchlookupid, $vchlookuppid)
VALUES ($NEW($vchtableid), $NEW($vchtableid))"
}
elog DEBUG "End Trigger"
return [array get NEW];
' LANGUAGE 'pltcl';
Trigger definition is:
CREATE TRIGGER trgGroupAddTrigger BEFORE INSERT ON tblGroup
FOR EACH ROW EXECUTE PROCEDURE HierarchyAddTrigger();
Thanks for you help!
--
Russell Brown
Russ Brown <postgres@dot4dot.plus.com> writes:
Can we see the whole function definition? I think you are somehow
managing to include this string in a quoted argument of some other elog
command, but without context it's hard to say more.
I thought that too but I can't see anything obvious (but then I am a tcl
novice :-).
My tcl is a bit rusty but I don't see the problem either. Anyone?
If you don't get any helpful answers, maybe you could show us the exact
contents of your postmaster log too --- perhaps that would trigger an
idea ...
regards, tom lane
Can we see the whole function definition? I think you are somehow
managing to include this string in a quoted argument of some other elog
command, but without context it's hard to say more.regards, tom lane
Actually, I have done something stupid. I'm basically running the error
log through a grep for DEBUG, and what I'm seeing is chunks of the
function create being dumped to the error log. My actual dumps aren't
getting into the error log at all, which is a seperate problem probably
caused by misconfiguration.
Sorry for wasting your time! :-)
--
Russell Brown
Russ Brown <postgres@dot4dot.plus.com> writes:
Actually, I have done something stupid. I'm basically running the error
log through a grep for DEBUG, and what I'm seeing is chunks of the
function create being dumped to the error log. My actual dumps aren't
getting into the error log at all, which is a seperate problem probably
caused by misconfiguration.
Ah, that makes sense. Check your log_min_messages setting. Or bump up
client_min_messages so you can get what you want on your terminal.
regards, tom lane
On Wed, 24 Sep 2003 15:02:49 -0400, Tom Lane <tgl@sss.pgh.pa.us> wrote:
Russ Brown <postgres@dot4dot.plus.com> writes:
Actually, I have done something stupid. I'm basically running the error
log through a grep for DEBUG, and what I'm seeing is chunks of the
function create being dumped to the error log. My actual dumps aren't
getting into the error log at all, which is a seperate problem probably
caused by misconfiguration.Ah, that makes sense. Check your log_min_messages setting. Or bump up
client_min_messages so you can get what you want on your terminal.regards, tom lane
Sorted. Seems I needed it setting to debug2 to get DEBUG output.
Thanks a log for your help. :-)
--
Russ.