Discussion:
Get file size
(too old to reply)
Lukas
2012-09-04 19:39:58 UTC
Permalink
Hello,

maybe someone can give an idea how I cat get sizes of file which location
is know?
Lets say I have table with 200k records, in every record one column
indicates full file path on server for ex. "c:\temp\test.txt" etc. and I
want to fill that table with file sizes..
I was looking for function in plpgsql or plpgper languages, but I did not
found anything what could help me..

Lukas
--
Sent via pgsql-novice mailing list (pgsql-***@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-novice
Matt Musgrove
2012-09-05 15:15:28 UTC
Permalink
plpgsql is a trusted language so it can't access the file system.

I'd do it with plpgperlu but then again, Perl is my favorite language.

// Totally off-the-cuff (i.e. untested) example code to get you started
CREATE FUNCTION check_file_size (character varying)
RETURNS integer AS $BODY$
my ( $filepath ) = @_;
return 0 unless defined $filepath;
return -s $filepath; # returns size in bytes
$BODY$ LANGUAGE plperlu;

________________________________________
From: pgsql-novice-***@postgresql.org [pgsql-novice-***@postgresql.org] on behalf of Lukas [***@fmf.vtu.lt]
Sent: Tuesday, September 04, 2012 2:39 PM
To: pgsql-***@postgresql.org
Subject: [NOVICE] Get file size

Hello,

maybe someone can give an idea how I cat get sizes of file which location
is know?
Lets say I have table with 200k records, in every record one column
indicates full file path on server for ex. "c:\temp\test.txt" etc. and I
want to fill that table with file sizes..
I was looking for function in plpgsql or plpgper languages, but I did not
found anything what could help me..

Lukas







--
Sent via pgsql-novice mailing list (pgsql-***@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-novice
--
Sent via pgsql-novice mailing list (pgsql-***@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-novice
Loading...