473,320 Members | 1,946 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

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

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

Nov 12 '05 #1
7 1615
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
> 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
>
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
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Bruce Davis | last post by:
I'm having a problem on windows (both 2000 and XP) with a multi-threaded tkinter gui application. The problem appears to be a deadlock condition when a child thread pops up a Pmw dialog window in...
11
by: Kostatus | last post by:
I have a virtual function in a base class, which is then overwritten by a function of the same name in a publically derived class. When I call the function using a pointer to the derived class...
117
by: Peter Olcott | last post by:
www.halting-problem.com
2
by: Josué Maldonado | last post by:
Hello list, I have a trigger that loop for each column in a table, is there a way to identify a dropped column from within a PLTCL trigger? Thanks in advance -- Josué Maldonado.
28
by: Jon Davis | last post by:
If I have a class with a virtual method, and a child class that overrides the virtual method, and then I create an instance of the child class AS A base class... BaseClass bc = new ChildClass();...
6
by: Ammar | last post by:
Dear All, I'm facing a small problem. I have a portal web site, that contains articles, for each article, the end user can send a comment about the article. The problem is: I the comment length...
0
by: Ian Harding | last post by:
I am trying to build pltcl.so and have a small problem. It builds fine butwhen I try to createlang, I get the dreaded "...server closed the connection unexpectedly..." error and the log just says...
16
by: Dany | last post by:
Our web service was working fine until we installed .net Framework 1.1 service pack 1. Uninstalling SP1 is not an option because our largest customer says service packs marked as "critical" by...
2
by: Mike Collins | last post by:
I cannot get the correct drop down list value from a drop down I have on my web form. I get the initial value that was loaded in the list. It was asked by someone else what the autopostback was...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.