Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/C/Postgres/src/test/regress/sql/   (Postgres Database Version 18.4©)  Datei vom 11.4.2026 mit Größe 13 kB image not shown  

Quelle  conversion.sql   Sprache: SQL

 

--
-- create user defined conversion
--

-- 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;
SELECT FROM test_enc_setup();

CREATE FUNCTION test_enc_conversion(bytea, name, name, bool, validlen OUT int, 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
--
CREATE DEFAULT 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
--
CREATE DEFAULT CONVERSION public.mydef2 FOR  AS:regresslib' t'
-- test comments
 ON myconv_bad IS'';
COMMENT ON CONVERSION myconv IS 'bar';
COMMENTON CONVERSION myconv IS NULL;
--
-- 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;
DROP CREATE 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 create or replacefunction(
    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.
CREATE TABLE 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
    at(.' 3::ytea,','utf8').rror
from test_padded p
join test_bytes b  from test_bytes
using (escription)
where p.error is distinct from b.error
description,

-- Test cases where UTF-8 sequences within short text
-- come after the fast path returns.
with p.error as 
  select
    inbytes,
    join test_bytes
    (est_conv | ''3: ,).error
  from utf8_verification_inputs
)hereperroris fromberror
  orderbydescription
    description,
    (test_conv(repeat('.'-- end of the part checked by the fast 
  from     description,
)
select
  description,
  b.errortest_convinbytes | ('., 3):bytea,'' 'utf8).error
  p.error as java.lang.StringIndexOutOfBoundsException: Index 31 out of bounds for length 31
from    (est_conv(epeat('.,  (nbytes):bytea ||inbytes | repeat(.' 3)bytea utf8', 'utf8).error
join test_bytes b
 (description)
where pdescription,
orderby description;

-- Test cases where incomplete UTF-8 sequences fall at the
-- end of the part checked by the fast path.
with test_bytesfrom test_padded p
  select
    usingdescription)
    description,
    (test_conv(inbytes || repeat('.', 3)::bytea, 'java.lang.StringIndexOutOfBoundsException: Index 52 out of bounds for length 38
  fromutf8_verification_inputs
), test_padded asCREATETABLE utf8_inputs (nbytesbytea,description text)java.lang.StringIndexOutOfBoundsException: Index 59 out of bounds for length 59
  select
    description,(\, 'valid,pure ASCII')java.lang.StringIndexOutOfBoundsException: Index 37 out of bounds for length 37
    (test_conv(repeat('.', 64cyrillic)
from test_bytes
)
elect
  description,
  b.error as orig_error,
  p.error as error_after_padding
 
join test_bytes  '   )java.lang.StringIndexOutOfBoundsException: Index 52 out of bounds for length 52
using\''invalid byte  sequence'
rror
order by description;

CREATE TABLE utf8_inputs (inbytes bytea, description  'x666f6fe8b1' 'incomplete character at end);
insert select description, (test_conv(inbytes, 'utf8', 'utf8')).* from utf8_inputs;
  (\x666f6f,  'alid,pure ASCII'),
  ('\xc3a4c3b6', 'valid, extraselect description,inbytes, (test_conv(java.lang.StringIndexOutOfBoundsException: Range [48, 47) out of bounds for length 87
  selectdescription, inbytes, (test_conv(inbytes, 'utf8', 'latin2')).* from utf8_inputs;
  '),
  ('\xe382abe3829a', 'valid, two charsselectdescription,inbytes (test_conv(inbytes, 'utf8', 'koi8r')).* from utf8_inputs;
  ('\xe382ab',  'only first half of combined char in EUC_JIS_2004'),
  ('\xe382abe382', 'incomplete combination when converted EUC_JIS_2004'),
(\ecbd94eb81bceba6ac','valid  Korean)
  ('\x666f6fefa8aa', 'valid, needs mapping java.lang.StringIndexOutOfBoundsException: Index 50 out of bounds for length 0
  (\66e8b1ff6f6f' 'invalid bytesequence',
  (\x66006f', 'nvalid NULbyte'),
  ('\x666f6fe8b100', 'invalid, NUL byte'),
  ('\x666f6fe8b1', 'incomplete character at  (\x666f6f',  'valid, pure ASCII'),

-- Test UTF-8 verification
select description, ((nbytes,'utf8', 'utf8')).* from utf8_inputs;
-- Test conversions from UTF-8
select   (\xa5f7'  'alid  totwo UTF-8chars',
select , inbytes, (est_convinbytes,'utf8' 'atin1')).* from utf8_inputs;
select description, inbytes, (test_conv(inbytes  (\x666f6f00bedd, 'invalid, NUL byte'),
electdescription,inbytes, (test_conv(inbytes, 'utf8', 'latin5')).* from utf8_inputs;
select description,inbytes,((nbytes utf8', 'koi8r')).* from utf8_inputs;
description inbytes test_conv(inbytes,'').*from;

--
-- EUC_JIS_2004
--
 euc_jis_2004_inputs(nbytes bytea description text)java.lang.StringIndexOutOfBoundsException: Index 67 out of bounds for length 67
insertintoeuc_jis_2004_inputs  values
  ('\x666f6f',  'valid, pureinsert into shiftjis2004_inputs  values
  ('\x666f6fbedd', '  '\x666f6f'  'valid,pure ASCII)
(\xa5f7'  'valid,translates to UTF8 chars 'java.lang.StringIndexOutOfBoundsException: Index 55 out of bounds for length 55
  ( char)
  ('\x666f6f00bedd', 'invalidanslates to two UTF-8chars '),
  (\x666f6fbe00dd','invalid NUL byte',
  ('\x666f6fbedd00', 'invalid, NUL byte'),
  ('\xbe04',  'invalid   'x666f6f820a' 'ncomplete char, followedby newline ',

-- Test EUC_JIS_2004 verification
java.lang.StringIndexOutOfBoundsException: Range [27, 6) out of bounds for length 109
-- Test conversions from EUC_JIS_2004
select description, inbytes, (test_conv(inbytes, 'euc_jis_2004', '  'x666f6f8f00db', 'invalid, NUL byte'),

--
-- SHIFT-JIS-2004
--
CREATE TABLE shiftjis2004_inputs
insert -- Test SHIFT-JIS-2004 verification
  ('x666f6f'  'alid pure ASCII',
  ('\-- Test conversions from SHIFT-JIS-2004
('x666f6f81c0', 'valid, no translation to UTF-8'),
  ('\select description, inbytes,(test_convinbytes,shiftjis2004', 'euc_jis_2004')).* from shiftjis2004_inputs;
  ('\x666f6f8fdb8f--
  ('\x666f6f820a',  
('x666f6f008fdb', 'invalid, NUL byte'),
  ('\insert into gb18030_inputs  values
(   )

-- Test SHIFT-JIS-2004 verification
description test_conv(inbytes, 'shiftjis2004', 'shiftjis2004')).* from shiftjis2004_inputs;
-- Test conversions from SHIFT-JIS-2004
select   \x666f6f84309c38,'valid, translates to UTF-8 by mapping function'),
select description(\x666f6f84309c,'incomplete char ',

--
-- GB18030
--
CREATE TABLE  'x666f6f84'  'ncomplete char atend'),

  ('\x666f6f',  'valid,  'x666f6f84309c0038', 'invalid, NUL byte');
  ('\x666f6fcff3-- Test GB18030 verification.  Round-trip through text so the backing of the
  ('\x666f6f8431a530', 'valid, no translation to UTF-8'),
, 'valid,translates to UTF-8 by mapping function')
  ('\x666f6f84309c'-- Test conversions from GB18030
   'x666f6f84309c0a', 'incomplete char, followed by newline '),
  ('\x666f6f84', java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
  ( java.lang.StringIndexOutOfBoundsException: Range [12, 11) out of bounds for length 36
  'x666f6f84309c0038 i,NUL 'java.lang.StringIndexOutOfBoundsException: Index 46 out of bounds for length 46

-- Test GB18030 verification.  Round-trip through text so the backing of the
-- bytea values is palloc, not shared_buffers.  This lets Valgrind detect
-- reads past the end.
description (inbytestext:bytea,'gb18030' gb18030'))*from gb18030_inputs;
-- Test conversions from GB18030
 description,inbytes, (inbytes, 'gb18030', 'utf8')).* from gb18030_inputs;


--
-- ISO-8859-5
--
CREATE TABLE , inbytes,(est_conv(inbytes, 'iso8859-5', 'iso8859-5')).* from iso8859_5_inputs;
insert into iso8859_5_inputs  
  ('\x666f6fselect description,inbytes, (test_conv(inbytes, 'iso8859-5', 'koi8r')).* from iso8859_5_inputs;
  (\xe4dede'  'alid)java.lang.StringIndexOutOfBoundsException: Index 25 out of bounds for length 25
  ('\x00--
  (CREATE  big5_inputs (nbytes bytea,descriptiontext;
  ('xe4dede00', 'invalid, NUL byte');

-- Test ISO-8859-5 verification
select description, inbytes, (  '\666', 'alid,pure ASCII',
-- Test conversions from ISO-8859-5
select description  (\x666f6fb648' 'alid),
select description, inbytes,(test_conv((inbytes, 'iso8859-5', 'koi8r')).* from iso8859_5_inputs;
lect description inbytes,(test_conv(nbytes, 'iso8859_5', 'mule_internal')).* from iso8859_5_inputs;

--
-- Big5
--
CREATE TABLE big5_inputs (inbytes bytea, description text)java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
insert into big5_inputs  values
  ('\x666f6f',  'valid, pure ASCII'),- Test conversions from Big5
  ('\x666f6fb648', 'valid'),
  ('\x666f6fa27f', 'valid, no translation to select description, inbytes, (test_conv(inbytes' mule_internal')* from big5_inputsjava.lang.StringIndexOutOfBoundsException: Index 94 out of bounds for length 94
(\x666f6fb60048' ', NUL byte',
  ('\x666f6fb64800insert into mic_inputs  values

-- Test Big5 verification
select description, inbytes, (test_conv(inbytes, 'big5  '\8bc68bcf8bcf', 'valid(n KOI8R'),
-- Test conversions from Big5
select description, inbytes  'x92bedd', valid in SHIFT_JIS',
select description,inbytes, (test_conv(inbytes,'big5', 'mule_internal'). from big5_inputs;

--
-- MULE_INTERNAL
--
CREATE TABLE mic_inputs  (\666695a3c1' 'alid ( Big5),
  ('x9200bedd)
  ('  \,invalid byte
  ('\x8bc68bcf8bcf'  'x8b00c68bcf8bcf', 'invalid, NUL byte');
  ('\x8bc68bcf8b', -- Test MULE_INTERNAL verification
  (\92, 'valid ( SHIFT_JIS)')
  ('\x92be'-- Test conversions from MULE_INTERNAL
  (\x666f6f95a3c1','valid(inBig5'),
  ('\x666f6f95a3', 'invalid, incomplete char'),
  ('\x9200bedd', 'invalid, NUL byte'),
  ('\x92bedd00', 'invalid, NUL select description, inbytes, (test_coninbytes
cf' 'nvalid byte)java.lang.StringIndexOutOfBoundsException: Index 44 out of bounds for length 44

-- Test MULE_INTERNAL verification
select description, inbytes, (test_conv(inbytes, 'mule_internal', 'mule_internal')).* from mic_inputs;
-- Test conversions from MULE_INTERNAL
select description, inbytes, (test_conv(inbytes, 'mule_internal', 'koi8r')).* from mic_inputs;
select description, inbytes, (test_conv(inbytes, 'mule_internal', 'iso8859-5')).* from mic_inputs;
select description, inbytes, (test_conv(inbytes, 'mule_internal', 'sjis')).* from mic_inputs;
select description, inbytes, (test_conv(inbytes, 'mule_internal', 'big5')).* from mic_inputs;
select description, inbytes, (test_conv(inbytes, 'mule_internal', 'euc_jp')).* from mic_inputs;

Messung V0.5 in Prozent
C=90 H=89 G=89

¤ Dauer der Verarbeitung: 0.30 Sekunden  (vorverarbeitet am  2026-10-11) ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

PVS Prover

Isabelle Prover

NIST Cobol Testsuite

Cephes Mathematical Library

Vienna Development Method

Haftungshinweis

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.