473,785 Members | 2,989 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Stored procedure failure

hello, I have interesting problem...

I have stored procedure, which works good, but only if input is "correct".
Correct input is, when $1 is id, which exists in table...
If I put non exists id, database fall down and restart with this error:
server closed the connection unexpectedly
This probably means the server terminated abnormally
before or while processing the request.
The connection to the server was lost. Attempting reset: Failed.

I think, that problem is in line:
FOR tmp_row IN SELECT v_name FROM c_part_cat WHERE v_path @> my_path
ORDER BY v_path LOOP
because without them it works well...

Version: 7.4.5 and 7.4.3 (both versions have this problem)

thanx, hlavki

source:

/*============== =============== =============== =============== ===*/
/* Table: c_part_cat */
/*============== =============== =============== =============== ===*/
create table c_part_cat (
i_part_cat_id integer default nextval('c_part _cat_seq') not null,
c_code varchar(32) not null,
v_name varchar(128) null,
v_path ltree not null,
i_parent_id int4 null,
constraint pk_c_part_cat primary key (i_part_cat_id)
);

/*============== =============== =============== =============== ===*/
/* Index: index_13 */
/*============== =============== =============== =============== ===*/
create index index_13 on c_part_cat (
i_parent_id
);

/*============== =============== =============== =============== ===*/
/* Index: index_22 */
/*============== =============== =============== =============== ===*/
create unique index index_22 on c_part_cat (
c_code
);

/*============== =============== =============== =============== ===*/
/* Index: index_4 */
/*============== =============== =============== =============== ===*/
create index index_4 on c_part_cat using gist (
v_path
);

alter table c_part_cat
add constraint fk_c_part_cat_r ef_c_part_cat foreign key (i_parent_id)
references c_part_cat (i_part_cat_id)
on delete restrict on update restrict;

CREATE OR REPLACE FUNCTION "public"."get_p art_cat_path" (integer)
RETURNS text AS'
DECLARE
my_path ltree;
result text;
tmp_row RECORD;
first bool;
BEGIN
SELECT v_path INTO my_path FROM c_part_cat WHERE i_part_cat_id = $1;
result := ''''; first := true;
FOR tmp_row IN SELECT v_name FROM c_part_cat WHERE v_path @> my_path
ORDER BY v_path LOOP
IF first THEN
result := tmp_row.v_name;
first := false;
ELSE
result := tmp_row.v_name || ''->'' || result;
END IF;
END LOOP;
RETURN result;
END;
'LANGUAGE 'plpgsql' STABLE CALLED ON NULL INPUT SECURITY INVOKER;

--

[ miso hlavac ][ hl****@medium13 .sk ][ http://www.medium13.sk ]
[ icq:94900232 ][ callto://hlavki ]

---------------------------(end of broadcast)---------------------------
TIP 8: explain analyze is your friend

Nov 23 '05 #1
6 1417
Michal Hlavac wrote:
hello, I have interesting problem...

I have stored procedure, which works good, but only if input is "correct".
Correct input is, when $1 is id, which exists in table...
If I put non exists id, database fall down and restart with this error:
server closed the connection unexpectedly
This probably means the server terminated abnormally
before or while processing the request.
The connection to the server was lost. Attempting reset: Failed.

I think, that problem is in line:
FOR tmp_row IN SELECT v_name FROM c_part_cat WHERE v_path @> my_path
ORDER BY v_path LOOP
because without them it works well... CREATE OR REPLACE FUNCTION "public"."get_p art_cat_path" (integer)
RETURNS text AS'
DECLARE
my_path ltree; .... BEGIN
SELECT v_path INTO my_path FROM c_part_cat WHERE i_part_cat_id = $1;
result := ''''; first := true;
FOR tmp_row IN SELECT v_name FROM c_part_cat WHERE v_path @> my_path

I'm guessing a problem with the ltree code. Presumably in handling the
null my_path.
Version: 7.4.5 and 7.4.3 (both versions have this problem)


Looking at the 8.0beta source, the functions (...ltree_ispar ent) are all
marked strict so they should just return null on a null parameter.

What happens if you set my_path to some non-null but un-matched value
before the problem line?

--
Richard Huxton
Archonet Ltd

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

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

