diff options
author | Alvaro Herrera <alvherre@alvh.no-ip.org> | 2012-07-10 16:46:59 -0400 |
---|---|---|
committer | Alvaro Herrera <alvherre@alvh.no-ip.org> | 2012-07-10 16:46:59 -0400 |
commit | 892a8d05440deaf0f73b91a98f35d32b9415d497 (patch) | |
tree | d113496058b1231c0b2149cccbdd8dff69664410 /src | |
parent | fc661f78c6007103604fc43e98622a71400b769f (diff) | |
download | postgresql-892a8d05440deaf0f73b91a98f35d32b9415d497.tar.gz postgresql-892a8d05440deaf0f73b91a98f35d32b9415d497.zip |
Add forgotten PL/Perl regression test files
Due to a git hook blowing up in my face telling me I could not commit
Peter Eisentraut's patch on his name, I had to "git reset" to fix the
previous commit ... and then forgot that I needed to "git add" these
files :-(
Diffstat (limited to 'src')
-rw-r--r-- | src/pl/plperl/expected/plperl_lc.out | 33 | ||||
-rw-r--r-- | src/pl/plperl/expected/plperl_lc_1.out | 41 | ||||
-rw-r--r-- | src/pl/plperl/sql/plperl_lc.sql | 24 |
3 files changed, 98 insertions, 0 deletions
diff --git a/src/pl/plperl/expected/plperl_lc.out b/src/pl/plperl/expected/plperl_lc.out new file mode 100644 index 00000000000..8557b4655a5 --- /dev/null +++ b/src/pl/plperl/expected/plperl_lc.out @@ -0,0 +1,33 @@ +-- +-- Make sure strings are validated +-- Should fail for all encodings, as nul bytes are never permitted. +-- +CREATE OR REPLACE FUNCTION perl_zerob() RETURNS TEXT AS $$ + return "abcd\0efg"; +$$ LANGUAGE plperl; +SELECT perl_zerob(); +ERROR: invalid byte sequence for encoding "UTF8": 0x00 +CONTEXT: PL/Perl function "perl_zerob" +CREATE OR REPLACE FUNCTION perl_0x80_in(text) RETURNS BOOL AS $$ + return ($_[0] eq "abc\x80de" ? "true" : "false"); +$$ LANGUAGE plperl; +SELECT perl_0x80_in(E'abc\x80de'); +ERROR: invalid byte sequence for encoding "UTF8": 0x80 +CREATE OR REPLACE FUNCTION perl_0x80_out() RETURNS TEXT AS $$ + return "abc\x80de"; +$$ LANGUAGE plperl; +SELECT perl_0x80_out() = E'abc\x80de'; +ERROR: invalid byte sequence for encoding "UTF8": 0x80 +CREATE OR REPLACE FUNCTION perl_utf_inout(text) RETURNS TEXT AS $$ + $str = $_[0]; $code = "NotUTF8:"; $match = "ab\xe5\xb1\xb1cd"; + if (utf8::is_utf8($str)) { + $code = "UTF8:"; utf8::decode($str); $match="ab\x{5c71}cd"; + } + return ($str ne $match ? $code."DIFFER" : $code."ab\x{5ddd}cd"); +$$ LANGUAGE plperl; +SELECT encode(perl_utf_inout(E'ab\xe5\xb1\xb1cd')::bytea, 'escape') + encode +----------------------- + UTF8:ab\345\267\235cd +(1 row) + diff --git a/src/pl/plperl/expected/plperl_lc_1.out b/src/pl/plperl/expected/plperl_lc_1.out new file mode 100644 index 00000000000..c454c4409ed --- /dev/null +++ b/src/pl/plperl/expected/plperl_lc_1.out @@ -0,0 +1,41 @@ +-- +-- Make sure strings are validated +-- Should fail for all encodings, as nul bytes are never permitted. +-- +CREATE OR REPLACE FUNCTION perl_zerob() RETURNS TEXT AS $$ + return "abcd\0efg"; +$$ LANGUAGE plperl; +SELECT perl_zerob(); +ERROR: invalid byte sequence for encoding "SQL_ASCII": 0x00 +CONTEXT: PL/Perl function "perl_zerob" +CREATE OR REPLACE FUNCTION perl_0x80_in(text) RETURNS BOOL AS $$ + return ($_[0] eq "abc\x80de" ? "true" : "false"); +$$ LANGUAGE plperl; +SELECT perl_0x80_in(E'abc\x80de'); + perl_0x80_in +-------------- + t +(1 row) + +CREATE OR REPLACE FUNCTION perl_0x80_out() RETURNS TEXT AS $$ + return "abc\x80de"; +$$ LANGUAGE plperl; +SELECT perl_0x80_out() = E'abc\x80de'; + ?column? +---------- + t +(1 row) + +CREATE OR REPLACE FUNCTION perl_utf_inout(text) RETURNS TEXT AS $$ + $str = $_[0]; $code = "NotUTF8:"; $match = "ab\xe5\xb1\xb1cd"; + if (utf8::is_utf8($str)) { + $code = "UTF8:"; utf8::decode($str); $match="ab\x{5c71}cd"; + } + return ($str ne $match ? $code."DIFFER" : $code."ab\x{5ddd}cd"); +$$ LANGUAGE plperl; +SELECT encode(perl_utf_inout(E'ab\xe5\xb1\xb1cd')::bytea, 'escape') + encode +-------------------------- + NotUTF8:ab\345\267\235cd +(1 row) + diff --git a/src/pl/plperl/sql/plperl_lc.sql b/src/pl/plperl/sql/plperl_lc.sql new file mode 100644 index 00000000000..fd75bc0d703 --- /dev/null +++ b/src/pl/plperl/sql/plperl_lc.sql @@ -0,0 +1,24 @@ +-- +-- Make sure strings are validated +-- Should fail for all encodings, as nul bytes are never permitted. +-- +CREATE OR REPLACE FUNCTION perl_zerob() RETURNS TEXT AS $$ + return "abcd\0efg"; +$$ LANGUAGE plperl; +SELECT perl_zerob(); +CREATE OR REPLACE FUNCTION perl_0x80_in(text) RETURNS BOOL AS $$ + return ($_[0] eq "abc\x80de" ? "true" : "false"); +$$ LANGUAGE plperl; +SELECT perl_0x80_in(E'abc\x80de'); +CREATE OR REPLACE FUNCTION perl_0x80_out() RETURNS TEXT AS $$ + return "abc\x80de"; +$$ LANGUAGE plperl; +SELECT perl_0x80_out() = E'abc\x80de'; +CREATE OR REPLACE FUNCTION perl_utf_inout(text) RETURNS TEXT AS $$ + $str = $_[0]; $code = "NotUTF8:"; $match = "ab\xe5\xb1\xb1cd"; + if (utf8::is_utf8($str)) { + $code = "UTF8:"; utf8::decode($str); $match="ab\x{5c71}cd"; + } + return ($str ne $match ? $code."DIFFER" : $code."ab\x{5ddd}cd"); +$$ LANGUAGE plperl; +SELECT encode(perl_utf_inout(E'ab\xe5\xb1\xb1cd')::bytea, 'escape') |