File tree 1 file changed +62
-0
lines changed
1 file changed +62
-0
lines changed Original file line number Diff line number Diff line change
1
+ \set ECHO
2
+ \set QUIET 1
3
+
4
+ \pset format unaligned
5
+ \pset tuples_only true
6
+ \pset pager
7
+
8
+ \set ON_ERROR_ROLLBACK 1
9
+ \set ON_ERROR_STOP true
10
+ \set QUIET 1
11
+
12
+ SET client_encoding = utf8;
13
+
14
+ BEGIN ;
15
+ SELECT plan(5 );
16
+
17
+ SELECT lives_ok( ' CREATE LANGUAGE plperl' , ' Language creation should work fine?!' );
18
+
19
+ SELECT lives_ok(
20
+ $FUNC$
21
+ CREATE function test_output () RETURNS BYTEA as $$
22
+ my $reply = " \000" x6;
23
+ for (1 ..255 ) {
24
+ $reply .= chr($_);
25
+ }
26
+ $reply .= " \000" x 6 ;
27
+ $reply = ~ s/ ./ sprintf " \\%03o" , ord $&/ ges;
28
+ return $reply;
29
+ $$ language plperl
30
+ $FUNC$
31
+ );
32
+
33
+ SELECT ok( test_output() = decode(
34
+ ' 0000000000000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F202122232425262' ||
35
+ ' 728292A2B2C2D2E2F303132333435363738393A3B3C3D3E3F404142434445464748494A4B4C4D4E4F50515253' ||
36
+ ' 5455565758595A5B5C5D5E5F606162636465666768696A6B6C6D6E6F707172737475767778797A7B7C7D7E7F8' ||
37
+ ' 08182838485868788898A8B8C8D8E8F909192939495969798999A9B9C9D9E9FA0A1A2A3A4A5A6A7A8A9AAABAC' ||
38
+ ' ADAEAFB0B1B2B3B4B5B6B7B8B9BABBBCBDBEBFC0C1C2C3C4C5C6C7C8C9CACBCCCDCECFD0D1D2D3D4D5D6D7D8D' ||
39
+ ' 9DADBDCDDDEDFE0E1E2E3E4E5E6E7E8E9EAEBECEDEEEFF0F1F2F3F4F5F6F7F8F9FAFBFCFDFEFF000000000000' ,
40
+ ' hex' ));
41
+
42
+ SELECT lives_ok(
43
+ $FUNC$
44
+ CREATE function test_input (bytea ) RETURNS int4 as $$
45
+ my $reply = 0 ;
46
+ my $input = shift;
47
+ if ( $input = ~ s/ ^\\x// ) {
48
+ $input = ~ s/ ([0 - 9a- f]{2 })/ chr hex $1 / eig;
49
+ } else {
50
+ $input = ~ s/ \\([0 - 7 ]{3 })/ chr oct $1 / eig;
51
+ }
52
+ for my $char ( split // , $input ) {
53
+ $reply + = ord( $char );
54
+ }
55
+ return $reply;
56
+ $$ language plperl
57
+ $FUNC$
58
+ );
59
+ SELECT is( test_input( decode(' 00010220' , ' hex' )), 35 );
60
+
61
+ SELECT * FROM finish();
62
+ ROLLBACK ;
You can’t perform that action at this time.
0 commit comments