From 11324e408f0e3a25621c611467927c644894b30d Mon Sep 17 00:00:00 2001
From: Tom Lane <tgl@sss.pgh.pa.us>
Date: Tue, 7 Mar 2017 10:42:11 -0500
Subject: [PATCH] Remove vestigial grammar support for CHARACTER ... CHARACTER
 SET option.

The SQL standard says that you should be able to write "CHARACTER SET foo"
as part of the declaration of a char-type column.  We don't implement that,
but a rough form of support has existed in gram.y since commit f10b63923.
That's now sat there for nigh 20 years without anyone fleshing it out ---
and even if someone did, the contemplated approach of having separate data
type name(s) for every character set certainly isn't what we'd do today.
Let's just remove the grammar production; if anyone is ever motivated to
work on this, reinventing the grammar support is a trivial fraction of
what they'd have to do.  And we've never documented anything about
supporting such a clause.

Per gripe from Neha Khatri.

Discussion: https://postgr.es/m/CAFO0U+-iOS5oYN5v3SBuZvfhPUTRrkDFEx8w7H17B07Rwg3YUA@mail.gmail.com
---
 src/backend/parser/gram.y | 18 ++----------------
 1 file changed, 2 insertions(+), 16 deletions(-)

diff --git a/src/backend/parser/gram.y b/src/backend/parser/gram.y
index 083124ed3b..bb55e1c95c 100644
--- a/src/backend/parser/gram.y
+++ b/src/backend/parser/gram.y
@@ -513,7 +513,6 @@ static Node *makeRecursiveViewSelect(char *relname, List *aliases, Node *query);
 				Bit ConstBit BitWithLength BitWithoutLength
 %type <str>		character
 %type <str>		extract_arg
-%type <str>		opt_charset
 %type <boolean> opt_varying opt_timezone opt_no_inherit
 
 %type <ival>	Iconst SignedIconst
@@ -11923,28 +11922,20 @@ ConstCharacter:  CharacterWithLength
 				}
 		;
 
-CharacterWithLength:  character '(' Iconst ')' opt_charset
+CharacterWithLength:  character '(' Iconst ')'
 				{
-					if (($5 != NULL) && (strcmp($5, "sql_text") != 0))
-						$1 = psprintf("%s_%s", $1, $5);
-
 					$$ = SystemTypeName($1);
 					$$->typmods = list_make1(makeIntConst($3, @3));
 					$$->location = @1;
 				}
 		;
 
-CharacterWithoutLength:	 character opt_charset
+CharacterWithoutLength:	 character
 				{
-					if (($2 != NULL) && (strcmp($2, "sql_text") != 0))
-						$1 = psprintf("%s_%s", $1, $2);
-
 					$$ = SystemTypeName($1);
-
 					/* char defaults to char(1), varchar to no limit */
 					if (strcmp($1, "bpchar") == 0)
 						$$->typmods = list_make1(makeIntConst(1, -1));
-
 					$$->location = @1;
 				}
 		;
@@ -11968,11 +11959,6 @@ opt_varying:
 			| /*EMPTY*/								{ $$ = FALSE; }
 		;
 
-opt_charset:
-			CHARACTER SET ColId						{ $$ = $3; }
-			| /*EMPTY*/								{ $$ = NULL; }
-		;
-
 /*
  * SQL date/time types
  */
-- 
2.50.1