Greetings.
I am very new to PostgreSQL so apologies in advance if this bug report is a waste of time for some reason.


Summary:
I have been experimenting with 8.0 Beta4 on Windows XP and the attached SQL resulted in a crash of the database (not the postmaster as far as I can tell). My code creates a function, then another function to test it. Then the test function is executed. During the execution of the test function the process crashes.


Version:
PostgreSQL 8.0.0beta4 on i686-pc-mingw32, compiled by GCC gcc.exe (GCC) 3.3.1 (mingw special 20030804-1)
OS: Windows XP SP1


Recreating the problem:
Create a database and run the attached script against it using psql.

Observed Outcome:
postgres.exe crashes. See log file extract below.

Expected Outcome:
Either the tests should run to completion or an exception should be raised (in the likely event that my syntax or logic is flawed).


FYI I have implemented my logic in a new way, so I don't need a fix, but thought I'd pass on the details all the same.

Best Regards,
- John.



pg_log Extract
=========

2004-11-16 08:58:41 NOTICE:  00000: PASS: / did not raise an exception

2004-11-16 08:58:41 LOCATION:  exec_stmt_raise, pl_exec.c:1968

2004-11-16 08:58:41 NOTICE:  00000: PASS: /topdir did not raise an exception

2004-11-16 08:58:41 LOCATION:  exec_stmt_raise, pl_exec.c:1968

2004-11-16 08:58:41 NOTICE: 00000: PASS: /topdir/subdir did not raise an exception

2004-11-16 08:58:41 LOCATION:  exec_stmt_raise, pl_exec.c:1968

2004-11-16 08:58:41 NOTICE: 00000: PASS: /topdir/subdir/subsubdir did not raise an exception

2004-11-16 08:58:41 LOCATION:  exec_stmt_raise, pl_exec.c:1968

2004-11-16 08:58:41 NOTICE: 00000: FAIL: should have been identified as an invalid path

2004-11-16 08:58:41 LOCATION:  exec_stmt_raise, pl_exec.c:1968

2004-11-16 08:58:41 NOTICE:  00000: PASS: // did raise an exception

2004-11-16 08:58:41 LOCATION:  exec_stmt_raise, pl_exec.c:1968

2004-11-16 08:58:47 LOG: 00000: server process (PID 3652) was terminated by signal 5

2004-11-16 08:58:47 LOCATION:  LogChildExit, postmaster.c:2282

2004-11-16 08:58:47 LOG: 00000: terminating any other active server processes

2004-11-16 08:58:47 LOCATION:  HandleChildCrash, postmaster.c:2175

2004-11-16 08:58:47 LOG: 00000: all server processes terminated; reinitializing

2004-11-16 08:58:47 LOCATION:  reaper, postmaster.c:2074

2004-11-16 08:58:47 LOG: 00000: database system was interrupted at 2004-11-15 17:43:17 GMT Standard Time

2004-11-16 08:58:47 LOCATION:  StartupXLOG, xlog.c:4026

2004-11-16 08:58:47 LOG:  00000: checkpoint record is at 0/4EA3158

2004-11-16 08:58:47 LOCATION:  StartupXLOG, xlog.c:4095

2004-11-16 08:58:47 LOG: 00000: redo record is at 0/4EA3158; undo record is at 0/0; shutdown FALSE

2004-11-16 08:58:47 LOCATION:  StartupXLOG, xlog.c:4123

2004-11-16 08:58:47 LOG: 00000: next transaction ID: 26681; next OID: 135172

2004-11-16 08:58:47 LOCATION:  StartupXLOG, xlog.c:4126

2004-11-16 08:58:47 LOG: 00000: database system was not properly shut down; automatic recovery in progress

2004-11-16 08:58:47 LOCATION:  StartupXLOG, xlog.c:4182

2004-11-16 08:58:47 LOG:  00000: redo starts at 0/4EA3198

2004-11-16 08:58:47 LOCATION:  StartupXLOG, xlog.c:4219