Nov 23 '05 #2
Michal Hlavac wrote:
hello, I have interesting problem...

I have stored procedure, which works good, but only if input is "correct". Correct input is, when $1 is id, which exists in table...
If I put non exists id, database fall down and restart with this error:
server closed the connection unexpectedly
This probably means the server terminated abnormally
before or while processing the request.
The connection to the server was lost. Attempting reset: Failed.

I think, that problem is in line:
FOR tmp_row IN SELECT v_name FROM c_part_cat WHERE v_path @> my_path
ORDER BY v_path LOOP
because without them it works well...

Version: 7.4.5 and 7.4.3 (both versions have this problem)


I am sorry... I've got it... my_path cannot be null... ;)

thanx, hlavki

--

[ miso hlavac ][ hl****@medium13 .sk ][ http://www.medium13.sk ]
[ icq:94900232 ][ callto://hlavki ]

---------------------------(end of broadcast)---------------------------
TIP 9: the planner will ignore your desire to choose an index scan if your
joining column's datatypes do not match

Nov 23 '05 #3
Richard Huxton wrote:

Looking at the 8.0beta source, the functions (...ltree_ispar ent) are all
marked strict so they should just return null on a null parameter.

What happens if you set my_path to some non-null but un-matched value
before the problem line?


When my_path have non-null value, everything is OK...

I don't understand why one null value would crash the server???

--

[ miso hlavac ][ hl****@medium13 .sk ][ http://www.medium13.sk ]
[ icq:94900232 ][ callto://hlavki ]

---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddres sHere" to ma*******@postg resql.org)

Nov 23 '05 #4
Michal Hlavac wrote:
Richard Huxton wrote:

Looking at the 8.0beta source, the functions (...ltree_ispar ent) are
all marked strict so they should just return null on a null parameter.

What happens if you set my_path to some non-null but un-matched value
before the problem line?


When my_path have non-null value, everything is OK...

I don't understand why one null value would crash the server???


Because it attempts to follow a pointer that isn't there.

If you installed from source, can you check contrib/ltree/ltree.sql.in
and check the "isstrict" attribute is set:
CREATE FUNCTION ltree_isparent( ltree,ltree)
RETURNS bool
AS 'MODULE_PATHNAM E'
LANGUAGE 'C' WITH (isstrict,iscac hable);

If it is, then you'll have to wait for a developer to take an interest,
I'm stumped. Shouldn't take long, but if you wanted to be thorough you
could report a bug via the bugs mailing list or the website.

--
Richard Huxton
Archonet Ltd

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

Nov 23 '05 #5
Michal Hlavac <hl****@medium1 3.sk> writes:
I have stored procedure, which works good, but only if input is "correct".
Correct input is, when $1 is id, which exists in table...
If I put non exists id, database fall down and restart with this error:
server closed the connection unexpectedly


I can't reproduce a crash here, but perhaps that's because you have not
supplied any sample data...

regards, tom lane

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

Nov 23 '05 #6
Michal Hlavac <hl****@medium1 3.sk> writes:
Tom Lane wrote:
I can't reproduce a crash here, but perhaps that's because you have not
supplied any sample data...
I attached file with data, where it fails...


Thanks. It turns out the main reason I couldn't reproduce it was
I was testing in CVS tip, where the bug had already been repaired.
I've applied the attached patch to the 7.4 branch to fix it there.

regards, tom lane

Index: gistget.c
=============== =============== =============== =============== =======
RCS file: /cvsroot/pgsql-server/src/backend/access/gist/gistget.c,v
retrieving revision 1.36
diff -c -r1.36 gistget.c
*** gistget.c 4 Aug 2003 02:39:57 -0000 1.36
--- gistget.c 27 Aug 2004 17:44:04 -0000
***************
*** 234,249 ****
key[0].sk_attno,
giststate->tupdesc,
&isNull);
if (isNull)
{
/* XXX eventually should check if SK_ISNULL */
return false;
}
!
! /* this code from backend/access/common/indexvalid.c. But why and what???
if (key[0].sk_flags & SK_ISNULL)
return false;
! */
gistdentryinit( giststate, key[0].sk_attno - 1, &de,
datum, r, p, offset,
IndexTupleSize( tuple) - sizeof(IndexTup leData),
--- 234,249 ----
key[0].sk_attno,
giststate->tupdesc,
&isNull);
+ /* is the index entry NULL? */
if (isNull)
{
/* XXX eventually should check if SK_ISNULL */
return false;
}
! /* is the compared-to datum NULL? */
if (key[0].sk_flags & SK_ISNULL)
return false;
!
gistdentryinit( giststate, key[0].sk_attno - 1, &de,
datum, r, p, offset,
IndexTupleSize( tuple) - sizeof(IndexTup leData),

---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddres sHere" to ma*******@postg resql.org)

Nov 23 '05 #7

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

Similar topics

3
22146
by: dinesh prasad | last post by:
I'm trying to use a servlet to process a form, then send that data to an SQL server stored procedure. I'm using the WebLogic 8 App. server. I am able to retrieve database information, so I know my application server can talk to the database. I've determined the failure occurs when the the following statement is executed: cstmt.execute(); (due to the failure of println statements placed afterwards). I get the following error after trying to...
3
4684
by: new | last post by:
Question: What would be the best way to add carrage returns to a record, and would my method create alot of overhead and wasted space. What would be the best method to minimize overhead and wasted space. Scenario: Server MS SQL 2000 Table name= mitTickets Fields= problem,details, created, lupdate
4
23497
by: Paul | last post by:
Hi, In SQL Books Online in the section on @@Error it gives the following example: -- Execute the INSERT statement. INSERT INTO authors (au_id, au_lname, au_fname, phone, address, city, state, zip, contract) values (@au_id,@au_lname,@au_fname,@phone,@address,
2
4962
by: Jose Perez | last post by:
Dear All, I have 2 SP's, one (let's call it sp_A) which returns a list of files and another (let's call it sp_B) which recursively looks through a menu table to give me the location of the file. I call sp_B within sp_A as I want to return the data in one table. I am having trouble in getting the results back. Both SP's work independantly but when they are put together I get an error. Any help will be greatly appreciated!!
4
8102
by: MD | last post by:
I am trying to create a dynamic SQL statement to create a view. I have a stored procedure, which based on the parameters passed calls different stored procedures. Each of this sub stored procedure creates a string of custom SQL statement and returns this string back to the main stored procedure. This SQL statements work fine on there own. The SQL returned from the sub stored procedure are returned fine. The datatype of the variable that...
4
13468
by: marc | last post by:
I've been developing a stored procedure that uses a user defined function in the query portion of the procedure. However, since the end product needs to allow for dynamic table names, the UDF will not work. I've been trying to get this to work with converting the UDF to a procedure, but I'm having no luck. Here is the background on what I'm trying to accomplish. I need to perform a sub-identity on a table, I have the normal identity set,...
8
7258
by: N.V.Dev | last post by:
Hi, I am trying to use the db2load API using C. During run-time below is the error message thrown call utils.load_table('util.temp') SQL1131N DARI (Stored Procedure) process has been terminated abnormally. SQLSTATE=38503
4
4405
by: Nyul | last post by:
Gurus, I have a verb big problem which I'm unable to explain. We have a DB2 V6.1.0 on AIX 4.3 I want to make a C stored procedure which at the end will be called by a PHP script. The development server was an UDB V6.1.0 on W2K. Everything went well. I was able to call the stored proc from C and from Delphi.
3
6033
by: David Carver | last post by:
We are running into a problem with a Communication Link failure when calling an External Stored procedure written in ILE Cobol from an SQL UDF. When calling the stored procedure by itself and not within the UDF it runs fine, it's only when we excute the UDF that we get the communication link failure. I have setup EXTERNAL ACTION on the the UDF, the COBOL program doesn't execute any SQL statements. Here is the function and how it is...
2
6390
by: Krij | last post by:
Hi, I'm a student and I have the following working example that troubles me (in SQL Server 2005): CREATE PROCEDURE dbo.CustomersOrderHistory ( @Firstname varchar(7) OUTPUT) AS SELECT dbo.Customers.Firstname, dbo.Orders.Orderdate, dbo.Orderdetails.Orderamount, dbo.Orderdetails.Orderprice,
0
9645
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
9480
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10330
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
10093
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,...
0
8976
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7500
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
5381
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
5511
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2880
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.