Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
Postgres FD Implementation
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Abuhujair Javed
Postgres FD Implementation
Commits
290f1603
Commit
290f1603
authored
Dec 15, 2010
by
Robert Haas
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Some copy editing of pg_read_binary_file() patch.
parent
afc8f47b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
9 deletions
+11
-9
doc/src/sgml/func.sgml
doc/src/sgml/func.sgml
+9
-7
src/backend/utils/adt/genfile.c
src/backend/utils/adt/genfile.c
+2
-2
No files found.
doc/src/sgml/func.sgml
View file @
290f1603
...
...
@@ -14489,19 +14489,21 @@ postgres=# SELECT * FROM pg_xlogfile_name_offset(pg_stop_backup());
at the given
<parameter>
offset
</>
, returning at most
<parameter>
length
</>
bytes (less if the end of file is reached first). If
<parameter>
offset
</>
is negative, it is relative to the end of the file.
When
<parameter>
offset
</>
and
<parameter>
length
</>
parameters are omitted,
it returns the whole of the file.
The part of a file must be a valid text in the server encoding.
If
<parameter>
offset
</>
and
<parameter>
length
</>
are omitted, the entire
file is returned. The bytes read from the file are interpreted as a string
in the server encoding; an error is thrown if they are not valid in that
encoding.
</para>
<indexterm>
<primary>
pg_read_binary_file
</primary>
</indexterm>
<para>
<function>
pg_read_binary_file
</>
returns part of a file as like as
<function>
pg_read_file
</>
, but the result is a bytea value.
One of the usages is to read a file in the specified encoding combined with
<function>
convert_from
</>
function:
<function>
pg_read_binary_file
</>
is similar to
<function>
pg_read_file
</>
, except that the result is a bytea value;
accordingly, no encoding checks are performed.
In combination with the
<function>
convert_from
</>
function, this function
can be used to read a file in a specified encoding:
<programlisting>
SELECT convert_from(pg_read_binary_file('file_in_utf8.txt'), 'UTF8');
</programlisting>
...
...
src/backend/utils/adt/genfile.c
View file @
290f1603
...
...
@@ -152,7 +152,7 @@ read_binary_file(text *filename_t, int64 seek_offset, int64 bytes_to_read)
}
/*
*
In addition to read_binary_file, verify whether the contents are encode
d
*
Similar to read_binary_file, but we verify that the contents are vali
d
* in the database encoding.
*/
static
text
*
...
...
@@ -163,7 +163,7 @@ read_text_file(text *filename, int64 seek_offset, int64 bytes_to_read)
/* Make sure the input is valid */
pg_verifymbstr
(
VARDATA
(
buf
),
VARSIZE
(
buf
)
-
VARHDRSZ
,
false
);
/* OK, we can cast it
as
text safely */
/* OK, we can cast it
to
text safely */
return
(
text
*
)
buf
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment