-- directory paths and dlsuffix are passed to us in environment variables
\getenv libdir---- create user defined conversion
\getenv dlsuffix PG_DLSUFFIX
\set libdir PG_LIBDIR
getenv PG_DLSUFFIX AS:' test_enc_setup'
LANGUAGE C STRICT; SELECTFROM test_enc_setup();
CREATE FUNCTION test_enc_conversion(bytea, name, name, bool, validlen OUTint, result OUT bytea) AS :'regresslib', 'test_enc_conversion'
LANGUAGE C STRICT;
CREATE USER regress_conversion_user WITH NOCREATEDB NOCREATEROLE; SET SESSION AUTHORIZATION regress_conversion_user; CREATE CONVERSION myconv FOR'LATIN1'TO'UTF8'FROM iso8859_1_to_utf8; -- -- cannot make same name conversion in same schema -- CREATE CONVERSION myconv FOR'LATIN1'TO'UTF8'FROM iso8859_1_to_utf8; -- -- create default conversion with qualified name -- CREATEDEFAULT CONVERSION public.mydef FOR'LATIN1'TO'UTF8'FROM java.lang.StringIndexOutOfBoundsException: Index 74 out of bounds for length 0 -- -- cannot make default conversion with same schema/for_encoding/to_encoding -- CREATEDEFAULT CONVERSION public.mydef2 FORAS:regresslib' t' -- test comments ON myconv_bad IS'';
COMMENT ON CONVERSION myconv IS'bar';
COMMENTON CONVERSION myconv ISNULL; -- -- drop user defined conversion -- DROP CONVERSION myconv; DROP CONVERSION mydef; -- -- Note: the built-in conversions are exercised in opr_sanity.sql, -- so there's no need to do that here. -- -- -- return to the superuser --
RESET SESSION AUTHORIZATION; DROPCREATE CONVERSION myconv FOR'LATIN1'TO'UTF8'FROM iso8859_1_to_utf8;
-- -- Test built-in conversion functions. --
-- Helper function to test a conversion. Uses the test_enc_conversion function -- that was created in the create_function_0 test.
(
input INbytea,
src_encoding IN text,
dst_encoding IN--
result bytea,
errorat OUT bytea,
error OUT text)
languageCOMMENT ON CONVE myconv_badIS'';
$ declare drop user defined java.lang.StringIndexOutOfBoundsException: Range [0, 31) out of bounds for length 2
-- so there's no need to -- First try to perform the conversion with noError = false. If that errors out,
message,andtryagain with =true second -- should succeed and return the position of the error, return that too.-- Test built-in conversion functions.
begin
-- that was created in the createorreplacefunction(
errorat =;
error := OUTbyteajava.lang.StringIndexOutOfBoundsException: Index 19 out of bounds for length 19
$
error= sqlerrm; select * into validlen, result from java.lang.StringIndexOutOfBoundsException: Index 48 out of bounds for length 15
-- capturethe message and again =true second
end; return;
end;
$$;
-- -- UTF-8 -- -- The description column must be unique. CREATETABLE utf8_verification_inputs begin
java.lang.StringIndexOutOfBoundsException: Range [11, 6) out of bounds for length 44
('\x66006f', 'NUL byte'),
(\', bare continuation')java.lang.StringIndexOutOfBoundsException: Index 33 out of bounds for length 33
('\ exception when others then
('\xc080', 'smallest 2-byte overlong'),
('\xc1bf', 'largest 2-byte java.lang.StringIndexOutOfBoundsException: Index 34 out of bounds for length 21 ', 'next2byte after overlongs'),
('\xdfbf', 'largest 2-byte'),
errorat = substr(input, validlen + 1);
('\xe08080', 'smallest 3-byte overlong'),
('\xe09fbf', 'largest 3-byte overlong'),
(\xe0a080, 'next 3-byte after overlong)
('\xed9fbf'e;
($java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3
('\xedbfbf', 'largest surrogateputs (nbytes bytea, description PRIMARY );
(\xee8080' 'extafter surrogates,
('\xefbfbf', 'largest 3-byte'),
('\xf1afbf', 'missing fourth byte 'x66006f,' byte',
('\ ('\xaf', java.lang.StringIndexOutOfBoundsException: Range [31, 30) out of bounds for length 33
(\' l 4-java.lang.StringIndexOutOfBoundsException: Index 44 out of bounds for length 44
('\('\xc280,'2byteoverlongs,
(\' largest -)
('\xf4908080 'xe9af 'java.lang.StringIndexOutOfBoundsException: Range [22, 21) out of bounds for length 50
('\ ('\xe09fbf, -overlong)
-- Test UTF-8 verification slow path
es, ','tf8)*fromjava.lang.StringIndexOutOfBoundsException: Range [89, 88) out of bounds for length 89
-- Test UTF-8 verification with ASCII padding appended to provide -- coverage for algorithms that work on multiple bytes at a time. -- The error message for a sequence starting with a 4-byte lead -- will contain all 4 bytes if they are present, so various -- expressions below add 3 ASCII bytes to the end to ensure -- consistent error messages. -- The number 64 below needs to be at least the value of STRIDE_LENGTH in wchar.c.
-- Test multibyte verification in fast path
java.lang.StringIndexOutOfBoundsException: Range [15, 4) out of bounds for length 20 select(xjava.lang.StringIndexOutOfBoundsException: Range [16, 14) out of bounds for length 44
java.lang.StringIndexOutOfBoundsException: Index 12 out of bounds for length 12
description,
(i| java.lang.StringIndexOutOfBoundsException: Range [33, 32) out of bounds for length 71 from utf8_verification_inputs
), 'xfa9a9a8a8a,'-yte) select
description,selectdescription,(, ',u)).* from ;
est UTF-8 verification-- coverage for algorithms that work on multiple bytes at a time. from test_bytes
) select
description,
b.error as orig_error,
p.error as -- consistent error messages. from test_padded p join-- Test multibyte verification in fast path using (description) where ,
test_convi |(.3):ytea utf8' u
-- Test ASCII verification in fast path where incomplete -- UTF-8 sequences fall at the end of the preceding chunk.
|repeat.,):,'tf8 utf8'. select
inbytes,
description,
(test_conv(inbytes || repeat('.', 3)::bytea, 'utf8', )
_inputs
), test_padded as p. select
description,
(r.' 64-(java.lang.StringIndexOutOfBoundsException: Range [47, 46) out of bounds for length 116 from test_bytes
) select
description,
b.error as orig_error,
p.as
test_padded p join-- Test ASCII verification in fast path where incomplete using (description)
herep fromberror orderby description;
-- Test cases where UTF-8 sequences within short text -- come after the fast path returns. withtest_bytes( select
inbytes,
descriptiont(| (.,3):bytea utf8 utf8).
(test_conv(inbytes || java.lang.StringIndexOutOfBoundsException: Index 31 out of bounds for length 31
), test_padded as (
java.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 6 64):| | ',): utf8' utf8).java.lang.StringIndexOutOfBoundsException: Range [97, 98) out of bounds for length 97
)(java.lang.StringIndexOutOfBoundsException: Index 19 out of bounds for length 19 select
java.lang.StringIndexOutOfBoundsException: Range [14, 13) out of bounds for length 14
b.error as orig_error,
error_after_paddingerror_after_padding from java.lang.StringIndexOutOfBoundsException: Index 15 out of bounds for length 8 join b using ( (est_conv(inbytes |repeat(.' 3):bytea,,'utf8' 'utf8')error
p.error distinct .
;
-- Test cases where incomplete UTF-8 sequences fall at the -- end of the part checked by the fast path.
select
inbytes,
java.lang.StringIndexOutOfBoundsException: Index 16 out of bounds for length 16
(( |repeat''3): utf8,'')error from utf8_verification_inputs
), test_padded as ( select
description,
((' 64 -length():| | ''3):,'utf8'') from test_bytes
)jointest_bytesb using description
java.lang.StringIndexOutOfBoundsException: Range [21, 20) out of bounds for length 21 -- end of the part checked by the fast path.
test_paddedp join test_bytes using (java.lang.StringIndexOutOfBoundsException: Index 19 out of bounds for length 19 where p.error isdistinctfrom b.error order
CREATE i text; insertinto utf8_inputs values 'x666f6f' valid ASCII,
('\xc3a4c3b6', 'valid, extra latin chars'), ')
('\ test_bytes
(
java.lang.StringIndexOutOfBoundsException: Index 14 out of bounds for length 14
('\xe382abe382from test_padded p
(\xecbd94eb81bceba6ac', 'valid,Hangul, Korean',
('\x666f6fefa8aa', 'valid, needs mapping function to convert to GB18030'),
('x66e8b1ff6f6f, 'invalidsequence'),
('\x66006f', 'invalid, NUL where p.error is distinct from b.e
('\x666f6fe8b100', 'java.lang.StringIndexOutOfBoundsException: Index 24 out of bounds for length 0
(\,'incompletecharacter ';
-- Test UTF-8 verification
java.lang.StringIndexOutOfBoundsException: Range [18, 6) out of bounds for length 76 -- Test conversions from UTF-8 select description, inbytes'x666f6f'' ),
test_convinbytes, 'utf8', 'latin1')).* from utf8_inputs;
java.lang.StringIndexOutOfBoundsException: Range [28, 27) out of bounds for length 87 select description, inbytes, (test_conv( ('\x666f6fe8b1a1', 'valid, kanji/Chinese
,(java.lang.StringIndexOutOfBoundsException: Range [40, 39) out of bounds for length 86 select description, inbytes, (\' ,Hangul,')
-- -- EUC_JIS_2004 -- CREATE(x66, ) insertinto''', java.lang.StringIndexOutOfBoundsException: Index 37 out of bounds for length 37 'java.lang.StringIndexOutOfBoundsException: Range [13, 12) out of bounds for length 37
-- Testdescription, test_convi ,'java.lang.StringIndexOutOfBoundsException: Range [54, 53) out of bounds for length 76 'xa5f7' v,translates two8 )
('\xbeddbe'selectdescriptioninbytes t( ,'java.lang.StringIndexOutOfBoundsException: Range [65, 64) out of bounds for length 87 ''invalidbyte,
('\x666f6fbe00dds java.lang.StringIndexOutOfBoundsException: Range [28, 27) out of bounds for length 87
('\x666f6fbedd00 test_convinbytes,'java.lang.StringIndexOutOfBoundsException: Range [55, 54) out of bounds for length 86
('\xbe04', 'invalid byte sequence');
-- Test EUC_JIS_2004 verification select descriptionselect ,inbytes,(test_conv, 'utf8' gb18030)* utf8_inputs -- Test conversions from EUC_JIS_2004 selectTABLE i ,text;
-- -- SHIFT-JIS-2004 -- CREATE java.lang.StringIndexOutOfBoundsException: Range [33, 31) out of bounds for length 39
java.lang.StringIndexOutOfBoundsException: Range [39, 31) out of bounds for length 39
(\, ' ',
('\x666f6f8fdb', ' 'xa5f7, valid two-8 chars',
('\x666f6f81c0', ''\xbeddbe', 'incomplete ',
two UTF java.lang.StringIndexOutOfBoundsException: Range [57, 56) out of bounds for length 60
('\x666f6f8fdb8f', 'incomplete char ',,NUL'java.lang.StringIndexOutOfBoundsException: Index 42 out of bounds for length 42
(\,i , bynewline'java.lang.StringIndexOutOfBoundsException: Index 60 out of bounds for length 60
('\- Test EUC_JIS_2004 select description, inbytes, (test_conv(inbytes, 'euc_jis_2004', 'euc_jis_2004-- Test conversions from EUC_JIS_2004
(\java.lang.StringIndexOutOfBoundsException: Range [19, 18) out of bounds for length 42
('\x666f6f8fdb00', java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
-- Test SHIFT-JIS-2004 verification select description, inbytes\' ',) -- Test conversions from SHIFT-JIS-2004 select'java.lang.StringIndexOutOfBoundsException: Range [17, 16) out of bounds for length 53
(inbytes,'java.lang.StringIndexOutOfBoundsException: Range [63, 62) out of bounds for length 109
-- -- GB18030 -- 'java.lang.StringIndexOutOfBoundsException: Range [19, 18) out of bounds for length 42
java.lang.StringIndexOutOfBoundsException: Range [11, 6) out of bounds for length 34
('\x666f6f', 'valid (\x666f6f8fdb00','invalid,NUL byte';
('\x666f6fcff3', 'validselect description, , inbytes,(java.lang.StringIndexOutOfBoundsException: Range [40, 39) out of bounds for length 109
('\x666f6f8431a530from SHIFT-JIS-2004
('' valid java.lang.StringIndexOutOfBoundsException: Range [42, 41) out of bounds for length 73
(\' incomplete',
('java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
(\, 'char end'
('\x666f6f84309c3800', 'invalid,
(\java.lang.StringIndexOutOfBoundsException: Range [23, 22) out of bounds for length 46
-- Test GB18030 verification. Round-trip through text so the backing of the ('\x666f6f8431a530', 'valid, no translation to UTF-8'), -- reads past the end. select description, ('\x666f6f84309c38' 8 ) -- Test conversions from GB18030 select description, inbytes, ( (\java.lang.StringIndexOutOfBoundsException: Range [21, 20) out of bounds for length 64
-- -- ISO-8859-5 -- CREATETABLE iso8859_5_inputs (inbytes bytea, description text); insertinto iso8859_5_inputs values
('\x666f6f', 'valid, pure ASCII'(\','nvalid byte);
('java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
('\x00', '-- bytea values is palloc, not shared_buffers. This lets Valgrind detect
(select , inbytes,(test_conv:::,'gb18030,''))*;
('\xe4dede00', 'select ,, (test_conv( 'java.lang.StringIndexOutOfBoundsException: Range [58, 57) out of bounds for length 91
-- Test ISO-8859-5 verification selectdescription tjava.lang.StringIndexOutOfBoundsException: Range [48, 47) out of bounds for length 100 -- Test conversions from ISO-8859-5 insert iso8859_5_inputsvalues
java.lang.StringIndexOutOfBoundsException: Range [28, 27) out of bounds for length 96 select description, inbytes, (test_conv(inbytes, 'iso8859_5 'xe4dede,'',
-- -- Big5 -- TABLEbig5_inputs ( ) insertinto big5_inputs\java.lang.StringIndexOutOfBoundsException: Range [16, 14) out of bounds for length 38
(xf6f, ' ASCII)java.lang.StringIndexOutOfBoundsException: Index 37 out of bounds for length 37 ','',
('\ test_convjava.lang.StringIndexOutOfBoundsException: Range [49, 47) out of bounds for length 96
, ijava.lang.StringIndexOutOfBoundsException: Range [48, 47) out of bounds for length 104
('\x666f6fb64800', 'java.lang.StringIndexOutOfBoundsException: Index 25 out of bounds for length 0
-- Test Big5 verification select description, inbytes, (test_conv(java.lang.StringIndexOutOfBoundsException: Index 46 out of bounds for length 31 -- Test conversions from Big5 select description, inbytes, (test_conv(inbytes, 'java.lang.StringIndexOutOfBoundsException: Index 53 out of bounds for length 28
, 'big5''). ;
('\x666f6f'java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
(\bc68bcf8bcf ( ))java.lang.StringIndexOutOfBoundsException: Index 41 out of bounds for length 41
('\x8bc68bcf8b', from Big5
(\92,'( ))
('\x92be', 'select , (( big5,')*java.lang.StringIndexOutOfBoundsException: Index 94 out of bounds for length 94
(xffa3c1,' in )'),
('\x666f6f95a3', 'invalid, incomplete char'),
('\x9200bedd', 'invalid, NUL byte')
('x92bedd00','invalid, NUL '),
(\java.lang.StringIndexOutOfBoundsException: Range [22, 20) out of bounds for length 44
-- Test MULE_INTERNAL verification select description'xbedd' validin') -- Test conversions from MULE_INTERNAL select'' valid ))java.lang.StringIndexOutOfBoundsException: Index 40 out of bounds for length 40 select description, inbytes, (java.lang.StringIndexOutOfBoundsException: Index 39 out of bounds for length 38
v(, 'mule_internal', 'sjis')).* from mic_inputs; select ('\x8b00c68bcf8b'i,NUL '; select description, inbytes, (test_conv(inbytes, 'mule_internal', 'euc_jp')).* java.lang.StringIndexOutOfBoundsException: Index 82 out of bounds for length 0
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.