By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,179 Members | 970 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,179 IT Pros & Developers. It's quick & easy.

pltcl problem

P: n/a
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
---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faqs/FAQ.html

Nov 12 '05 #1
Share this Question
Share on Google+
7 Replies


P: n/a
Russ Brown <po******@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

---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster

Nov 12 '05 #2

P: n/a
> 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
---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to ma*******@postgresql.org so that your
message can get through to the mailing list cleanly

Nov 12 '05 #3

P: n/a
>
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
---------------------------(end of broadcast)---------------------------
TIP 8: explain analyze is your friend

Nov 12 '05 #4

P: n/a
Russ Brown <po******@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

---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to ma*******@postgresql.org so that your
message can get through to the mailing list cleanly

Nov 12 '05 #5

P: n/a
That line, in a context where it will get evaluated by the tcl
interpreter, should work.

Do you have a tcl variable called vchtablename available at that point
in your script? If it is a tcl array, to get its contents, you need
[array get vchtablename] instead of the $ dereference. However, that
seems not to be your problem.

Can you send the tcl trigger function code, and the create trigger
statement?

Russ Brown wrote:
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,

------------------------------------------------------------------------

SPAM: TO_ADDRESS_EQ_REAL (0.4 points) To: repeats address as real name
SPAM: X_MAILING_LIST (-0.0 points) Has a X-Mailing-List header
SPAM: BAYES_00 (-5.2 points) Bayesian classifier says spam probability is 0 to 1%
Score Total: -4.8


---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to ma*******@postgresql.org

Nov 12 '05 #6

P: n/a
Russ Brown <po******@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

---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faqs/FAQ.html

Nov 12 '05 #7

P: n/a
On Wed, 24 Sep 2003 15:02:49 -0400, Tom Lane <tg*@sss.pgh.pa.us> wrote:
Russ Brown <po******@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.
---------------------------(end of broadcast)---------------------------
TIP 8: explain analyze is your friend

Nov 12 '05 #8

This discussion thread is closed

Replies have been disabled for this discussion.