Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1aikx6-0001kh-PE for pgsql-bugs@arkaria.postgresql.org; Wed, 23 Mar 2016 15:44:08 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1aikx6-0002oF-Br for pgsql-bugs@arkaria.postgresql.org; Wed, 23 Mar 2016 15:44:08 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1aikx5-0002nO-7v for pgsql-bugs@postgresql.org; Wed, 23 Mar 2016 15:44:07 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1aikx1-0003zf-3S for pgsql-bugs@postgresql.org; Wed, 23 Mar 2016 15:44:06 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id u2NFhuQL031914; Wed, 23 Mar 2016 11:43:56 -0400 From: Tom Lane To: Robert Haas cc: Noah Misch , Peter Geoghegan , Marc-Olaf Jaschke , Postgres-Bugs Subject: Re: Re: Missing rows with index scan when collation is not "C" (PostgreSQL 9.5) In-reply-to: References: <111D0E27-A8F3-4A84-A4E0-B0FB703863DF@s24.com> <9688.1458605021@sss.pgh.pa.us> <16214.1458615257@sss.pgh.pa.us> <19132.1458688784@sss.pgh.pa.us> <20160323024445.GA1306688@tornado.leadboat.com> Comments: In-reply-to Robert Haas message dated "Wed, 23 Mar 2016 10:47:07 -0400" MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0" Content-ID: <31687.1458747643.0@sss.pgh.pa.us> Date: Wed, 23 Mar 2016 11:43:56 -0400 Message-ID: <31913.1458747836@sss.pgh.pa.us> X-Pg-Spam-Score: -1.9 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org ------- =_aaaaaaaaaa0 Content-Type: text/plain; charset="us-ascii" Content-ID: <31687.1458747643.1@sss.pgh.pa.us> Robert Haas writes: > On Tue, Mar 22, 2016 at 10:44 PM, Noah Misch wrote: >> I, too, found MAXXFRMLEN insufficient; I raised it fourfold. Cygwin >> 2.2.1(0.289/5/3) caught fire; 10% of locales passed. (varstr_sortsupport() >> already blacklists the UTF8/native Windows case.) The test passed on Solaris >> 10, Solaris 11, HP-UX B.11.31, OpenBSD 5.0, NetBSD 5.1.2, and FreeBSD 9.0. >> See attached tryalllocales.sh outputs. I did not test AIX, because the AIX >> machines I use have no UTF8 locales installed. > Wow, thanks for the extensive testing. This suggests that, apart from > Cygwin which apparently doesn't matter right now, the only thing that > is busted is glibc. I believe we have yet to see a single locale that > fails anywhere else (apart from Cygwin). Good thing so few of our > users run glibc! I extended my test program to be able to check locales using ISO-8859-x encodings. RHEL6 shows me failures in a set of locales that is remarkably unlike the set it fails on for UTF8 (though good ol de_DE manages to fail in both encodings, as do a few others). I'm not sure what that implies for the underlying bug(s). > So, options: > 1. We could make it the user's problem to figure out whether they've > got a buggy glibc and add a GUC to shut this off, as previously > suggested. > 2. We could add a blacklist (either hardcoded or a GUC) shutting this > off for locales known to be buggy anywhere. > 3. We could write some test code that runs at startup time which > reliably detects all of the broken locales we've so far uncovered and > disables this if so. > 4. We could shut this off for all Linux users in all locales and tell > everybody to REINDEX. That would be pretty sad, though. TBH, I think #1 is right out, unless maybe the GUC defaults to off. We aren't that cavalier with data consistency in other departments. #2 and #3 presume a level of knowledge of the bug details that we have not got, and probably can't get by Monday. As far as #4 goes, we're going to have to tell people to REINDEX no matter what the other aspects of the fix look like. On-disk indexes are broken right now, if you're using one of the affected locales. regards, tom lane ------- =_aaaaaaaaaa0 Content-Type: text/x-c; name="strcolltest.c"; charset="us-ascii" Content-ID: <31687.1458747643.2@sss.pgh.pa.us> Content-Description: strcolltest.c Content-Transfer-Encoding: quoted-printable #include #include #include #include #include #include /* * Test: generate 1000 random UTF8 strings, sort them by strcoll, sanity- * check the sort result, sort them by strxfrm, sanity-check that result, * and compare the two sort orders. */ #define NSTRINGS 1000 #define MAXSTRLEN 20 #define MAXXFRMLEN (MAXSTRLEN * 10) typedef struct { char strval[MAXSTRLEN]; char xfrmval[MAXXFRMLEN]; int strsortpos; int xfrmsortpos; } OneString; /* qsort comparators */ static int strcoll_compare(const void *pa, const void *pb) { const OneString *a =3D (const OneString *) pa; const OneString *b =3D (const OneString *) pb; return strcoll(a->strval, b->strval); } static int strxfrm_compare(const void *pa, const void *pb) { const OneString *a =3D (const OneString *) pa; const OneString *b =3D (const OneString *) pb; return strcmp(a->xfrmval, b->xfrmval); } /* returns 1 if OK, 0 if inconsistency detected */ static int run_test_case(int is_utf8) { int ok =3D 1; OneString data[NSTRINGS]; int i, j; /* Generate random strings of length less than MAXSTRLEN bytes */ for (i =3D 0; i < NSTRINGS; i++) { char *p =3D data[i].strval; int len; len =3D 1 + (random() % (MAXSTRLEN - 1)); while (len > 0) { int c; /* Generate random printable char in ISO8859-1 range */ /* Bias towards producing a lot of spaces */ if ((random() % 16) < 3) c =3D ' '; else { do { c =3D random() & 0xFF; } while (!((c >=3D ' ' && c <=3D 127) || (c >=3D 0xA0 && c <=3D 0xFF))); } if (c <=3D 127 || !is_utf8) { *p++ =3D c; len--; } else { if (len < 2) break; /* Poor man's utf8-ification */ *p++ =3D 0xC0 + (c >> 6); len--; *p++ =3D 0x80 + (c & 0x3F); len--; } } *p =3D '\0'; /* strxfrm each string as we produce it */ if (strxfrm(data[i].xfrmval, data[i].strval, MAXXFRMLEN) >=3D MAXXFRMLEN) { fprintf(stderr, "strxfrm() result for %d-length string exceeded %d bytes= \n", (int) strlen(data[i].strval), MAXXFRMLEN); exit(1); } #if 0 printf("%d %s\n", i, data[i].strval); #endif } /* Sort per strcoll(), and label, being careful in case some are equal */ qsort(data, NSTRINGS, sizeof(OneString), strcoll_compare); j =3D 0; for (i =3D 0; i < NSTRINGS; i++) { if (i > 0 && strcoll(data[i].strval, data[i-1].strval) !=3D 0) j++; data[i].strsortpos =3D j; } /* Sanity-check: is each string <=3D those after it? */ for (i =3D 0; i < NSTRINGS; i++) { for (j =3D i + 1; j < NSTRINGS; j++) { if (strcoll(data[i].strval, data[j].strval) > 0) { fprintf(stdout, "strcoll sort inconsistency between positions %d and %d= \n", i, j); ok =3D 0; } } } /* Sort per strxfrm(), and label, being careful in case some are equal */ qsort(data, NSTRINGS, sizeof(OneString), strxfrm_compare); j =3D 0; for (i =3D 0; i < NSTRINGS; i++) { if (i > 0 && strcmp(data[i].xfrmval, data[i-1].xfrmval) !=3D 0) j++; data[i].xfrmsortpos =3D j; } /* Sanity-check: is each string <=3D those after it? */ for (i =3D 0; i < NSTRINGS; i++) { for (j =3D i + 1; j < NSTRINGS; j++) { if (strcmp(data[i].xfrmval, data[j].xfrmval) > 0) { fprintf(stdout, "strxfrm sort inconsistency between positions %d and %d= \n", i, j); ok =3D 0; } } } /* Compare */ for (i =3D 0; i < NSTRINGS; i++) { if (data[i].strsortpos !=3D data[i].xfrmsortpos) { fprintf(stdout, "inconsistency between strcoll (%d) and strxfrm (%d) ord= ers\n", data[i].strsortpos, data[i].xfrmsortpos); ok =3D 0; } } return ok; } int main(int argc, char **argv) { const char *lc; const char *cset; int is_utf8; int ntries; int result =3D 0; /* Absorb locale from environment, and report what we're using */ if (setlocale(LC_ALL, "") =3D=3D NULL) { perror("setlocale(LC_ALL) failed"); exit(1); } lc =3D setlocale(LC_COLLATE, NULL); if (lc) { printf("Using LC_COLLATE =3D \"%s\"\n", lc); } else { perror("setlocale(LC_COLLATE) failed"); exit(1); } lc =3D setlocale(LC_CTYPE, NULL); if (lc) { printf("Using LC_CTYPE =3D \"%s\"\n", lc); } else { perror("setlocale(LC_CTYPE) failed"); exit(1); } /* Identify encoding */ cset =3D nl_langinfo(CODESET); if (!cset) { perror("nl_langinfo(CODESET) failed"); exit(1); } if (strstr(cset, "utf") || strstr(cset, "UTF")) is_utf8 =3D 1; else if (strstr(cset, "iso-8859") || strstr(cset, "ISO-8859") || strstr(cset, "iso8859") || strstr(cset, "ISO8859")) is_utf8 =3D 0; else { fprintf(stderr, "unrecognized codeset name \"%s\"\n", cset); exit(1); } /* Ensure new random() values on every run */ srandom((unsigned int) time(NULL)); /* argv[1] can be the max number of tries to run */ if (argc > 1) ntries =3D atoi(argv[1]); else ntries =3D 1; /* Run one test instance per loop */ while (ntries-- > 0) { if (!run_test_case(is_utf8)) result =3D 1; } return result; } ------- =_aaaaaaaaaa0 Content-Type: text/plain; name="rhel6-bad-in-utf8"; charset="us-ascii" Content-ID: <31687.1458747643.3@sss.pgh.pa.us> Content-Description: rhel6-bad-in-utf8 az_AZ.utf8 BAD ca_AD.utf8 BAD ca_ES.utf8 BAD ca_FR.utf8 BAD ca_IT.utf8 BAD crh_UA.utf8 BAD csb_PL.utf8 BAD cv_RU.utf8 BAD da_DK.utf8 BAD de_DE.utf8 BAD en_CA.utf8 BAD es_EC.utf8 BAD es_US.utf8 BAD fi_FI.utf8 BAD fil_PH.utf8 BAD fo_FO.utf8 BAD fr_CA.utf8 BAD fur_IT.utf8 BAD hu_HU.utf8 BAD ig_NG.utf8 BAD ik_CA.utf8 BAD iu_CA.utf8 BAD kl_GL.utf8 BAD ku_TR.utf8 BAD nb_NO.utf8 BAD nn_NO.utf8 BAD no_NO.utf8 BAD ro_RO.utf8 BAD sc_IT.utf8 BAD se_NO.utf8 BAD shs_CA.utf8 BAD sq_AL.utf8 BAD sq_MK.utf8 BAD sv_FI.utf8 BAD sv_SE.utf8 BAD tk_TM.utf8 BAD tt_RU.utf8 BAD tt_RU.utf8@iqtelif BAD ug_CN.utf8 BAD vi_VN.utf8 BAD yo_NG.utf8 BAD ------- =_aaaaaaaaaa0 Content-Type: text/plain; name="rhel6-bad-in-iso8859x"; charset="us-ascii" Content-ID: <31687.1458747643.4@sss.pgh.pa.us> Content-Description: rhel6-bad-in-iso8859x ar_AE.iso88596 BAD ar_BH.iso88596 BAD ar_DZ.iso88596 BAD ar_EG.iso88596 BAD ar_IQ.iso88596 BAD ar_JO.iso88596 BAD ar_KW.iso88596 BAD ar_LB.iso88596 BAD ar_LY.iso88596 BAD ar_MA.iso88596 BAD ar_OM.iso88596 BAD ar_QA.iso88596 BAD ar_SD.iso88596 BAD ar_SY.iso88596 BAD ar_TN.iso88596 BAD ar_YE.iso88596 BAD bs_BA.iso88592 BAD ca_AD.iso885915 BAD ca_ES.iso88591 BAD ca_ES.iso885915@euro BAD ca_FR.iso885915 BAD ca_IT.iso885915 BAD da_DK.iso88591 BAD da_DK.iso885915 BAD de_DE.iso88591 BAD es_EC.iso88591 BAD es_US.iso88591 BAD fi_FI.iso88591 BAD fi_FI.iso885915@euro BAD fo_FO.iso88591 BAD fr_CA.iso88591 BAD he_IL.iso88598 BAD hu_HU.iso88592 BAD iw_IL.iso88598 BAD kl_GL.iso88591 BAD ku_TR.iso88599 BAD mk_MK.iso88595 BAD mt_MT.iso88593 BAD nb_NO.iso88591 BAD nn_NO.iso88591 BAD no_NO.iso88591 BAD ro_RO.iso88592 BAD ru_RU.iso88595 BAD sq_AL.iso88591 BAD sv_FI.iso88591 BAD sv_FI.iso885915@euro BAD sv_SE.iso88591 BAD sv_SE.iso885915 BAD ------- =_aaaaaaaaaa0 Content-Type: text/plain Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs ------- =_aaaaaaaaaa0--