시도하지만, 문서보고 : 일부 파일 시스템 API가 필요로 같은 기술을 사용한다고 생각 http://www.postgresql.org/docs/current/interactive/lo-interfaces.html#LO-TELL
: 추구 끝, 다음 위치를 말해. PostgreSQL은 내부 C 함수를 감싸는 것처럼 보이는 SQL 함수를 가지고 있습니다. 나는 많은 문서를 찾을 수 없습니다, 그러나 이것은 일 :
CREATE OR REPLACE FUNCTION get_lo_size(oid) RETURNS bigint
VOLATILE STRICT
LANGUAGE 'plpgsql'
AS $$
DECLARE
fd integer;
sz bigint;
BEGIN
-- Open the LO; N.B. it needs to be in a transaction otherwise it will close immediately.
-- Luckily a function invocation makes its own transaction if necessary.
-- The mode x'40000'::int corresponds to the PostgreSQL LO mode INV_READ = 0x40000.
fd := lo_open($1, x'40000'::int);
-- Seek to the end. 2 = SEEK_END.
PERFORM lo_lseek(fd, 0, 2);
-- Fetch the current file position; since we're at the end, this is the size.
sz := lo_tell(fd);
-- Remember to close it, since the function may be called as part of a larger transaction.
PERFORM lo_close(fd);
-- Return the size.
RETURN sz;
END;
$$;
테스트를이 :
-- Make a new LO, returns an OID e.g. 1234567
SELECT lo_create(0);
-- Populate it with data somehow
...
-- Get the length.
SELECT get_lo_size(1234567);
그것은이 LO 기능은 클라이언트를 통해 또는 낮은 수준의 서버 프로그래밍을 통해 대부분 사용할 수 있도록 설계되었습니다 것 같다 그러나 적어도 그들은 SQL 가시 함수를 제공하여 위와 같은 것을 가능하게합니다. 나 자신을 시작하려면 SELECT relname FROM pg_proc where relname LIKE 'lo%'
에 대한 쿼리를 수행했습니다. C 프로그래밍에 대한 막연한 기억과 모드 x'40000'::int
및 SEEK_END = 2
값에 대한 약간의 연구가 나머지에 필요했습니다!
같은 질문을 게시하기 전에 설명서를 읽어 보시기 바랍니다 : 당신이 꽤 인쇄하려면
정의 http://www.postgresql.org/docs/current/static/functions.html –
을 "BLOB 데이터 ". 바이트 열'? 또는'pg_largeobject'에 저장된 큰 오브젝트? 테이블 정의를 표시하십시오. –
[PostgresSQL에서 객체 크기 얻기] (http://stackoverflow.com/questions/9248738/obailable-the-size-of-lobject-in-postgressql)의 중복? –