8000 Declare range inclusion operators as taking anyelement not anynonarray. · postwait/postgres@709aca5 · GitHub
[go: up one dir, main page]

Skip to content

Commit 709aca5

Browse files
committed
Declare range inclusion operators as taking anyelement not anynonarray.
Use of anynonarray was a crude hack to get around ambiguity versus the array inclusion operators of the same names. My previous patch to extend the parser's type resolution heuristics makes that unnecessary, so use the more general declaration instead. This eliminates a wart that these operators couldn't be used with ranges over arrays, which are otherwise supported just fine. Also, mark range_before and range_after as commutator operators, per discussion with Jeff Davis.
1 parent 1a8b9fb commit 709aca5

File tree

6 files changed

+24
-9
lines changed
  • src
    • include/catalog
      • < 8000 div class="PRIVATE_VisuallyHidden prc-TreeView-TreeViewVisuallyHidden-4-mPv" aria-hidden="true" id=":R5mmtddabH1:">
        catversion.h
  • test/regress
  • 6 files changed

    +24
    -9
    lines changed

    src/include/catalog/catversion.h

    Lines changed: 1 addition & 1 deletion
    Original file line numberDiff line numberDiff line change
    @@ -53,6 +53,6 @@
    5353
    */
    5454

    5555
    /* yyyymmddN */
    56-
    #define CATALOG_VERSION_NO 201111161
    56+
    #define CATALOG_VERSION_NO 201111171
    5757

    5858
    #endif

    src/include/catalog/pg_amop.h

    Lines changed: 2 additions & 2 deletions
    Original file line numberDiff line numberDiff line change
    @@ -729,8 +729,8 @@ DATA(insert ( 3903 3831 3831 1 s 3882 405 0 ));
    729729
    DATA(insert ( 3919 3831 3831 1 s 3882 783 0 ));
    730730
    DATA(insert ( 3919 3831 3831 2 s 3883 783 0 ));
    731731
    DATA(insert ( 3919 3831 3831 3 s 3888 783 0 ));
    732-
    DATA(insert ( 3919 3831 2776 4 s 3889 783 0 ));
    733-
    DATA(insert ( 3919 2776 3831 5 s 3891 783 0 ));
    732+
    DATA(insert ( 3919 3831 2283 4 s 3889 783 0 ));
    733+
    DATA(insert ( 3919 2283 3831 5 s 3891 783 0 ));
    734734
    DATA(insert ( 3919 3831 3831 6 s 3890 783 0 ));
    735735
    DATA(insert ( 3919 3831 3831 7 s 3892 783 0 ));
    736736
    DATA(insert ( 3919 3831 3831 8 s 3893 783 0 ));

    src/include/catalog/pg_operator.h

    Lines changed: 4 additions & 4 deletions
    Original file line numberDiff line numberDiff line change
    @@ -1676,17 +1676,17 @@ DATA(insert OID = 3887 ( ">" PGNSP PGUID b f f 3831 3831 16 3884 3885 range_
    16761676
    DESCR("greater than");
    16771677
    DATA(insert OID = 3888 ( "&&" PGNSP PGUID b f f 3831 3831 16 3888 0 range_overlaps - - ));
    16781678
    DESCR("overlaps");
    1679-
    DATA(insert OID = 3889 ( "@>" PGNSP PGUID b f f 3831 2776 16 3891 0 range_contains_elem - - ));
    1679+
    DATA(insert OID = 3889 ( "@>" PGNSP PGUID b f f 3831 2283 16 3891 0 range_contains_elem - - ));
    16801680
    DESCR("contains");
    16811681
    DATA(insert OID = 3890 ( "@>" PGNSP PGUID b f f 3831 3831 16 3892 0 range_contains - - ));
    16821682
    DESCR("contains");
    1683-
    DATA(insert OID = 3891 ( "<@" PGNSP PGUID b f f 2776 3831 16 3889 0 elem_contained_by_range - - ));
    1683+
    DATA(insert OID = 3891 ( "<@" PGNSP PGUID b f f 2283 3831 16 3889 0 elem_contained_by_range - - ));
    16841684
    DESCR("is contained by");
    16851685
    DATA(insert OID = 3892 ( "<@" PGNSP PGUID b f f 3831 3831 16 3890 0 range_contained_by - - ));
    16861686
    DESCR("is contained by");
    1687-
    DATA(insert OID = 3893 ( "<<" PGNSP PGUID b f f 3831 3831 16 0 0 range_before scalarltsel scalarltjoinsel ));
    1687+
    DATA(insert OID = 3893 ( "<<" PGNSP PGUID b f f 3831 3831 16 3894 0 range_before scalarltsel scalarltjoinsel ));
    16881688
    DESCR("is left of");
    1689-
    DATA(insert OID = 3894 ( ">>" PGNSP PGUID b f f 3831 3831 16 0 0 range_after scalargtsel scalargtjoinsel ));
    1689+
    DATA(insert OID = 3894 ( ">>" PGNSP PGUID b f f 3831 3831 16 3893 0 range_after scalargtsel scalargtjoinsel ));
    16901690
    DESCR("is right of");
    16911691
    DATA(insert OID = 3895 ( "&<" PGNSP PGUID b f f 3831 3831 16 0 0 range_overleft scalarltsel scalarltjoinsel ));
    16921692
    DESCR("overlaps or is left of");

    src/include/catalog/pg_proc.h

    Lines changed: 2 additions & 2 deletions
    Original file line numberDiff line numberDiff line change
    @@ -4367,11 +4367,11 @@ DATA(insert OID = 3856 ( range_ne PGNSP PGUID 12 1 0 0 0 f f f t f i 2 0 16 "38
    43674367
    DESCR("implementation of <> operator");
    43684368
    DATA(insert OID = 3857 ( range_overlaps PGNSP PGUID 12 1 0 0 0 f f f t f i 2 0 16 "3831 3831" _null_ _null_ _null_ _null_ range_overlaps _null_ _null_ _null_ ));
    43694369
    DESCR("implementation of && operator");
    4370-
    DATA(insert OID = 3858 ( range_contains_elem PGNSP PGUID 12 1 0 0 0 f f f t f i 2 0 16 "3831 2776" _null_ _null_ _null_ _null_ range_contains_elem _null_ _null_ _null_ ));
    4370+
    DATA(insert OID = 3858 ( range_contains_elem PGNSP PGUID 12 1 0 0 0 f f f t f i 2 0 16 "3831 2283" _null_ _null_ _null_ _null_ range_contains_elem _null_ _null_ _null_ ));
    43714371
    DESCR("implementation of @> operator");
    43724372
    DATA(insert OID = 3859 ( range_contains PGNSP PGUID 12 1 0 0 0 f f f t f i 2 0 16 "3831 3831" _null_ _null_ _null_ _null_ range_contains _null_ _null_ _null_ ));
    43734373
    DESCR("implementation of @> operator");
    4374-
    DATA(insert OID = 3860 ( elem_contained_by_range PGNSP PGUID 12 1 0 0 0 f f f t f i 2 0 16 "2776 3831" _null_ _null_ _null_ _null_ elem_contained_by_range _null_ _null_ _null_ ));
    4374+
    DATA(insert OID = 3860 ( elem_contained_by_range PGNSP PGUID 12 1 0 0 0 f f f t f i 2 0 16 "2283 3831" _null_ _null_ _null_ _null_ elem_contained_by_range _null_ _null_ _null_ ));
    43754375
    DESCR("implementation of <@ operator");
    43764376
    DATA(insert OID = 3861 ( range_contained_by PGNSP PGUID 12 1 0 0 0 f f f t f i 2 0 16 "3831 3831" _null_ _null_ _null_ _null_ range_contained_by _null_ _null_ _null_ ));
    43774377
    DESCR("implementation of <@ operator");

    src/test/regress/expected/rangetypes.out

    Lines changed: 12 additions & 0 deletions
    Original file line numberDiff line numberDiff line change
    @@ -964,6 +964,18 @@ select arrayrange(ARRAY[1,2], ARRAY[2,1]);
    964964
    ["{1,2}","{2,1}")
    965965
    (1 row)
    966966

    967+
    select array[1,1] <@ arrayrange(array[1,2], array[2,1]);
    968+
    ?column?
    969+
    ----------
    970+
    f
    971+
    (1 row)
    972+
    973+
    select array[1,3] <@ arrayrange(array[1,2], array[2,1]);
    974+
    ?column?
    975+
    ----------
    976+
    t
    977+
    (1 row)
    978+
    967979
    --
    968980
    -- OUT/INOUT/TABLE functions
    969981
    --

    src/test/regress/sql/rangetypes.sql

    Lines changed: 3 additions & 0 deletions
    Original file line numberDiff line numberDiff line change
    @@ -346,6 +346,9 @@ create type arrayrange as range (subtype=int4[]);
    346346

    347347
    select arrayrange(ARRAY[1,2], ARRAY[2,1]);
    348348

    349+
    select array[1,1] <@ arrayrange(array[1,2], array[2,1]);
    350+
    select array[1,3] <@ arrayrange(array[1,2], array[2,1]);
    351+
    349352
    --
    350353
    -- OUT/INOUT/TABLE functions
    351354
    --

    0 commit comments

    Comments
     (0)
    0