473,395 Members | 1,466 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,395 software developers and data experts.

possible bug in exception handling code? (postgres8.0beta)

Hi all!
I was looking into the postgres8.0 code for exception handling,
and it seems that the grammer treats an exception condition as opt_lblname.
This means that I can pass any arbitrary string as an exception condition.
This also means that implementation of user defined exceptions would be in
trouble.

Note that the execution would not be affected(for now, i.e. without user
defined exceptions), it's just a compiler vulnerability.

example:

declare
a int;
begin
return 1;
exception
when a OR any_random_string OR DIVISION_BY_ZERO then
return 0;
end;

would compile, when in fact it should not. (or am I totally wrong here?)
pl_exec.c has a exception label map which is used at execution, when the
exception actually happens.
Wouldn't it be preferable to use it at compile time?

**************

Also, I noticed that for

begin
valid_stmt_1;
valid_stmt_2;
zero_divide_exception_causing_stmt;
exception
when DIVISION_BY_ZERO then
return safely;
end;

valid_stmt_1 and 2 are rolled back.
This happens because whenever execution goes into the catch block,
the staments for that level are rolled back before searching for
exceptions.
Shouldn't it be the other way around? as in, searching for a handler, and
rolling the subtransaction back only if no handler is found?

thanks
paraM

---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?

http://archives.postgresql.org

Nov 23 '05 #1
1 1676
Pa*************@trilogy.com writes:
would compile, when in fact it should not. (or am I totally wrong here?)
pl_exec.c has a exception label map which is used at execution, when the
exception actually happens.
Wouldn't it be preferable to use it at compile time?
That is on my to-do list. One question is whether we *want* unknown
condition names to be rejected. Probably the answer is yes, but you
could make an argument the other way.
Shouldn't it be the other way around?


No. You do not have the option not to roll back, no matter what handler
is found or not found.

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?

http://archives.postgresql.org

Nov 23 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: adi | last post by:
Dear all, This is more like a theoretical or conceptual question: which is better, using exception or return code for a .NET component? I had created a COM object (using VB6), which uses...
6
by: Daniel Wilson | last post by:
I am having exception-handling and stability problems with .NET. I will have a block of managed code inside try...catch and will still get a generic ..NET exception box that will tell me which...
7
by: Noor | last post by:
please tell the technique of centralize exception handling without try catch blocks in c#.
3
by: Master of C++ | last post by:
Hi, I am an absolute newbie to Exception Handling, and I am trying to retrofit exception handling to a LOT of C++ code that I've written earlier. I am just looking for a bare-bones, low-tech...
19
by: KKramsch | last post by:
One of the features from other languages that I miss most in C is trappable exceptions. More specifically, I think it's great to be able to demarcate a whole block of code where several exceptions...
44
by: craig | last post by:
I am wondering if there are some best practices for determining a strategy for using try/catch blocks within an application. My current thoughts are: 1. The code the initiates any high-level...
41
by: Zytan | last post by:
Ok something simple like int.Parse(string) can throw these exceptions: ArgumentNullException, FormatException, OverflowException I don't want my program to just crash on an exception, so I must...
4
by: Johnny Jörgensen | last post by:
Hi Does anyone know of a component that can facilitate error handling in a complex application. What I'm looking for is a component you can simply drop on your application form (or the like)....
1
by: George2 | last post by:
Hello everyone, Such code segment is used to check whether function call or exception- handling mechanism runs out of memory first (written by Bjarne), void perverted() { try{
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.