473,765 Members | 2,061 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

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_stri ng OR DIVISION_BY_ZER O 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_exc eption_causing_ stmt;
exception
when DIVISION_BY_ZER O 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 1691
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
2885
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 return code (not generating error/exception) so it is more compatible with other programming language.
6
2341
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 assemblies are loaded before shutting down. In one case, some of my DB-accessing code didn't handle a NULL value properly. But try...catch wouldn't catch the exception and keep going. I'd just get the error message and then it would shut the...
7
6007
by: Noor | last post by:
please tell the technique of centralize exception handling without try catch blocks in c#.
3
2751
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 exception handling mechanism which will allow me to pass character information about an error and its location from lower-level classes. Can you please critique the following exception handling mechanism in terms of my requirements ?
19
2198
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 can happen at various points, so that any one of these exceptions can be trapped and handled by the exception-handling code collected in one place after the block. This also means that the exception generating code can be much cleaner, since...
44
4226
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 user tasks should always be included in a try/catch block that actually handles any exceptions that occur (log the exception, display a message box, etc.). 2. Low-level operations that are used to carry out the high level tasks
41
3070
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 handle all of them. I don't care about which one happened, except to write out exception.Message to a log file. It seems verbose to write out three handlers that all do the same thing. So, I could just catch Exception. But, is that...
4
1582
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). If an exception occurs, it will generate a useful error message containing procedure, line number etc for the offensive code and either send it itself to a specified email address or give the user the option of reporting the error.
1
3109
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
9568
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10163
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9957
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7379
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6649
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5276
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5423
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3924
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3532
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.