Thread: BUG #3673: Untrusted perl language: ERROR: could not open relation 1663/16384/1259: No such file or directory
BUG #3673: Untrusted perl language: ERROR: could not open relation 1663/16384/1259: No such file or directory
From
"Timur Luchkin"
Date:
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=#
Re: BUG #3673: Untrusted perl language: ERROR: could not open relation 1663/16384/1259: No such file or directory
From
"Heikki Linnakangas"
Date:
Timur Luchkin wrote: > 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: > ... > chdir("$base_path"); > ... Don't do that. Postgres sets the current directory to the data directory, and uses relative paths to access all the relation files. Calling chdir will confuse the server. You could use absolute paths in your plperlu function instead. -- Heikki Linnakangas EnterpriseDB http://www.enterprisedb.com