2004-11-16 08:58:47 WARNING: 01000: could not remove database directory "C:/Program Files/PostgreSQL/8.0.0-beta4/data/base/128288"

2004-11-16 08:58:47 LOCATION:  dbase_redo, dbcommands.c:1214

2004-11-16 08:58:48 LOG:  00000: record with zero length at 0/4EB9F38

2004-11-16 08:58:48 LOCATION:  ReadRecord, xlog.c:2459

2004-11-16 08:58:48 LOG:  00000: redo done at 0/4EB9F08

2004-11-16 08:58:48 LOCATION:  StartupXLOG, xlog.c:4277

2004-11-16 08:58:49 LOG:  00000: database system is ready

2004-11-16 08:58:49 LOCATION:  StartupXLOG, xlog.c:4489

_________________________________________________________________
Don't just search. Find. Check out the new MSN Search! http://search.msn.com/

/* Function */

CREATE OR REPLACE FUNCTION dss_check_path(dss_path varchar)
 RETURNS void AS
$BODY$
BEGIN
        --test for empty directory names
        IF dss_path LIKE '%//%' THEN
                RAISE EXCEPTION '% contains an empty directory name', dss_path;
        END IF;

        --test if last directory is empty name

        IF dss_path LIKE '%/' AND dss_path <> '/' THEN
                RAISE EXCEPTION '% ends with an empty directory name', dss_path;
        END IF;

        --TODO: Check for invalid characters, trailing spaces, etc....

        RETURN;

END;
$BODY$
 LANGUAGE 'plpgsql' VOLATILE;

/* Test Function */

CREATE OR REPLACE FUNCTION test_dss_clean_path()
        RETURNS int4 AS
$BODY$
DECLARE
        valid_paths varchar[];
        invalid_paths varchar[];
        current_index int4 = 1;
        current_path varchar;
        max_index int4;

        error_count int4 := 0;
        test_count int4 := 0;
        input varchar;
BEGIN
        valid_paths := ARRAY['/',
                                        '/topdir',
                                        '/topdir/subdir',
                                        '/topdir/subdir/subsubdir'];

        invalid_paths := ARRAY['',
                                        '//',
                                        '//topdir',
                                        '///',
                                        '/topdir/',
                                        '/topdir/subdir/',
                                        '/topdir/subdir/subsubdir/'];

        /* Test valid paths: should not raise an exception */

        max_index := array_upper(valid_paths, 1);
        current_index := 1;

BEGIN
WHILE current_index <= max_index LOOP
current_path := valid_paths[current_index];
PERFORM dss_check_path(current_path);
--exception not expected
RAISE NOTICE 'PASS: % did not raise an exception', current_path;
current_index := current_index + 1;
test_count := test_count + 1;
END LOOP;
EXCEPTION
WHEN OTHERS THEN
RAISE NOTICE 'FAIL: % should not have been identified as being an invalid path', current_path;
error_count := error_count + 1;
END;


        /* Test invalid paths: should raise an exception */

        max_index := array_upper(invalid_paths, 1);
        current_index := 1;

WHILE current_index <= max_index LOOP
BEGIN
current_path := invalid_paths[current_index];
PERFORM dss_check_path(current_path);
RAISE NOTICE 'FAIL: % should have been identified as an invalid path', current_path;
error_count := error_count + 1;
EXCEPTION
WHEN OTHERS THEN
--exception expected
RAISE NOTICE 'PASS: % did raise an exception', current_path;
END;
current_index := current_index + 1;
test_count := test_count + 1;
END LOOP;



IF error_count = 0 THEN RAISE NOTICE 'SUCCESS: All % tests passed', test_count; ELSE RAISE NOTICE 'FAILURE: % out of % tests failed', error_count, test_count; END IF;

        RETURN error_count;
END;

$BODY$
 LANGUAGE 'plpgsql' VOLATILE;

/* Call Test Function */

SELECT test_dss_clean_path();

/* Drop Test Function */

DROP FUNCTION test_dss_clean_path();
---------------------------(end of broadcast)---------------------------
TIP 7: don't forget to increase your free space map settings

Reply via email to