Received: from malur.postgresql.org ([2a02:16a8:dc51::56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1g2R6F-0001Sj-6E for pgsql-hackers@arkaria.postgresql.org; Wed, 19 Sep 2018 01:16:15 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1g2R6B-00028r-Pb for pgsql-hackers@arkaria.postgresql.org; Wed, 19 Sep 2018 01:16:11 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1g2R6B-00028j-EX for pgsql-hackers@lists.postgresql.org; Wed, 19 Sep 2018 01:16:11 +0000 Received: from tamriel.snowman.net ([2001:470:e38f::11]) by makus.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1g2R68-0001u8-F3 for pgsql-hackers@postgresql.org; Wed, 19 Sep 2018 01:16:09 +0000 Received: by tamriel.snowman.net (Postfix, from userid 1000) id C06C05F79C; Tue, 18 Sep 2018 21:16:07 -0400 (EDT) Date: Tue, 18 Sep 2018 21:16:07 -0400 From: Stephen Frost To: Thomas Munro Cc: Douglas Doole , Peter Eisentraut , Christoph Berg , Pg Hackers Subject: Re: Collation versioning Message-ID: <20180919011607.GU4184@tamriel.snowman.net> References: <20180916210215.GE4184@tamriel.snowman.net> <20180918124835.GZ4184@tamriel.snowman.net> <20180918215451.GQ4184@tamriel.snowman.net> <20180918220931.GS4184@tamriel.snowman.net> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="a7SarfeDDnAelrrD" Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.24 (2015-08-30) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --a7SarfeDDnAelrrD Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Greetings, * Thomas Munro (thomas.munro@enterprisedb.com) wrote: > On Wed, Sep 19, 2018 at 10:09 AM Stephen Frost wrote: > > * Douglas Doole (dougdoole@gmail.com) wrote: > > > > The CHECK constraint doesn't need to directly track that informatio= n- > > > > it should have a dependency on the column in the table and that's w= here > > > > the information would be recorded about the current collation versi= on. > > > > > > Just to have fun throwing odd cases out, how would something like thi= s be > > > recorded? > > > > > > Database default collation: en_US > > > > > > CREATE TABLE t (c1 TEXT, c2 TEXT, c3 TEXT, > > > CHECK (c1 COLLATE "fr_FR" BETWEEN c2 COLLATE "fr_FR" AND c3 COLL= ATE > > > "fr_FR")); > > > > > > You could even be really warped and apply multiple collations on a si= ngle > > > column in a single constraint. > > > > Once it gets to an expression and not just a simple check, I'd think > > we'd record it in the expression.. >=20 > Maybe I misunderstood, but I don't think it makes sense to have a > collation version "on the column in the table", because (1) that fails > to capture the fact that two CHECK constraints that were defined at > different times might have become dependent on two different versions > (you created one constraint before upgrading and the other after, now > the older one is invalidated and sounds the alarm but the second one > is fine), and (2) the table itself doesn't care about collation > versions since heap tables are unordered; there is no particular > operation on the table that would be the correct time to update the > collation version on a table/column. What we're trying to track is > when objects that in some way depend on the version become > invalidated, so wherever we store it there's going to have to be a > version recorded per dependent object at its creation time, so that's > either new columns on every interested catalog table, or ... Today, we work out what operators to use for a given column based on the data type. This is why I was trying to get at the idea of using typmod earlier, but if we can't make that work then I'm inclined to try and figure out a way to get it as close as possible to being associated with the type. Yes, the heap is unordered, but the type *is* ordered and we track that with the type system. Maybe we just extend that somehow, rather than using the typmod or adding columns into catalogs where we store type information (such as pg_attribute). Perhaps typmod could be made larger to be able to support this, that might be another approach. No where in this does it strike me that it makes sense to push this into pg_depend though. Thanks! Stephen --a7SarfeDDnAelrrD Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAEBCgAGBQJboaNXAAoJEO1sijiDR2RVBrMP/juSplnMK5AkbXB3dd2YQXD+ +3GXbhxZfectbnnP8O0AIPDBvh1wWoCHKeUy7pLdjeuzS1SyF/WYx2JpzpKFfB6w MPzZQpGk9AxOsliSlZ37yclyJG23VAZbjun7XLTsrukj8xU7MdXfiYD1p0j/oIAy sLHxI1DJ+jElFVaL4vV+aRwf6/5VrX3+1ppPXYt9GUxK+QuiFpRe+DZt5EzzhDfU 3e5XFub1bputZ7RMHng+sDPWZeUswFmiymsqNCPJ+PZ3m1bmmAhrpDjhPCNIvHJT cx2uS48CsNFRmFfybcqxMwqO/YxsKvQbh44olFz6JWILLba4rI6d3KMiWem7pFNt C9hcprHh7SLJj1l9VBKGOh3nB+1hDA50XlvH27BXodqG3gPoI/5oUck+BDmIRkhL aMJf6gYgBABLsFUDo0mMtadhL3BXyOMIh6RvhuGAPONchAHcWwPJ0PnUZXiA9lvL j6WjZB4LAmYVEpheeC5UsnthadsGuUi+mr2km8yVYue+SAc7h+AViRgd3+D+HeNq pxsJcvtlOUP5El/N/uR5oJNq4hf2lzEl6DTUlW7ojg7Z7tPZ4CnnjDyQaYaIBuyM VFEIC1tJ225awev+q/l7koJ3Aia3SIXS3gMbeQvmuaBZbY8EEegYYUv3rrw5nHDY RnsAyMumd0H6BR/NMsrZ =SZlw -----END PGP SIGNATURE----- --a7SarfeDDnAelrrD--