Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Greenplum
Gpdb
提交
5acde74e
G
Gpdb
项目概览
Greenplum
/
Gpdb
通知
7
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
Gpdb
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
5acde74e
编写于
3月 10, 2007
作者:
A
Andrew Dunstan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add alternate result file for large object tests to handle Windows line ends.
上级
c0aa5063
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
275 addition
and
0 deletion
+275
-0
src/test/regress/output/largeobject_1.source
src/test/regress/output/largeobject_1.source
+275
-0
未找到文件。
src/test/regress/output/largeobject_1.source
0 → 100644
浏览文件 @
5acde74e
--
-- Test large object support
--
-- Load a file
CREATE TABLE lotest_stash_values (loid oid, fd integer);
-- lo_creat(mode integer) returns oid
-- The mode arg to lo_creat is unused, some vestigal holdover from ancient times
-- returns the large object id
INSERT INTO lotest_stash_values (loid) SELECT lo_creat(42);
-- NOTE: large objects require transactions
BEGIN;
-- lo_open(lobjId oid, mode integer) returns integer
-- The mode parameter to lo_open uses two constants:
-- INV_READ = 0x20000
-- INV_WRITE = 0x40000
-- The return value is a file descriptor-like value which remains valid for the
-- transaction.
UPDATE lotest_stash_values SET fd = lo_open(loid, CAST(x'20000' | x'40000' AS integer));
-- loread/lowrite names are wonky, different from other functions which are lo_*
-- lowrite(fd integer, data bytea) returns integer
-- the integer is the number of bytes written
SELECT lowrite(fd, '
Whose woods these are I think I know,
His house is in the village though.
He will not see me stopping here,
To watch his woods fill up with snow.
My little horse must think it queer,
To stop without a farmhouse near,
Between the woods and frozen lake,
The darkest evening of the year.
He gives his harness bells a shake,
To ask if there is some mistake.
The only other sound''s the sweep,
Of easy wind and downy flake.
The woods are lovely, dark and deep,
But I have promises to keep,
And miles to go before I sleep,
And miles to go before I sleep.
-- Robert Frost
') FROM lotest_stash_values;
lowrite
---------
578
(1 row)
-- lo_close(fd integer) returns integer
-- return value is 0 for success, or <0 for error (actually only -1, but...)
SELECT lo_close(fd) FROM lotest_stash_values;
lo_close
----------
0
(1 row)
END;
-- Read out a portion
BEGIN;
UPDATE lotest_stash_values SET fd=lo_open(loid, CAST(x'20000' | x'40000' AS integer));
-- lo_lseek(fd integer, offset integer, whence integer) returns integer
-- offset is in bytes, whence is one of three values:
-- SEEK_SET (= 0) meaning relative to beginning
-- SEEK_CUR (= 1) meaning relative to current position
-- SEEK_END (= 2) meaning relative to end (offset better be negative)
-- returns current position in file
SELECT lo_lseek(fd, 422, 0) FROM lotest_stash_values;
lo_lseek
----------
422
(1 row)
-- loread/lowrite names are wonky, different from other functions which are lo_*
-- loread(fd integer, len integer) returns bytea
SELECT loread(fd, 35) FROM lotest_stash_values;
loread
-------------------------------------
The woods are lovely, dark and deep
(1 row)
SELECT lo_lseek(fd, -19, 1) FROM lotest_stash_values;
lo_lseek
----------
438
(1 row)
SELECT lowrite(fd, 'n') FROM lotest_stash_values;
lowrite
---------
1
(1 row)
SELECT lo_tell(fd) FROM lotest_stash_values;
lo_tell
---------
439
(1 row)
SELECT lo_lseek(fd, -156, 2) FROM lotest_stash_values;
lo_lseek
----------
422
(1 row)
SELECT loread(fd, 35) FROM lotest_stash_values;
loread
-------------------------------------
The woods are lonely, dark and deep
(1 row)
SELECT lo_close(fd) FROM lotest_stash_values;
lo_close
----------
0
(1 row)
END;
-- Test truncation.
BEGIN;
UPDATE lotest_stash_values SET fd=lo_open(loid, CAST(x'20000' | x'40000' AS integer));
SELECT lo_truncate(fd, 10) FROM lotest_stash_values;
lo_truncate
-------------
0
(1 row)
SELECT loread(fd, 15) FROM lotest_stash_values;
loread
---------------
\012Whose woo
(1 row)
SELECT lo_truncate(fd, 10000) FROM lotest_stash_values;
lo_truncate
-------------
0
(1 row)
SELECT loread(fd, 10) FROM lotest_stash_values;
loread
------------------------------------------
\000\000\000\000\000\000\000\000\000\000
(1 row)
SELECT lo_lseek(fd, 0, 2) FROM lotest_stash_values;
lo_lseek
----------
10000
(1 row)
SELECT lo_tell(fd) FROM lotest_stash_values;
lo_tell
---------
10000
(1 row)
SELECT lo_truncate(fd, 5000) FROM lotest_stash_values;
lo_truncate
-------------
0
(1 row)
SELECT lo_lseek(fd, 0, 2) FROM lotest_stash_values;
lo_lseek
----------
5000
(1 row)
SELECT lo_tell(fd) FROM lotest_stash_values;
lo_tell
---------
5000
(1 row)
SELECT lo_close(fd) FROM lotest_stash_values;
lo_close
----------
0
(1 row)
END;
-- lo_unlink(lobjId oid) returns integer
-- return value appears to always be 1
SELECT lo_unlink(loid) from lotest_stash_values;
lo_unlink
-----------
1
(1 row)
TRUNCATE lotest_stash_values;
INSERT INTO lotest_stash_values (loid) SELECT lo_import('@abs_srcdir@/data/tenk.data');
BEGIN;
UPDATE lotest_stash_values SET fd=lo_open(loid, CAST(x'20000' | x'40000' AS integer));
-- with the default BLKSZ, LOBLKSZ = 2048, so this positions us for a block
-- edge case
SELECT lo_lseek(fd, 2030, 0) FROM lotest_stash_values;
lo_lseek
----------
2030
(1 row)
-- this should get half of the value from page 0 and half from page 1 of the
-- large object
SELECT loread(fd, 36) FROM lotest_stash_values;
loread
--------------------------------------------------------------
44\011144\0111144\0114144\0119144\01188\01189\011SNAAAA\011F
(1 row)
SELECT lo_tell(fd) FROM lotest_stash_values;
lo_tell
---------
2066
(1 row)
SELECT lo_lseek(fd, -26, 1) FROM lotest_stash_values;
lo_lseek
----------
2040
(1 row)
SELECT lowrite(fd, 'abcdefghijklmnop') FROM lotest_stash_values;
lowrite
---------
16
(1 row)
SELECT lo_lseek(fd, 2030, 0) FROM lotest_stash_values;
lo_lseek
----------
2030
(1 row)
SELECT loread(fd, 36) FROM lotest_stash_values;
loread
--------------------------------------------------
44\011144\011114abcdefghijklmnop9\011SNAAAA\011F
(1 row)
SELECT lo_close(fd) FROM lotest_stash_values;
lo_close
----------
0
(1 row)
END;
SELECT lo_export(loid, '@abs_builddir@/results/lotest.txt') FROM lotest_stash_values;
lo_export
-----------
1
(1 row)
\lo_import 'results/lotest.txt'
\set newloid :LASTOID
-- just make sure \lo_export does not barf
\lo_export :newloid 'results/lotest2.txt'
-- This is a hack to test that export/import are reversible
-- This uses knowledge about the inner workings of large object mechanism
-- which should not be used outside it. This makes it a HACK
SELECT pageno, data FROM pg_largeobject WHERE loid = (SELECT loid from lotest_stash_values)
EXCEPT
SELECT pageno, data FROM pg_largeobject WHERE loid = :newloid;
pageno | data
--------+------
(0 rows)
SELECT lo_unlink(loid) FROM lotest_stash_values;
lo_unlink
-----------
1
(1 row)
\lo_unlink :newloid
TRUNCATE lotest_stash_values;
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录