From: | Josh Kupershmidt <schmiddy(at)gmail(dot)com> |
---|---|
To: | Lukas <lukas(at)fmf(dot)vgtu(dot)lt> |
Cc: | pgsql-novice(at)postgresql(dot)org |
Subject: | Re: Get file size |
Date: | 2012-09-04 21:37:56 |
Message-ID: | CAK3UJRE3dYV4=mjg4g+tZZUHsiFPa5z7Ng8UCEtLOc-pU0VQug@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-novice |
On Tue, Sep 4, 2012 at 12:09 PM, Lukas <lukas(at)fmf(dot)vgtu(dot)lt> wrote:
> 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..
If the files you need to read are located within your PGDATA
directory, you could get away with using pg_stat_file(). Otherwise, I
think you'll need to create a quick function in PL/Python, PL/Perl, or
similar. Example:
CREATE OR REPLACE FUNCTION file_size (v_fname text)
RETURNS bigint
AS $$
import os
size = None
try:
size = os.path.getsize(v_fname)
except os.error, exc:
pass
return size
$$ LANGUAGE plpythonu VOLATILE STRICT;
Josh
From | Date | Subject | |
---|---|---|---|
Next Message | lazyPGDBA | 2012-09-05 15:02:42 | pg_dump error on hot standy db (msg or pg_toast missing a chunk number). |
Previous Message | Alan Hodgson | 2012-09-04 19:51:42 | Re: Get file size |