Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: postgresql-cfbot/postgresql
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: cf/5941~1
Choose a base ref
...
head repository: postgresql-cfbot/postgresql
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: cf/5941
Choose a head ref
  • 19 commits
  • 50 files changed
  • 2 contributors

Commits on Aug 11, 2025

  1. error safe for casting bytea to other types per pg_cast

    select castsource::regtype, casttarget::regtype, castfunc, castcontext,castmethod, pp.prosrc, pp.proname
    from pg_cast pc join pg_proc pp on pp.oid = pc.castfunc and pc.castfunc > 0 and castsource::regtype ='bytea'::regtype
    order by castsource::regtype;
    
     castsource | casttarget | castfunc | castcontext | castmethod |   prosrc   | proname
    ------------+------------+----------+-------------+------------+------------+---------
     bytea      | smallint   |     6370 | e           | f          | bytea_int2 | int2
     bytea      | integer    |     6371 | e           | f          | bytea_int4 | int4
     bytea      | bigint     |     6372 | e           | f          | bytea_int8 | int8
    (3 rows)
    jianhe-fun authored and Commitfest Bot committed Aug 11, 2025
    Configuration menu
    Copy the full SHA
    180d4d2 View commit details
    Browse the repository at this point in the history
  2. error safe for casting character to other types per pg_cast

    select castsource::regtype, casttarget::regtype, castfunc,
    castcontext,castmethod, pp.prosrc, pp.proname from pg_cast pc join pg_proc pp on
    pp.oid = pc.castfunc and pc.castfunc > 0
    and castsource::regtype ='character'::regtype
    order by castsource::regtype;
    
     castsource |    casttarget     | castfunc | castcontext | castmethod |   prosrc    | proname
    ------------+-------------------+----------+-------------+------------+-------------+---------
     character  | text              |      401 | i           | f          | rtrim1      | text
     character  | character varying |      401 | i           | f          | rtrim1      | text
     character  | "char"            |      944 | a           | f          | text_char   | char
     character  | name              |      409 | i           | f          | bpchar_name | name
     character  | xml               |     2896 | e           | f          | texttoxml   | xml
     character  | character         |      668 | i           | f          | bpchar      | bpchar
    (6 rows)
    
    only texttoxml, bpchar(PG_FUNCTION_ARGS) need take care of error handling.
    other already error safe.
    jianhe-fun authored and Commitfest Bot committed Aug 11, 2025
    Configuration menu
    Copy the full SHA
    5967274 View commit details
    Browse the repository at this point in the history
  3. error safe for casting integer to other types per pg_cast

    select castsource::regtype, casttarget::regtype, castfunc,
    castcontext,castmethod, pp.prosrc, pp.proname from pg_cast pc join pg_proc pp on
    pp.oid = pc.castfunc and pc.castfunc > 0
    and castsource::regtype = 'integer'::regtype
    order by castsource::regtype;
    
     castsource |    casttarget    | castfunc | castcontext | castmethod |    prosrc    | proname
    ------------+------------------+----------+-------------+------------+--------------+---------
     integer    | bigint           |      481 | i           | f          | int48        | int8
     integer    | smallint         |      314 | a           | f          | i4toi2       | int2
     integer    | real             |      318 | i           | f          | i4tof        | float4
     integer    | double precision |      316 | i           | f          | i4tod        | float8
     integer    | numeric          |     1740 | i           | f          | int4_numeric | numeric
     integer    | money            |     3811 | a           | f          | int4_cash    | money
     integer    | boolean          |     2557 | e           | f          | int4_bool    | bool
     integer    | bytea            |     6368 | e           | f          | int4_bytea   | bytea
     integer    | "char"           |       78 | e           | f          | i4tochar     | char
     integer    | bit              |     1683 | e           | f          | bitfromint4  | bit
    (10 rows)
    
    only int4_cash, i4toi2, i4tochar need take care of error handling.  but support
    for cash data type is not easy, so only i4toi2, i4tochar function refactoring.
    jianhe-fun authored and Commitfest Bot committed Aug 11, 2025
    Configuration menu
    Copy the full SHA
    4c9b45f View commit details
    Browse the repository at this point in the history
  4. error safe for casting bigint to other types per pg_cast

    select castsource::regtype, casttarget::regtype, castfunc,
    castcontext,castmethod, pp.prosrc, pp.proname from pg_cast pc join pg_proc pp on
    pp.oid = pc.castfunc and pc.castfunc > 0
    and castsource::regtype = 'bigint'::regtype
    order by castsource::regtype;
    
     castsource |    casttarget    | castfunc | castcontext | castmethod |    prosrc    | proname
    ------------+------------------+----------+-------------+------------+--------------+---------
     bigint     | smallint         |      714 | a           | f          | int82        | int2
     bigint     | integer          |      480 | a           | f          | int84        | int4
     bigint     | real             |      652 | i           | f          | i8tof        | float4
     bigint     | double precision |      482 | i           | f          | i8tod        | float8
     bigint     | numeric          |     1781 | i           | f          | int8_numeric | numeric
     bigint     | money            |     3812 | a           | f          | int8_cash    | money
     bigint     | oid              |     1287 | i           | f          | i8tooid      | oid
     bigint     | regproc          |     1287 | i           | f          | i8tooid      | oid
     bigint     | regprocedure     |     1287 | i           | f          | i8tooid      | oid
     bigint     | regoper          |     1287 | i           | f          | i8tooid      | oid
     bigint     | regoperator      |     1287 | i           | f          | i8tooid      | oid
     bigint     | regclass         |     1287 | i           | f          | i8tooid      | oid
     bigint     | regcollation     |     1287 | i           | f          | i8tooid      | oid
     bigint     | regtype          |     1287 | i           | f          | i8tooid      | oid
     bigint     | regconfig        |     1287 | i           | f          | i8tooid      | oid
     bigint     | regdictionary    |     1287 | i           | f          | i8tooid      | oid
     bigint     | regrole          |     1287 | i           | f          | i8tooid      | oid
     bigint     | regnamespace     |     1287 | i           | f          | i8tooid      | oid
     bigint     | regdatabase      |     1287 | i           | f          | i8tooid      | oid
     bigint     | bytea            |     6369 | e           | f          | int8_bytea   | bytea
     bigint     | bit              |     2075 | e           | f          | bitfromint8  | bit
    (21 rows)
    
    already error safe: i8tof, i8tod, int8_numeric, int8_bytea, bitfromint8
    jianhe-fun authored and Commitfest Bot committed Aug 11, 2025
    Configuration menu
    Copy the full SHA
    1941353 View commit details
    Browse the repository at this point in the history
  5. error safe for casting numeric to other types per pg_cast

    select castsource::regtype, casttarget::regtype, castfunc,
    castcontext,castmethod, pp.prosrc, pp.proname from pg_cast pc join pg_proc pp on
    pp.oid = pc.castfunc and pc.castfunc > 0
    and castsource::regtype = 'numeric'::regtype
    order by castsource::regtype;
    
    castsource |    casttarget    | castfunc | castcontext | castmethod |     prosrc     | proname
    ------------+------------------+----------+-------------+------------+----------------+---------
     numeric    | bigint           |     1779 | a           | f          | numeric_int8   | int8
     numeric    | smallint         |     1783 | a           | f          | numeric_int2   | int2
     numeric    | integer          |     1744 | a           | f          | numeric_int4   | int4
     numeric    | real             |     1745 | i           | f          | numeric_float4 | float4
     numeric    | double precision |     1746 | i           | f          | numeric_float8 | float8
     numeric    | money            |     3824 | a           | f          | numeric_cash   | money
     numeric    | numeric          |     1703 | i           | f          | numeric        | numeric
    (7 rows)
    
    current safe cast for money data type is not supported, so no realted function
    refactoring.
    jianhe-fun authored and Commitfest Bot committed Aug 11, 2025
    Configuration menu
    Copy the full SHA
    ee20142 View commit details
    Browse the repository at this point in the history
  6. error safe for casting float4 to other types per pg_cast

    select castsource::regtype, casttarget::regtype, castfunc,
    castcontext,castmethod, pp.prosrc, pp.proname from pg_cast pc join pg_proc pp on
    pp.oid = pc.castfunc and pc.castfunc > 0
    and castsource::regtype = 'float4'::regtype
    order by castsource::regtype;
    
     castsource |    casttarget    | castfunc | castcontext | castmethod |     prosrc     | proname
    ------------+------------------+----------+-------------+------------+----------------+---------
     real       | bigint           |      653 | a           | f          | ftoi8          | int8
     real       | smallint         |      238 | a           | f          | ftoi2          | int2
     real       | integer          |      319 | a           | f          | ftoi4          | int4
     real       | double precision |      311 | i           | f          | ftod           | float8
     real       | numeric          |     1742 | a           | f          | float4_numeric | numeric
    (5 rows)
    
    float4 to float8, numeric is error safe, so no need refactor ftod,
    float4_numeric.
    jianhe-fun authored and Commitfest Bot committed Aug 11, 2025
    Configuration menu
    Copy the full SHA
    fad69c2 View commit details
    Browse the repository at this point in the history
  7. error safe for casting float8 to other types per pg_cast

    select castsource::regtype, casttarget::regtype, castfunc,
    castcontext,castmethod, pp.prosrc, pp.proname from pg_cast pc join pg_proc pp on
    pp.oid = pc.castfunc and pc.castfunc > 0
    and castsource::regtype = 'float8'::regtype
    order by castsource::regtype;
    
        castsource    | casttarget | castfunc | castcontext | castmethod |     prosrc     | proname
    ------------------+------------+----------+-------------+------------+----------------+---------
     double precision | bigint     |      483 | a           | f          | dtoi8          | int8
     double precision | smallint   |      237 | a           | f          | dtoi2          | int2
     double precision | integer    |      317 | a           | f          | dtoi4          | int4
     double precision | real       |      312 | a           | f          | dtof           | float4
     double precision | numeric    |     1743 | a           | f          | float8_numeric | numeric
    (5 rows)
    jianhe-fun authored and Commitfest Bot committed Aug 11, 2025
    Configuration menu
    Copy the full SHA
    9851681 View commit details
    Browse the repository at this point in the history
  8. error safe for casting jsonb to other types per pg_cast

    select castsource::regtype, casttarget::regtype, castfunc,
    castcontext,castmethod, pp.prosrc, pp.proname from pg_cast pc join pg_proc pp on
    pp.oid = pc.castfunc and pc.castfunc > 0
    and castsource::regtype = 'jsonb'::regtype
    order by castsource::regtype;
    
     castsource |    casttarget    | castfunc | castcontext | castmethod |    prosrc     | proname
    ------------+------------------+----------+-------------+------------+---------------+---------
     jsonb      | boolean          |     3556 | e           | f          | jsonb_bool    | bool
     jsonb      | numeric          |     3449 | e           | f          | jsonb_numeric | numeric
     jsonb      | smallint         |     3450 | e           | f          | jsonb_int2    | int2
     jsonb      | integer          |     3451 | e           | f          | jsonb_int4    | int4
     jsonb      | bigint           |     3452 | e           | f          | jsonb_int8    | int8
     jsonb      | real             |     3453 | e           | f          | jsonb_float4  | float4
     jsonb      | double precision |     2580 | e           | f          | jsonb_float8  | float8
    (7 rows)
    jianhe-fun authored and Commitfest Bot committed Aug 11, 2025
    Configuration menu
    Copy the full SHA
    7b816b7 View commit details
    Browse the repository at this point in the history
  9. error safe for casting date to other types per pg_cast

    select castsource::regtype, casttarget::regtype, castfunc,
    castcontext,castmethod, pp.prosrc, pp.proname from pg_cast pc join pg_proc pp on
    pp.oid = pc.castfunc and pc.castfunc > 0
    and castsource::regtype = 'date'::regtype
    order by castsource::regtype;
    
    castsource |         casttarget          | castfunc | castcontext | castmethod |      prosrc      |   proname
    ------------+-----------------------------+----------+-------------+------------+------------------+-------------
     date       | timestamp without time zone |     2024 | i           | f          | date_timestamp   | timestamp
     date       | timestamp with time zone    |     1174 | i           | f          | date_timestamptz | timestamptz
    (2 rows)
    jianhe-fun authored and Commitfest Bot committed Aug 11, 2025
    Configuration menu
    Copy the full SHA
    01607a5 View commit details
    Browse the repository at this point in the history
  10. error safe for casting text to other types per pg_cast

    select castsource::regtype, casttarget::regtype, castfunc,
    castcontext,castmethod, pp.prosrc, pp.proname from pg_cast pc join pg_proc pp on
    pp.oid = pc.castfunc and pc.castfunc > 0
    and castsource::regtype = 'text'::regtype
    order by castsource::regtype;
    
     castsource | casttarget | castfunc | castcontext | castmethod |    prosrc     | proname
    ------------+------------+----------+-------------+------------+---------------+----------
     text       | regclass   |     1079 | i           | f          | text_regclass | regclass
     text       | "char"     |      944 | a           | f          | text_char     | char
     text       | name       |      407 | i           | f          | text_name     | name
     text       | xml        |     2896 | e           | f          | texttoxml     | xml
    (4 rows)
    
    already error safe: text_name, text_char.
    texttoxml is refactored in character type error safe patch.
    jianhe-fun authored and Commitfest Bot committed Aug 11, 2025
    Configuration menu
    Copy the full SHA
    d9dd0a6 View commit details
    Browse the repository at this point in the history
  11. error safe for casting inet to other types per pg_cast

    select castsource::regtype, casttarget::regtype, castfunc,
    castcontext,castmethod, pp.prosrc, pp.proname from pg_cast pc join pg_proc pp on
    pp.oid = pc.castfunc and pc.castfunc > 0
    and castsource::regtype = 'inet'::regtype
    order by castsource::regtype;
    
     castsource |    casttarget     | castfunc | castcontext | castmethod |    prosrc    | proname
    ------------+-------------------+----------+-------------+------------+--------------+---------
     inet       | cidr              |     1715 | a           | f          | inet_to_cidr | cidr
     inet       | text              |      730 | a           | f          | network_show | text
     inet       | character varying |      730 | a           | f          | network_show | text
     inet       | character         |      730 | a           | f          | network_show | text
    (4 rows)
    jianhe-fun authored and Commitfest Bot committed Aug 11, 2025
    Configuration menu
    Copy the full SHA
    94af6b7 View commit details
    Browse the repository at this point in the history
  12. error safe for casting interval to other types per pg_cast

    select castsource::regtype, casttarget::regtype, castfunc,
    castcontext,castmethod, pp.prosrc, pp.proname from pg_cast pc join pg_proc pp on
    pp.oid = pc.castfunc and pc.castfunc > 0
    and castsource::regtype = 'interval'::regtype
    order by castsource::regtype;
    
     castsource |       casttarget       | castfunc | castcontext | castmethod |     prosrc     | proname
    ------------+------------------------+----------+-------------+------------+----------------+----------
     interval   | time without time zone |     1419 | a           | f          | interval_time  | time
     interval   | interval               |     1200 | i           | f          | interval_scale | interval
    (2 rows)
    jianhe-fun authored and Commitfest Bot committed Aug 11, 2025
    Configuration menu
    Copy the full SHA
    6f4e83c View commit details
    Browse the repository at this point in the history
  13. error safe for casting macaddr8 to other types per pg_cast

    select castsource::regtype, casttarget::regtype, castfunc, castcontext,castmethod, pp.prosrc, pp.proname
    from pg_cast pc join pg_proc pp on pp.oid = pc.castfunc
    and pc.castfunc > 0 and castsource::regtype ='macaddr8'::regtype
    order by castsource::regtype;
    
     castsource | casttarget | castfunc | castcontext | castmethod |      prosrc       | proname
    ------------+------------+----------+-------------+------------+-------------------+---------
     macaddr8   | macaddr    |     4124 | i           | f          | macaddr8tomacaddr | macaddr
    (1 row)
    jianhe-fun authored and Commitfest Bot committed Aug 11, 2025
    Configuration menu
    Copy the full SHA
    ecf2463 View commit details
    Browse the repository at this point in the history
  14. error safe for casting timestamptz to other types per pg_cast

    select castsource::regtype, casttarget::regtype, castfunc, castcontext,castmethod, pp.prosrc, pp.proname
    from pg_cast pc join pg_proc pp on pp.oid = pc.castfunc
    and pc.castfunc > 0 and (castsource::regtype ='timestamptz'::regtype)
    order by castsource::regtype;
    
            castsource        |         casttarget          | castfunc | castcontext | castmethod |        prosrc         |   proname
    --------------------------+-----------------------------+----------+-------------+------------+-----------------------+-------------
     timestamp with time zone | date                        |     1178 | a           | f          | timestamptz_date      | date
     timestamp with time zone | time without time zone      |     2019 | a           | f          | timestamptz_time      | time
     timestamp with time zone | timestamp without time zone |     2027 | a           | f          | timestamptz_timestamp | timestamp
     timestamp with time zone | time with time zone         |     1388 | a           | f          | timestamptz_timetz    | timetz
     timestamp with time zone | timestamp with time zone    |     1967 | i           | f          | timestamptz_scale     | timestamptz
    (5 rows)
    jianhe-fun authored and Commitfest Bot committed Aug 11, 2025
    Configuration menu
    Copy the full SHA
    a998255 View commit details
    Browse the repository at this point in the history
  15. error safe for casting timestamp to other types per pg_cast

    select castsource::regtype, casttarget::regtype, castfunc, castcontext,castmethod, pp.prosrc, pp.proname
    from pg_cast pc join pg_proc pp on pp.oid = pc.castfunc
    and pc.castfunc > 0 and (castsource::regtype ='timestamp'::regtype)
    order by castsource::regtype;
    
             castsource          |         casttarget          | castfunc | castcontext | castmethod |        prosrc         |   proname
    -----------------------------+-----------------------------+----------+-------------+------------+-----------------------+-------------
     timestamp without time zone | date                        |     2029 | a           | f          | timestamp_date        | date
     timestamp without time zone | time without time zone      |     1316 | a           | f          | timestamp_time        | time
     timestamp without time zone | timestamp with time zone    |     2028 | i           | f          | timestamp_timestamptz | timestamptz
     timestamp without time zone | timestamp without time zone |     1961 | i           | f          | timestamp_scale       | timestamp
    (4 rows)
    jianhe-fun authored and Commitfest Bot committed Aug 11, 2025
    Configuration menu
    Copy the full SHA
    8f5e6af View commit details
    Browse the repository at this point in the history
  16. error safe for casting character varying to other types per pg_cast

    select castsource::regtype, casttarget::regtype, castfunc, castcontext,castmethod, pp.prosrc, pp.proname
    from pg_cast pc join pg_proc pp on pp.oid = pc.castfunc and pc.castfunc > 0 and
    (castsource::regtype = 'character varying'::regtype)
    order by castsource::regtype;
    
        castsource     |    casttarget     | castfunc | castcontext | castmethod |    prosrc     | proname
    -------------------+-------------------+----------+-------------+------------+---------------+----------
     character varying | regclass          |     1079 | i           | f          | text_regclass | regclass
     character varying | "char"            |      944 | a           | f          | text_char     | char
     character varying | name              |     1400 | i           | f          | text_name     | name
     character varying | xml               |     2896 | e           | f          | texttoxml     | xml
     character varying | character varying |      669 | i           | f          | varchar       | varchar
    (5 rows)
    
    texttoxml, text_regclass was refactored as error safe in prior patch.
    text_char, text_name is already error safe.
    jianhe-fun authored and Commitfest Bot committed Aug 11, 2025
    Configuration menu
    Copy the full SHA
    9e573bc View commit details
    Browse the repository at this point in the history
  17. Configuration menu
    Copy the full SHA
    3ce352f View commit details
    Browse the repository at this point in the history
  18. CAST(expr AS newtype DEFAULT ON ERROR)

    Now that the type coercion node is error-safe, we also need to ensure that when
    a coercion fails, it falls back to evaluating the default node.
    draft doc also added.
    
    We cannot simply prohibit user-defined functions in pg_cast for safe cast
    evaluation because CREATE CAST can also utilize built-in functions. So, to
    completely disallow custom casts created via CREATE CAST used in safe cast
    evaluation, a new field in pg_cast would unfortunately be necessary.
    
    [0]: https://git.postgresql.org/cgit/postgresql.git/commit/?id=aaaf9449ec6be62cb0d30ed3588dc384f56274bf
    discussion: https://postgr.es/m/CADkLM=fv1JfY4Ufa-jcwwNbjQixNViskQ8jZu3Tz_p656i_4hQ@mail.gmail.com
    
    demo:
    SELECT CAST('1' AS date  DEFAULT '2011-01-01' ON ERROR),
           CAST('{234,def,567}'::text[] AS integer[] DEFAULT '{-1011}' ON ERROR);
        date    |  int4
    ------------+---------
     2011-01-01 | {-1011}
    jianhe-fun authored and Commitfest Bot committed Aug 11, 2025
    Configuration menu
    Copy the full SHA
    da1a6de View commit details
    Browse the repository at this point in the history
  19. [CF 5941] v6 - CAST(... ON DEFAULT) - WIP build on top of Error-Safe …

    …User Functions
    
    This branch was automatically generated by a robot using patches from an
    email thread registered at:
    
    https://commitfest.postgresql.org/patch/5941
    
    The branch will be overwritten each time a new patch version is posted to
    the thread, and also periodically to check for bitrot caused by changes
    on the master branch.
    
    Patch(es): https://www.postgresql.org/message-id/CACJufxE053=bO3pDUpGba6Yz3VGpU_XCbg4HO6Rew5EJ7k7VnQ@mail.gmail.com
    Author(s): Jian He
    Commitfest Bot committed Aug 11, 2025
    Configuration menu
    Copy the full SHA
    7a255b3 View commit details
    Browse the repository at this point in the history
Loading