1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-27 12:41:57 +03:00

Add 'noError' argument to encoding conversion functions.

With the 'noError' argument, you can try to convert a buffer without
knowing the character boundaries beforehand. The functions now need to
return the number of input bytes successfully converted.

This is is a backwards-incompatible change, if you have created a custom
encoding conversion with CREATE CONVERSION. This adds a check to
pg_upgrade for that, refusing the upgrade if there are any user-defined
encoding conversions. Custom conversions are very rare, there are no
commonly used extensions that I know of that uses that feature. No other
objects can depend on conversions, so if you do have one, you can fairly
easily drop it before upgrading, and recreate it after the upgrade with
an updated version.

Add regression tests for built-in encoding conversions. This doesn't cover
every conversion, but it covers all the internal functions in conv.c that
are used to implement the conversions.

Reviewed-by: John Naylor
Discussion: https://www.postgresql.org/message-id/e7861509-3960-538a-9025-b75a61188e01%40iki.fi
This commit is contained in:
Heikki Linnakangas
2021-04-01 11:45:22 +03:00
parent e2639a767b
commit ea1b99a661
40 changed files with 2333 additions and 631 deletions

View File

@ -117,9 +117,15 @@ conv_proc(
integer, -- destination encoding ID
cstring, -- source string (null terminated C string)
internal, -- destination (fill with a null terminated C string)
integer -- source string length
) RETURNS void;
</programlisting></para>
integer, -- source string length
boolean -- if true, don't throw an error if conversion fails
) RETURNS integer;
</programlisting>
The return value is the number of source bytes that were successfully
converted. If the last argument is false, the function must throw an
error on invalid input, and the return value is always equal to the
source string length.
</para>
</listitem>
</varlistentry>
</variablelist>