BUG #3673: Untrusted perl language: ERROR: could not open relation 1663/16384/1259: No such file or directory - Mailing list pgsql-bugs

From Timur Luchkin
Subject BUG #3673: Untrusted perl language: ERROR: could not open relation 1663/16384/1259: No such file or directory
Date
Msg-id 200710121301.l9CD17ab098721@wwwmaster.postgresql.org
Whole thread Raw
Responses Re: BUG #3673: Untrusted perl language: ERROR: could not open relation 1663/16384/1259: No such file or directory
List pgsql-bugs
The following bug has been logged online:

Bug reference:      3673
Logged by:          Timur Luchkin
Email address:      timur.luchkin@ctxm.com
PostgreSQL version: 8.2.5
Operating system:   Fedora Core 5 / Red Hat Ent. Linux AS 3
Description:        Untrusted perl language: ERROR: could not open relation
1663/16384/1259: No such file or directory
Details:

I have stored procedure in "plperlu" language. After the call to it Im
getting "could not open relation ... No such file or directory" on any next
operation in psql (the procedure itself works fine). If I'll close the
console and reopen it again, then everything works fine again (until the
next call to it).

Perl's SP code:

CREATE OR REPLACE FUNCTION fnc_prepare_base_dir (base_path IN  TEXT)
RETURNS INTEGER AS
$$
   my $base_path = $_[0];
   my $status = 0;

   if (-d "$base_path") {
      chdir("$base_path");
      @files = <*.cpio>;
      foreach $file (sort @files) {
         if (-f "$base_path/$file") {
            $status = system("cd $base_path > /dev/null; cpio --quiet -idmv
--no-absolute-filenames < $file > /dev/null; rm -f $file > /dev/null");
            if ($status > 0) {
               return $status;
            }
        }
      }
      return 0;
   }
   else {
      return 5;
   }
$$
LANGUAGE plperlu;


To repeat this do the next:

$psql -U tham
Welcome to psql 8.2.5, the PostgreSQL interactive terminal.

Type:  \copyright for distribution terms
       \h for help with SQL commands
       \? for help with psql commands
       \g or terminate with semicolon to execute query
       \q to quit

mydb=# SELECT * FROM fnc_prepare_base_dir
('/export/storage3/postgres/etl_data');
 fnc_prepare_base_dir
----------------------
                    0
(1 row)

mydb=# \dt
ERROR:  could not open relation 1663/16384/1259: No such file or directory
mydb=# \q

$ psql -U tham
Welcome to psql 8.2.5, the PostgreSQL interactive terminal.

Type:  \copyright for distribution terms
       \h for help with SQL commands
       \? for help with psql commands
       \g or terminate with semicolon to execute query
       \q to quit

mydb=# \dt
       List of relations
 Schema | Name  | Type  | Owner
--------+-------+-------+-------
 public | cust1 | table | tham
 public | abc2  | table | tham
(2 rows)

mydb=#

pgsql-bugs by date:

Previous
From: "Marc Mamin"
Date:
Subject: BUG #3672: ALTER TYPE change the underlying index tablespace to default
Next
From: "Heikki Linnakangas"
Date:
Subject: Re: BUG #3673: Untrusted perl language: ERROR: could not open relation 1663/16384/1259: No such file or directory