diff options
author | Tom Lane | 2018-12-20 21:21:51 +0000 |
---|---|---|
committer | Tom Lane | 2018-12-20 21:21:59 +0000 |
commit | 7c15cef86d37924505b3bb49b5e1ad1740b1d8f7 (patch) | |
tree | 164e3b38ddb3af942cb8a2ac7e2ec14458681c2b | |
parent | 5bbee34d9f2e6097247ace3ebe1dde1f6aa80287 (diff) |
Base information_schema.sql_identifier domain on name, not varchar.
The SQL spec says that sql_identifier is a domain over varchar,
but it also says that that domain is supposed to represent the set
of valid identifiers for the implementation, in particular applying
a length limit matching the implementation's identifier length limit.
We were declaring sql_identifier as just "character varying", thus
duplicating what the spec says about base type, but entirely failing
at the rest of it.
Instead, let's declare sql_identifier as a domain over type "name".
(We can drop the COLLATE "C" added by commit 6b0faf723, since that's
now implicit in "name".) With the recent improvements to name's
comparison support, there's not a lot of functional difference between
name and varchar. So although in principle this is a spec deviation,
it's a pretty minor one. And correctly enforcing PG's name length limit
is a good thing; on balance this seems closer to the intent of the spec
than what we had.
But that's all just language-lawyering. The *real* reason to do this is
that it makes sql_identifier columns exposed by information_schema views
be just direct representations of the underlying "name" catalog columns,
eliminating a semantic mismatch that was disastrous for performance of
typical queries on the information_schema. In combination with the
recent change to allow dropping no-op CoerceToDomain nodes, this allows
(for example) queries such as
select ... from information_schema.tables where table_name = 'foo';
to produce an indexscan rather than a seqscan on pg_class.
Discussion: https://postgr.es/m/CAFj8pRBUCX4LZ2rA2BbEkdD6NN59mgx+BLo1gO08Wod4RLtcTg@mail.gmail.com
-rw-r--r-- | src/backend/catalog/information_schema.sql | 2 | ||||
-rw-r--r-- | src/include/catalog/catversion.h | 2 |
2 files changed, 2 insertions, 2 deletions
diff --git a/src/backend/catalog/information_schema.sql b/src/backend/catalog/information_schema.sql index b30da5f31b5..9e14222fa98 100644 --- a/src/backend/catalog/information_schema.sql +++ b/src/backend/catalog/information_schema.sql @@ -216,7 +216,7 @@ CREATE DOMAIN character_data AS character varying COLLATE "C"; * SQL_IDENTIFIER domain */ -CREATE DOMAIN sql_identifier AS character varying COLLATE "C"; +CREATE DOMAIN sql_identifier AS name; /* diff --git a/src/include/catalog/catversion.h b/src/include/catalog/catversion.h index b6a66db1393..0e89b303650 100644 --- a/src/include/catalog/catversion.h +++ b/src/include/catalog/catversion.h @@ -53,6 +53,6 @@ */ /* yyyymmddN */ -#define CATALOG_VERSION_NO 201812201 +#define CATALOG_VERSION_NO 201812202 #endif |