~ubuntu-branches/ubuntu/trusty/postgresql-9.3/trusty-proposed

« back to all changes in this revision

Viewing changes to src/backend/utils/adt/int8.c

  • Committer: Package Import Robot
  • Author(s): Martin Pitt
  • Date: 2014-07-24 16:13:59 UTC
  • mfrom: (1.1.8)
  • Revision ID: package-import@ubuntu.com-20140724161359-uk325qfv03euxuuh
Tags: 9.3.5-0ubuntu0.14.04.1
* New upstream bug fix release: (LP: #1348176)
  - pg_upgrade: Users who upgraded to version 9.3 using pg_upgrade may have
    an issue with transaction information which causes VACUUM to eventually
    fail. These users should run the script provided in the release notes to
    determine if their installation is affected, and then take the remedy
    steps outlined there.
  - Various data integrity and other bug fixes.
  - Secure Unix-domain sockets of temporary postmasters started during make
    check.
    Any local user able to access the socket file could connect as the
    server's bootstrap superuser, then proceed to execute arbitrary code as
    the operating-system user running the test, as we previously noted in
    CVE-2014-0067. This change defends against that risk by placing the
    server's socket in a temporary, mode 0700 subdirectory of /tmp.
  - See release notes for details:
    http://www.postgresql.org/about/news/1534/
* Remove pg_regress patches to support --host=/path, obsolete with above
  upstream changes and not applicable any more.
* Drop tcl8.6 patch, applied upstream.
* Add missing logrotate test dependency.

Show diffs side-by-side

added added

removed removed

Lines of Context:
73
73
                ptr++;
74
74
 
75
75
                /*
76
 
                 * Do an explicit check for INT64_MIN.  Ugly though this is, it's
 
76
                 * Do an explicit check for INT64_MIN.  Ugly though this is, it's
77
77
                 * cleaner than trying to get the loop below to handle it portably.
78
78
                 */
79
79
                if (strncmp(ptr, "9223372036854775808", 19) == 0)
519
519
        result = arg1 + arg2;
520
520
 
521
521
        /*
522
 
         * Overflow check.      If the inputs are of different signs then their sum
 
522
         * Overflow check.  If the inputs are of different signs then their sum
523
523
         * cannot overflow.  If the inputs are of the same sign, their sum had
524
524
         * better be that sign too.
525
525
         */
540
540
        result = arg1 - arg2;
541
541
 
542
542
        /*
543
 
         * Overflow check.      If the inputs are of the same sign then their
544
 
         * difference cannot overflow.  If they are of different signs then the
 
543
         * Overflow check.  If the inputs are of the same sign then their
 
544
         * difference cannot overflow.  If they are of different signs then the
545
545
         * result should be of the same sign as the first input.
546
546
         */
547
547
        if (!SAMESIGN(arg1, arg2) && !SAMESIGN(result, arg1))
561
561
        result = arg1 * arg2;
562
562
 
563
563
        /*
564
 
         * Overflow check.      We basically check to see if result / arg2 gives arg1
 
564
         * Overflow check.  We basically check to see if result / arg2 gives arg1
565
565
         * again.  There are two cases where this fails: arg2 = 0 (which cannot
566
566
         * overflow) and arg1 = INT64_MIN, arg2 = -1 (where the division itself
567
567
         * will overflow and thus incorrectly match).
719
719
 
720
720
/*
721
721
 * These functions are exactly like int8inc but are used for aggregates that
722
 
 * count only non-null values.  Since the functions are declared strict,
 
722
 * count only non-null values.  Since the functions are declared strict,
723
723
 * the null checks happen before we ever get here, and all we need do is
724
724
 * increment the state value.  We could actually make these pg_proc entries
725
725
 * point right at int8inc, but then the opr_sanity regression test would
773
773
        result = arg1 + arg2;
774
774
 
775
775
        /*
776
 
         * Overflow check.      If the inputs are of different signs then their sum
 
776
         * Overflow check.  If the inputs are of different signs then their sum
777
777
         * cannot overflow.  If the inputs are of the same sign, their sum had
778
778
         * better be that sign too.
779
779
         */
794
794
        result = arg1 - arg2;
795
795
 
796
796
        /*
797
 
         * Overflow check.      If the inputs are of the same sign then their
798
 
         * difference cannot overflow.  If they are of different signs then the
 
797
         * Overflow check.  If the inputs are of the same sign then their
 
798
         * difference cannot overflow.  If they are of different signs then the
799
799
         * result should be of the same sign as the first input.
800
800
         */
801
801
        if (!SAMESIGN(arg1, arg2) && !SAMESIGN(result, arg1))
815
815
        result = arg1 * arg2;
816
816
 
817
817
        /*
818
 
         * Overflow check.      We basically check to see if result / arg1 gives arg2
 
818
         * Overflow check.  We basically check to see if result / arg1 gives arg2
819
819
         * again.  There is one case where this fails: arg1 = 0 (which cannot
820
820
         * overflow).
821
821
         *
882
882
        result = arg1 + arg2;
883
883
 
884
884
        /*
885
 
         * Overflow check.      If the inputs are of different signs then their sum
 
885
         * Overflow check.  If the inputs are of different signs then their sum
886
886
         * cannot overflow.  If the inputs are of the same sign, their sum had
887
887
         * better be that sign too.
888
888
         */
903
903
        result = arg1 - arg2;
904
904
 
905
905
        /*
906
 
         * Overflow check.      If the inputs are of the same sign then their
907
 
         * difference cannot overflow.  If they are of different signs then the
 
906
         * Overflow check.  If the inputs are of the same sign then their
 
907
         * difference cannot overflow.  If they are of different signs then the
908
908
         * result should be of the same sign as the first input.
909
909
         */
910
910
        if (!SAMESIGN(arg1, arg2) && !SAMESIGN(result, arg1))
924
924
        result = arg1 * arg2;
925
925
 
926
926
        /*
927
 
         * Overflow check.      We basically check to see if result / arg2 gives arg1
 
927
         * Overflow check.  We basically check to see if result / arg2 gives arg1
928
928
         * again.  There is one case where this fails: arg2 = 0 (which cannot
929
929
         * overflow).
930
930
         *
970
970
        result = arg1 + arg2;
971
971
 
972
972
        /*
973
 
         * Overflow check.      If the inputs are of different signs then their sum
 
973
         * Overflow check.  If the inputs are of different signs then their sum
974
974
         * cannot overflow.  If the inputs are of the same sign, their sum had
975
975
         * better be that sign too.
976
976
         */
991
991
        result = arg1 - arg2;
992
992
 
993
993
        /*
994
 
         * Overflow check.      If the inputs are of the same sign then their
995
 
         * difference cannot overflow.  If they are of different signs then the
 
994
         * Overflow check.  If the inputs are of the same sign then their
 
995
         * difference cannot overflow.  If they are of different signs then the
996
996
         * result should be of the same sign as the first input.
997
997
         */
998
998
        if (!SAMESIGN(arg1, arg2) && !SAMESIGN(result, arg1))
1012
1012
        result = arg1 * arg2;
1013
1013
 
1014
1014
        /*
1015
 
         * Overflow check.      We basically check to see if result / arg1 gives arg2
 
1015
         * Overflow check.  We basically check to see if result / arg1 gives arg2
1016
1016
         * again.  There is one case where this fails: arg1 = 0 (which cannot
1017
1017
         * overflow).
1018
1018
         *
1079
1079
        result = arg1 + arg2;
1080
1080
 
1081
1081
        /*
1082
 
         * Overflow check.      If the inputs are of different signs then their sum
 
1082
         * Overflow check.  If the inputs are of different signs then their sum
1083
1083
         * cannot overflow.  If the inputs are of the same sign, their sum had
1084
1084
         * better be that sign too.
1085
1085
         */
1100
1100
        result = arg1 - arg2;
1101
1101
 
1102
1102
        /*
1103
 
         * Overflow check.      If the inputs are of the same sign then their
1104
 
         * difference cannot overflow.  If they are of different signs then the
 
1103
         * Overflow check.  If the inputs are of the same sign then their
 
1104
         * difference cannot overflow.  If they are of different signs then the
1105
1105
         * result should be of the same sign as the first input.
1106
1106
         */
1107
1107
        if (!SAMESIGN(arg1, arg2) && !SAMESIGN(result, arg1))
1121
1121
        result = arg1 * arg2;
1122
1122
 
1123
1123
        /*
1124
 
         * Overflow check.      We basically check to see if result / arg2 gives arg1
 
1124
         * Overflow check.  We basically check to see if result / arg2 gives arg1
1125
1125
         * again.  There is one case where this fails: arg2 = 0 (which cannot
1126
1126
         * overflow).
1127
1127
         *