Pg: Add text2bin() and bin2text() conversion methods
This commit is contained in:
parent
beeefcf337
commit
76f55f277b
4 changed files with 93 additions and 3 deletions
19
FU/Pg.pm
19
FU/Pg.pm
|
|
@ -780,9 +780,24 @@ to be sent to (and further validated by) Postgres. For some types,
|
|||
C<perl2bin()> may return invalid data on invalid input and C<bin2perl()> may
|
||||
accept invalid binary data.
|
||||
|
||||
=back
|
||||
=item $conn->bin2text($oid, $bin, ...)
|
||||
|
||||
I<TODO:> Methods to convert between bin and text formats.
|
||||
=item $conn->text2bin($oid, $text, ...)
|
||||
|
||||
Convert between the binary format and the PostgreSQL text format. This
|
||||
conversion requires a round-trip to the server and throws an error if the
|
||||
connection state is not I<idle> or I<txn_idle>. Since it is Postgres doing the
|
||||
conversion, the input is properly validated and, in the case of C<bin2text()>,
|
||||
the result is guaranteed to be suitable for use as a textual bind parameter or
|
||||
for inclusion in an SQL query (but don't forget to use C<escape_literal()> in
|
||||
that case).
|
||||
|
||||
Calling these methods many times can be pretty slow. If you have several values
|
||||
to convert, you can do that in a single call to speed things up:
|
||||
|
||||
my($text1, $text2, ..) = $conn->bin2text($oid1, $bin1, $oid2, $bin2, ..);
|
||||
|
||||
=back
|
||||
|
||||
I<TODO:> Methods to query type info.
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue