From eb99bbbd401273916c94825120c594126aa17b66 Mon Sep 17 00:00:00 2001
From: Mark Dilger <mark.dilger@enterprisedb.com>
Date: Mon, 31 Aug 2020 13:13:07 -0700
Subject: [PATCH v6 2/3] Allow most keywords to be used as implicit column
 labels.

Previously, to use a keyword as a column label in an expression, the
keyword had to be preceded by the token AS.  That is no longer
required for most keywords.  This is accomplished with some changes
to gram.y and by removing support for postfix operators.

These keywords must still be preceded by AS:

    array, as, char, character, create, day, except, fetch, filter,
    for, from, grant, group, having, hour, intersect, into, isnull,
    limit, minute, month, notnull, offset, on, order, over,
    overlaps, precision, returning, second, to, union, varying,
    where, window, with, within, without, year

Adding to the return value of pg_get_keywords a fourth column
showing whether the keyword can be used as an implicit column label.
---
 doc/src/sgml/func.sgml                  |   6 +-
 doc/src/sgml/generate-keywords-table.pl |   2 +-
 src/backend/parser/check_keywords.pl    |  97 ++-
 src/backend/parser/gram.y               | 439 +++++++++++-
 src/backend/parser/scan.l               |   2 +-
 src/backend/utils/adt/misc.c            |  11 +-
 src/common/keywords.c                   |   2 +-
 src/include/catalog/pg_proc.dat         |   4 +-
 src/include/common/kwlookup.h           |   8 +
 src/include/parser/kwlist.h             | 902 ++++++++++++------------
 src/interfaces/ecpg/preproc/keywords.c  |   2 +-
 src/tools/gen_keywordlist.pl            |  30 +-
 12 files changed, 1010 insertions(+), 495 deletions(-)

diff --git a/doc/src/sgml/func.sgml b/doc/src/sgml/func.sgml
index b9f591296a..fd20720734 100644
--- a/doc/src/sgml/func.sgml
+++ b/doc/src/sgml/func.sgml
@@ -22171,7 +22171,8 @@ SELECT pg_type_is_visible('myschema.widget'::regtype);
         <returnvalue>setof record</returnvalue>
         ( <parameter>word</parameter> <type>text</type>,
         <parameter>catcode</parameter> <type>"char"</type>,
-        <parameter>catdesc</parameter> <type>text</type> )
+        <parameter>catdesc</parameter> <type>text</type>,
+        <parameter>aliastype</parameter> <type>text</type> )
        </para>
        <para>
         Returns a set of records describing the SQL keywords recognized by the
@@ -22183,6 +22184,9 @@ SELECT pg_type_is_visible('myschema.widget'::regtype);
         function name, or <literal>R</literal> for a fully reserved keyword.
         The <parameter>catdesc</parameter> column contains a
         possibly-localized string describing the category.
+        The <parameter>aliastype</parameter> column is
+        <literal>implicit</literal> if the keyword can be used as an implicit
+        column label, <literal>explicit</literal> otherwise.
        </para></entry>
       </row>
 
diff --git a/doc/src/sgml/generate-keywords-table.pl b/doc/src/sgml/generate-keywords-table.pl
index 824b324ef7..6ae6f80c3f 100644
--- a/doc/src/sgml/generate-keywords-table.pl
+++ b/doc/src/sgml/generate-keywords-table.pl
@@ -39,7 +39,7 @@ open my $fh, '<', "$srcdir/../../../src/include/parser/kwlist.h" or die;
 
 while (<$fh>)
 {
-	if (/^PG_KEYWORD\("(\w+)", \w+, (\w+)_KEYWORD\)/)
+	if (/^PG_KEYWORD\("(\w+)", \w+, (\w+)_KEYWORD\, \w+\)/)
 	{
 		$keywords{ uc $1 }{'pg'}{ lc $2 } = 1;
 	}
diff --git a/src/backend/parser/check_keywords.pl b/src/backend/parser/check_keywords.pl
index 702c97bba2..ddba00c96f 100644
--- a/src/backend/parser/check_keywords.pl
+++ b/src/backend/parser/check_keywords.pl
@@ -21,6 +21,27 @@ sub error
 	return;
 }
 
+sub check_alphabetical_order
+{
+	my ($listname, $list) = @_;
+	my $prevkword = '';
+	my $implicit_alias_kword;
+
+	foreach my $kword (@$list)
+	{
+
+		# Some keyword have a _P suffix. Remove it for the comparison.
+		$implicit_alias_kword = $kword;
+		$implicit_alias_kword =~ s/_P$//;
+		if ($implicit_alias_kword le $prevkword)
+		{
+			error
+			  "'$implicit_alias_kword' after '$prevkword' in $listname list is misplaced";
+		}
+		$prevkword = $implicit_alias_kword;
+	}
+}
+
 $, = ' ';     # set output field separator
 $\ = "\n";    # set output record separator
 
@@ -33,9 +54,11 @@ $keyword_categories{'reserved_keyword'}       = 'RESERVED_KEYWORD';
 open(my $gram, '<', $gram_filename) || die("Could not open : $gram_filename");
 
 my $kcat;
+my $implicit_alias;
 my $comment;
 my @arr;
 my %keywords;
+my @implicit_alias;
 
 line: while (my $S = <$gram>)
 {
@@ -51,7 +74,7 @@ line: while (my $S = <$gram>)
 	$s = '[/][*]', $S =~ s#$s# /* #g;
 	$s = '[*][/]', $S =~ s#$s# */ #g;
 
-	if (!($kcat))
+	if (!($kcat) && !($implicit_alias))
 	{
 
 		# Is this the beginning of a keyword list?
@@ -63,6 +86,10 @@ line: while (my $S = <$gram>)
 				next line;
 			}
 		}
+
+		# Is this the beginning of the implicit_alias_keyword list?
+		$implicit_alias = 1 if ($S =~ m/^implicit_alias_keyword:/);
+
 		next line;
 	}
 
@@ -97,7 +124,8 @@ line: while (my $S = <$gram>)
 		{
 
 			# end of keyword list
-			$kcat = '';
+			undef $kcat;
+			undef $implicit_alias;
 			next;
 		}
 
@@ -107,31 +135,21 @@ line: while (my $S = <$gram>)
 		}
 
 		# Put this keyword into the right list
-		push @{ $keywords{$kcat} }, $arr[$fieldIndexer];
+		if ($implicit_alias)
+		{
+			push @implicit_alias, $arr[$fieldIndexer];
+		}
+		else
+		{
+			push @{ $keywords{$kcat} }, $arr[$fieldIndexer];
+		}
 	}
 }
 close $gram;
 
 # Check that each keyword list is in alphabetical order (just for neatnik-ism)
-my ($prevkword, $bare_kword);
-foreach my $kcat (keys %keyword_categories)
-{
-	$prevkword = '';
-
-	foreach my $kword (@{ $keywords{$kcat} })
-	{
-
-		# Some keyword have a _P suffix. Remove it for the comparison.
-		$bare_kword = $kword;
-		$bare_kword =~ s/_P$//;
-		if ($bare_kword le $prevkword)
-		{
-			error
-			  "'$bare_kword' after '$prevkword' in $kcat list is misplaced";
-		}
-		$prevkword = $bare_kword;
-	}
-}
+check_alphabetical_order($_, $keywords{$_}) for (keys %keyword_categories);
+check_alphabetical_order('implicit_alias_keyword', \@implicit_alias);
 
 # Transform the keyword lists into hashes.
 # kwhashes is a hash of hashes, keyed by keyword category id,
@@ -147,6 +165,7 @@ while (my ($kcat, $kcat_id) = each(%keyword_categories))
 
 	$kwhashes{$kcat_id} = $hash;
 }
+my %implicit_alias = map { $_ => 1 } @implicit_alias;
 
 # Now read in kwlist.h
 
@@ -154,17 +173,41 @@ open(my $kwlist, '<', $kwlist_filename)
   || die("Could not open : $kwlist_filename");
 
 my $prevkwstring = '';
-my $bare_kwname;
+my $implicit_alias_kwname;
 my %kwhash;
 kwlist_line: while (<$kwlist>)
 {
 	my ($line) = $_;
 
-	if ($line =~ /^PG_KEYWORD\(\"(.*)\", (.*), (.*)\)/)
+	if ($line =~ /^PG_KEYWORD\(\"(.*)\", (.*), (.*), (.*)\)/)
 	{
 		my ($kwstring) = $1;
 		my ($kwname)   = $2;
 		my ($kwcat_id) = $3;
+		my ($aliastype) = $4;
+
+		# Check that the keyword label aliastype value matches treatment in gram.y
+		if ($aliastype eq 'IMPLICIT_ALIAS')
+		{
+			unless ($implicit_alias{$kwname})
+			{
+				error
+				  "'$kwstring' in kwlist.h is marked as implicit_alias, but is missing from gram.y's implicit_alias_keyword rule";
+			}
+		}
+		elsif ($aliastype eq 'EXPLICIT_ALIAS')
+		{
+			if ($implicit_alias{$kwname})
+			{
+				error
+				  "'$kwname' in kwlist.h is marked as explicit, but is listed in gram.y's implicit_alias_keyword rule";
+			}
+		}
+		else
+		{
+			error
+			  "'$aliastype' not recognized in kwlist.h.  Expected either 'IMPLICIT_ALIAS' or 'EXPLICIT_ALIAS'";
+		}
 
 		# Check that the list is in alphabetical order (critical!)
 		if ($kwstring le $prevkwstring)
@@ -189,9 +232,9 @@ kwlist_line: while (<$kwlist>)
 		}
 
 		# Check that the keyword string matches keyword name
-		$bare_kwname = $kwname;
-		$bare_kwname =~ s/_P$//;
-		if ($bare_kwname ne uc($kwstring))
+		$implicit_alias_kwname = $kwname;
+		$implicit_alias_kwname =~ s/_P$//;
+		if ($implicit_alias_kwname ne uc($kwstring))
 		{
 			error
 			  "keyword name '$kwname' doesn't match keyword string '$kwstring'";
diff --git a/src/backend/parser/gram.y b/src/backend/parser/gram.y
index d8a607e29a..e9ee5dd873 100644
--- a/src/backend/parser/gram.y
+++ b/src/backend/parser/gram.y
@@ -540,14 +540,15 @@ static Node *makeRecursiveViewSelect(char *relname, List *aliases, Node *query);
 %type <str>		Sconst comment_text notify_payload
 %type <str>		RoleId opt_boolean_or_string
 %type <list>	var_list
-%type <str>		ColId ColLabel var_name type_function_name param_name
+%type <str>		ColId ColLabel ImplicitAlias
 %type <str>		NonReservedWord NonReservedWord_or_Sconst
+%type <str>		var_name type_function_name param_name
 %type <str>		createdb_opt_name
 %type <node>	var_value zone_value
 %type <rolespec> auth_ident RoleSpec opt_granted_by
 
 %type <keyword> unreserved_keyword type_func_name_keyword
-%type <keyword> col_name_keyword reserved_keyword
+%type <keyword> col_name_keyword implicit_alias_keyword reserved_keyword
 
 %type <node>	TableConstraint TableLikeClause
 %type <ival>	TableLikeOptionList TableLikeOption
@@ -14655,11 +14656,7 @@ target_el:	a_expr AS ColLabel
 					$$->val = (Node *)$1;
 					$$->location = @1;
 				}
-			/*
-			 * We support omitting AS only for column labels that aren't
-			 * any known keyword.
-			 */
-			| a_expr IDENT
+			| a_expr ImplicitAlias
 				{
 					$$ = makeNode(ResTarget);
 					$$->name = $2;
@@ -14987,6 +14984,12 @@ NonReservedWord:	IDENT							{ $$ = $1; }
 			| type_func_name_keyword				{ $$ = pstrdup($1); }
 		;
 
+/* Bare column label --- names that can be column labels without writing "AS".
+ */
+ImplicitAlias:	IDENT								{ $$ = $1; }
+			| implicit_alias_keyword					{ $$ = pstrdup($1); }
+		;
+
 /* Column label --- allowed labels in "AS" clauses.
  * This presently includes *all* Postgres keywords.
  */
@@ -14998,6 +15001,428 @@ ColLabel:	IDENT									{ $$ = $1; }
 		;
 
 
+/*
+ * All keywords can be used explicitly as a column label in expressions
+ * like 'SELECT 1234 AS keyword', but only some keywords can be used
+ * implicitly as column labels in expressions like 'SELECT 1234 keyword'.
+ * Those that can be used implicitly should be listed here.
+ *
+ * Keep this in alphabetical order.
+ */
+implicit_alias_keyword:
+			  ABORT_P
+			| ABSOLUTE_P
+			| ACCESS
+			| ACTION
+			| ADD_P
+			| ADMIN
+			| AFTER
+			| AGGREGATE
+			| ALL
+			| ALSO
+			| ALTER
+			| ALWAYS
+			| ANALYSE
+			| ANALYZE
+			| AND
+			| ANY
+			| ASC
+			| ASSERTION
+			| ASSIGNMENT
+			| ASYMMETRIC
+			| AT
+			| ATTACH
+			| ATTRIBUTE
+			| AUTHORIZATION
+			| BACKWARD
+			| BEFORE
+			| BEGIN_P
+			| BETWEEN
+			| BIGINT
+			| BINARY
+			| BIT
+			| BOOLEAN_P
+			| BOTH
+			| BY
+			| CACHE
+			| CALL
+			| CALLED
+			| CASCADE
+			| CASCADED
+			| CASE
+			| CAST
+			| CATALOG_P
+			| CHAIN
+			| CHARACTERISTICS
+			| CHECK
+			| CHECKPOINT
+			| CLASS
+			| CLOSE
+			| CLUSTER
+			| COALESCE
+			| COLLATE
+			| COLLATION
+			| COLUMN
+			| COLUMNS
+			| COMMENT
+			| COMMENTS
+			| COMMIT
+			| COMMITTED
+			| CONCURRENTLY
+			| CONFIGURATION
+			| CONFLICT
+			| CONNECTION
+			| CONSTRAINT
+			| CONSTRAINTS
+			| CONTENT_P
+			| CONTINUE_P
+			| CONVERSION_P
+			| COPY
+			| COST
+			| CROSS
+			| CSV
+			| CUBE
+			| CURRENT_P
+			| CURRENT_CATALOG
+			| CURRENT_DATE
+			| CURRENT_ROLE
+			| CURRENT_SCHEMA
+			| CURRENT_TIME
+			| CURRENT_TIMESTAMP
+			| CURRENT_USER
+			| CURSOR
+			| CYCLE
+			| DATA_P
+			| DATABASE
+			| DEALLOCATE
+			| DEC
+			| DECIMAL_P
+			| DECLARE
+			| DEFAULT
+			| DEFAULTS
+			| DEFERRABLE
+			| DEFERRED
+			| DEFINER
+			| DELETE_P
+			| DELIMITER
+			| DELIMITERS
+			| DEPENDS
+			| DESC
+			| DETACH
+			| DICTIONARY
+			| DISABLE_P
+			| DISCARD
+			| DISTINCT
+			| DO
+			| DOCUMENT_P
+			| DOMAIN_P
+			| DOUBLE_P
+			| DROP
+			| EACH
+			| ELSE
+			| ENABLE_P
+			| ENCODING
+			| ENCRYPTED
+			| END_P
+			| ENUM_P
+			| ESCAPE
+			| EVENT
+			| EXCLUDE
+			| EXCLUDING
+			| EXCLUSIVE
+			| EXECUTE
+			| EXISTS
+			| EXPLAIN
+			| EXPRESSION
+			| EXTENSION
+			| EXTERNAL
+			| EXTRACT
+			| FALSE_P
+			| FAMILY
+			| FIRST_P
+			| FLOAT_P
+			| FOLLOWING
+			| FORCE
+			| FOREIGN
+			| FORWARD
+			| FREEZE
+			| FULL
+			| FUNCTION
+			| FUNCTIONS
+			| GENERATED
+			| GLOBAL
+			| GRANTED
+			| GREATEST
+			| GROUPING
+			| GROUPS
+			| HANDLER
+			| HEADER_P
+			| HOLD
+			| IDENTITY_P
+			| IF_P
+			| ILIKE
+			| IMMEDIATE
+			| IMMUTABLE
+			| IMPLICIT_P
+			| IMPORT_P
+			| IN_P
+			| INCLUDE
+			| INCLUDING
+			| INCREMENT
+			| INDEX
+			| INDEXES
+			| INHERIT
+			| INHERITS
+			| INITIALLY
+			| INLINE_P
+			| INNER_P
+			| INOUT
+			| INPUT_P
+			| INSENSITIVE
+			| INSERT
+			| INSTEAD
+			| INT_P
+			| INTEGER
+			| INTERVAL
+			| INVOKER
+			| IS
+			| ISOLATION
+			| JOIN
+			| KEY
+			| LABEL
+			| LANGUAGE
+			| LARGE_P
+			| LAST_P
+			| LATERAL_P
+			| LEADING
+			| LEAKPROOF
+			| LEAST
+			| LEFT
+			| LEVEL
+			| LIKE
+			| LISTEN
+			| LOAD
+			| LOCAL
+			| LOCALTIME
+			| LOCALTIMESTAMP
+			| LOCATION
+			| LOCK_P
+			| LOCKED
+			| LOGGED
+			| MAPPING
+			| MATCH
+			| MATERIALIZED
+			| MAXVALUE
+			| METHOD
+			| MINVALUE
+			| MODE
+			| MOVE
+			| NAME_P
+			| NAMES
+			| NATIONAL
+			| NATURAL
+			| NCHAR
+			| NEW
+			| NEXT
+			| NFC
+			| NFD
+			| NFKC
+			| NFKD
+			| NO
+			| NONE
+			| NORMALIZE
+			| NORMALIZED
+			| NOT
+			| NOTHING
+			| NOTIFY
+			| NOWAIT
+			| NULL_P
+			| NULLIF
+			| NULLS_P
+			| NUMERIC
+			| OBJECT_P
+			| OF
+			| OFF
+			| OIDS
+			| OLD
+			| ONLY
+			| OPERATOR
+			| OPTION
+			| OPTIONS
+			| OR
+			| ORDINALITY
+			| OTHERS
+			| OUT_P
+			| OUTER_P
+			| OVERLAY
+			| OVERRIDING
+			| OWNED
+			| OWNER
+			| PARALLEL
+			| PARSER
+			| PARTIAL
+			| PARTITION
+			| PASSING
+			| PASSWORD
+			| PLACING
+			| PLANS
+			| POLICY
+			| POSITION
+			| PRECEDING
+			| PREPARE
+			| PREPARED
+			| PRESERVE
+			| PRIMARY
+			| PRIOR
+			| PRIVILEGES
+			| PROCEDURAL
+			| PROCEDURE
+			| PROCEDURES
+			| PROGRAM
+			| PUBLICATION
+			| QUOTE
+			| RANGE
+			| READ
+			| REAL
+			| REASSIGN
+			| RECHECK
+			| RECURSIVE
+			| REF
+			| REFERENCES
+			| REFERENCING
+			| REFRESH
+			| REINDEX
+			| RELATIVE_P
+			| RELEASE
+			| RENAME
+			| REPEATABLE
+			| REPLACE
+			| REPLICA
+			| RESET
+			| RESTART
+			| RESTRICT
+			| RETURNS
+			| REVOKE
+			| RIGHT
+			| ROLE
+			| ROLLBACK
+			| ROLLUP
+			| ROUTINE
+			| ROUTINES
+			| ROW
+			| ROWS
+			| RULE
+			| SAVEPOINT
+			| SCHEMA
+			| SCHEMAS
+			| SCROLL
+			| SEARCH
+			| SECURITY
+			| SELECT
+			| SEQUENCE
+			| SEQUENCES
+			| SERIALIZABLE
+			| SERVER
+			| SESSION
+			| SESSION_USER
+			| SET
+			| SETOF
+			| SETS
+			| SHARE
+			| SHOW
+			| SIMILAR
+			| SIMPLE
+			| SKIP
+			| SMALLINT
+			| SNAPSHOT
+			| SOME
+			| SQL_P
+			| STABLE
+			| STANDALONE_P
+			| START
+			| STATEMENT
+			| STATISTICS
+			| STDIN
+			| STDOUT
+			| STORAGE
+			| STORED
+			| STRICT_P
+			| STRIP_P
+			| SUBSCRIPTION
+			| SUBSTRING
+			| SUPPORT
+			| SYMMETRIC
+			| SYSID
+			| SYSTEM_P
+			| TABLE
+			| TABLES
+			| TABLESAMPLE
+			| TABLESPACE
+			| TEMP
+			| TEMPLATE
+			| TEMPORARY
+			| TEXT_P
+			| THEN
+			| TIES
+			| TIME
+			| TIMESTAMP
+			| TRAILING
+			| TRANSACTION
+			| TRANSFORM
+			| TREAT
+			| TRIGGER
+			| TRIM
+			| TRUE_P
+			| TRUNCATE
+			| TRUSTED
+			| TYPE_P
+			| TYPES_P
+			| UESCAPE
+			| UNBOUNDED
+			| UNCOMMITTED
+			| UNENCRYPTED
+			| UNIQUE
+			| UNKNOWN
+			| UNLISTEN
+			| UNLOGGED
+			| UNTIL
+			| UPDATE
+			| USER
+			| USING
+			| VACUUM
+			| VALID
+			| VALIDATE
+			| VALIDATOR
+			| VALUE_P
+			| VALUES
+			| VARCHAR
+			| VARIADIC
+			| VERBOSE
+			| VERSION_P
+			| VIEW
+			| VIEWS
+			| VOLATILE
+			| WHEN
+			| WHITESPACE_P
+			| WORK
+			| WRAPPER
+			| WRITE
+			| XML_P
+			| XMLATTRIBUTES
+			| XMLCONCAT
+			| XMLELEMENT
+			| XMLEXISTS
+			| XMLFOREST
+			| XMLNAMESPACES
+			| XMLPARSE
+			| XMLPI
+			| XMLROOT
+			| XMLSERIALIZE
+			| XMLTABLE
+			| YES_P
+			| ZONE
+		;
+
 /*
  * Keyword category lists.  Generally, every keyword present in
  * the Postgres grammar should appear in exactly one of these lists.
diff --git a/src/backend/parser/scan.l b/src/backend/parser/scan.l
index b1ea0cb538..58a8afa782 100644
--- a/src/backend/parser/scan.l
+++ b/src/backend/parser/scan.l
@@ -73,7 +73,7 @@ bool		standard_conforming_strings = true;
  * callers need to pass it to scanner_init, if they are using the
  * standard keyword list ScanKeywords.
  */
-#define PG_KEYWORD(kwname, value, category) value,
+#define PG_KEYWORD(kwname, value, category, aliastype) value,
 
 const uint16 ScanKeywordTokens[] = {
 #include "parser/kwlist.h"
diff --git a/src/backend/utils/adt/misc.c b/src/backend/utils/adt/misc.c
index 37c23c9155..1b04b0e079 100644
--- a/src/backend/utils/adt/misc.c
+++ b/src/backend/utils/adt/misc.c
@@ -416,13 +416,15 @@ pg_get_keywords(PG_FUNCTION_ARGS)
 		funcctx = SRF_FIRSTCALL_INIT();
 		oldcontext = MemoryContextSwitchTo(funcctx->multi_call_memory_ctx);
 
-		tupdesc = CreateTemplateTupleDesc(3);
+		tupdesc = CreateTemplateTupleDesc(4);
 		TupleDescInitEntry(tupdesc, (AttrNumber) 1, "word",
 						   TEXTOID, -1, 0);
 		TupleDescInitEntry(tupdesc, (AttrNumber) 2, "catcode",
 						   CHAROID, -1, 0);
 		TupleDescInitEntry(tupdesc, (AttrNumber) 3, "catdesc",
 						   TEXTOID, -1, 0);
+		TupleDescInitEntry(tupdesc, (AttrNumber) 4, "aliastype",
+						   TEXTOID, -1, 0);
 
 		funcctx->attinmeta = TupleDescGetAttInMetadata(tupdesc);
 
@@ -433,7 +435,7 @@ pg_get_keywords(PG_FUNCTION_ARGS)
 
 	if (funcctx->call_cntr < ScanKeywords.num_keywords)
 	{
-		char	   *values[3];
+		char	   *values[4];
 		HeapTuple	tuple;
 
 		/* cast-away-const is ugly but alternatives aren't much better */
@@ -465,6 +467,11 @@ pg_get_keywords(PG_FUNCTION_ARGS)
 				break;
 		}
 
+		if (GetScanKeywordIsImplicit(funcctx->call_cntr, &ScanKeywords))
+			values[3] = unconstify(char *, (const char *)"implicit");
+		else
+			values[3] = unconstify(char *, (const char *)"explicit");
+
 		tuple = BuildTupleFromCStrings(funcctx->attinmeta, values);
 
 		SRF_RETURN_NEXT(funcctx, HeapTupleGetDatum(tuple));
diff --git a/src/common/keywords.c b/src/common/keywords.c
index 54ed977096..f42cd69094 100644
--- a/src/common/keywords.c
+++ b/src/common/keywords.c
@@ -24,7 +24,7 @@
 
 /* Keyword categories for SQL keywords */
 
-#define PG_KEYWORD(kwname, value, category) category,
+#define PG_KEYWORD(kwname, value, category, aliastype) category,
 
 const uint8 ScanKeywordCategories[SCANKEYWORDS_NUM_KEYWORDS] = {
 #include "parser/kwlist.h"
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index f5af410434..b4c4fe8a5c 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -3677,8 +3677,8 @@
 { oid => '1686', descr => 'list of SQL keywords',
   proname => 'pg_get_keywords', procost => '10', prorows => '400',
   proretset => 't', provolatile => 's', prorettype => 'record',
-  proargtypes => '', proallargtypes => '{text,char,text}',
-  proargmodes => '{o,o,o}', proargnames => '{word,catcode,catdesc}',
+  proargtypes => '', proallargtypes => '{text,char,text,text}',
+  proargmodes => '{o,o,o,o}', proargnames => '{word,catcode,catdesc,aliastype}',
   prosrc => 'pg_get_keywords' },
 
 { oid => '2289', descr => 'convert generic options array to name/value table',
diff --git a/src/include/common/kwlookup.h b/src/include/common/kwlookup.h
index 9c0c7f88d8..d56b3d895e 100644
--- a/src/include/common/kwlookup.h
+++ b/src/include/common/kwlookup.h
@@ -26,6 +26,7 @@ typedef struct ScanKeywordList
 {
 	const char *kw_string;		/* all keywords in order, separated by \0 */
 	const uint16 *kw_offsets;	/* offsets to the start of each keyword */
+	const bool *kw_is_implicit;	/* whether each keyword can be used as an implicit label */
 	ScanKeywordHashFunc hash;	/* perfect hash function for keywords */
 	int			num_keywords;	/* number of keywords */
 	int			max_kw_len;		/* length of longest keyword */
@@ -41,4 +42,11 @@ GetScanKeyword(int n, const ScanKeywordList *keywords)
 	return keywords->kw_string + keywords->kw_offsets[n];
 }
 
+/* Code that wants to retrieve the aliastype of the N'th keyword should use this. */
+static inline bool
+GetScanKeywordIsImplicit(int n, const ScanKeywordList *keywords)
+{
+	return keywords->kw_is_implicit[n];
+}
+
 #endif							/* KWLOOKUP_H */
diff --git a/src/include/parser/kwlist.h b/src/include/parser/kwlist.h
index 08f22ce211..d011b3a5e5 100644
--- a/src/include/parser/kwlist.h
+++ b/src/include/parser/kwlist.h
@@ -24,454 +24,454 @@
  * Note: gen_keywordlist.pl requires the entries to appear in ASCII order.
  */
 
-/* name, value, category */
-PG_KEYWORD("abort", ABORT_P, UNRESERVED_KEYWORD)
-PG_KEYWORD("absolute", ABSOLUTE_P, UNRESERVED_KEYWORD)
-PG_KEYWORD("access", ACCESS, UNRESERVED_KEYWORD)
-PG_KEYWORD("action", ACTION, UNRESERVED_KEYWORD)
-PG_KEYWORD("add", ADD_P, UNRESERVED_KEYWORD)
-PG_KEYWORD("admin", ADMIN, UNRESERVED_KEYWORD)
-PG_KEYWORD("after", AFTER, UNRESERVED_KEYWORD)
-PG_KEYWORD("aggregate", AGGREGATE, UNRESERVED_KEYWORD)
-PG_KEYWORD("all", ALL, RESERVED_KEYWORD)
-PG_KEYWORD("also", ALSO, UNRESERVED_KEYWORD)
-PG_KEYWORD("alter", ALTER, UNRESERVED_KEYWORD)
-PG_KEYWORD("always", ALWAYS, UNRESERVED_KEYWORD)
-PG_KEYWORD("analyse", ANALYSE, RESERVED_KEYWORD)		/* British spelling */
-PG_KEYWORD("analyze", ANALYZE, RESERVED_KEYWORD)
-PG_KEYWORD("and", AND, RESERVED_KEYWORD)
-PG_KEYWORD("any", ANY, RESERVED_KEYWORD)
-PG_KEYWORD("array", ARRAY, RESERVED_KEYWORD)
-PG_KEYWORD("as", AS, RESERVED_KEYWORD)
-PG_KEYWORD("asc", ASC, RESERVED_KEYWORD)
-PG_KEYWORD("assertion", ASSERTION, UNRESERVED_KEYWORD)
-PG_KEYWORD("assignment", ASSIGNMENT, UNRESERVED_KEYWORD)
-PG_KEYWORD("asymmetric", ASYMMETRIC, RESERVED_KEYWORD)
-PG_KEYWORD("at", AT, UNRESERVED_KEYWORD)
-PG_KEYWORD("attach", ATTACH, UNRESERVED_KEYWORD)
-PG_KEYWORD("attribute", ATTRIBUTE, UNRESERVED_KEYWORD)
-PG_KEYWORD("authorization", AUTHORIZATION, TYPE_FUNC_NAME_KEYWORD)
-PG_KEYWORD("backward", BACKWARD, UNRESERVED_KEYWORD)
-PG_KEYWORD("before", BEFORE, UNRESERVED_KEYWORD)
-PG_KEYWORD("begin", BEGIN_P, UNRESERVED_KEYWORD)
-PG_KEYWORD("between", BETWEEN, COL_NAME_KEYWORD)
-PG_KEYWORD("bigint", BIGINT, COL_NAME_KEYWORD)
-PG_KEYWORD("binary", BINARY, TYPE_FUNC_NAME_KEYWORD)
-PG_KEYWORD("bit", BIT, COL_NAME_KEYWORD)
-PG_KEYWORD("boolean", BOOLEAN_P, COL_NAME_KEYWORD)
-PG_KEYWORD("both", BOTH, RESERVED_KEYWORD)
-PG_KEYWORD("by", BY, UNRESERVED_KEYWORD)
-PG_KEYWORD("cache", CACHE, UNRESERVED_KEYWORD)
-PG_KEYWORD("call", CALL, UNRESERVED_KEYWORD)
-PG_KEYWORD("called", CALLED, UNRESERVED_KEYWORD)
-PG_KEYWORD("cascade", CASCADE, UNRESERVED_KEYWORD)
-PG_KEYWORD("cascaded", CASCADED, UNRESERVED_KEYWORD)
-PG_KEYWORD("case", CASE, RESERVED_KEYWORD)
-PG_KEYWORD("cast", CAST, RESERVED_KEYWORD)
-PG_KEYWORD("catalog", CATALOG_P, UNRESERVED_KEYWORD)
-PG_KEYWORD("chain", CHAIN, UNRESERVED_KEYWORD)
-PG_KEYWORD("char", CHAR_P, COL_NAME_KEYWORD)
-PG_KEYWORD("character", CHARACTER, COL_NAME_KEYWORD)
-PG_KEYWORD("characteristics", CHARACTERISTICS, UNRESERVED_KEYWORD)
-PG_KEYWORD("check", CHECK, RESERVED_KEYWORD)
-PG_KEYWORD("checkpoint", CHECKPOINT, UNRESERVED_KEYWORD)
-PG_KEYWORD("class", CLASS, UNRESERVED_KEYWORD)
-PG_KEYWORD("close", CLOSE, UNRESERVED_KEYWORD)
-PG_KEYWORD("cluster", CLUSTER, UNRESERVED_KEYWORD)
-PG_KEYWORD("coalesce", COALESCE, COL_NAME_KEYWORD)
-PG_KEYWORD("collate", COLLATE, RESERVED_KEYWORD)
-PG_KEYWORD("collation", COLLATION, TYPE_FUNC_NAME_KEYWORD)
-PG_KEYWORD("column", COLUMN, RESERVED_KEYWORD)
-PG_KEYWORD("columns", COLUMNS, UNRESERVED_KEYWORD)
-PG_KEYWORD("comment", COMMENT, UNRESERVED_KEYWORD)
-PG_KEYWORD("comments", COMMENTS, UNRESERVED_KEYWORD)
-PG_KEYWORD("commit", COMMIT, UNRESERVED_KEYWORD)
-PG_KEYWORD("committed", COMMITTED, UNRESERVED_KEYWORD)
-PG_KEYWORD("concurrently", CONCURRENTLY, TYPE_FUNC_NAME_KEYWORD)
-PG_KEYWORD("configuration", CONFIGURATION, UNRESERVED_KEYWORD)
-PG_KEYWORD("conflict", CONFLICT, UNRESERVED_KEYWORD)
-PG_KEYWORD("connection", CONNECTION, UNRESERVED_KEYWORD)
-PG_KEYWORD("constraint", CONSTRAINT, RESERVED_KEYWORD)
-PG_KEYWORD("constraints", CONSTRAINTS, UNRESERVED_KEYWORD)
-PG_KEYWORD("content", CONTENT_P, UNRESERVED_KEYWORD)
-PG_KEYWORD("continue", CONTINUE_P, UNRESERVED_KEYWORD)
-PG_KEYWORD("conversion", CONVERSION_P, UNRESERVED_KEYWORD)
-PG_KEYWORD("copy", COPY, UNRESERVED_KEYWORD)
-PG_KEYWORD("cost", COST, UNRESERVED_KEYWORD)
-PG_KEYWORD("create", CREATE, RESERVED_KEYWORD)
-PG_KEYWORD("cross", CROSS, TYPE_FUNC_NAME_KEYWORD)
-PG_KEYWORD("csv", CSV, UNRESERVED_KEYWORD)
-PG_KEYWORD("cube", CUBE, UNRESERVED_KEYWORD)
-PG_KEYWORD("current", CURRENT_P, UNRESERVED_KEYWORD)
-PG_KEYWORD("current_catalog", CURRENT_CATALOG, RESERVED_KEYWORD)
-PG_KEYWORD("current_date", CURRENT_DATE, RESERVED_KEYWORD)
-PG_KEYWORD("current_role", CURRENT_ROLE, RESERVED_KEYWORD)
-PG_KEYWORD("current_schema", CURRENT_SCHEMA, TYPE_FUNC_NAME_KEYWORD)
-PG_KEYWORD("current_time", CURRENT_TIME, RESERVED_KEYWORD)
-PG_KEYWORD("current_timestamp", CURRENT_TIMESTAMP, RESERVED_KEYWORD)
-PG_KEYWORD("current_user", CURRENT_USER, RESERVED_KEYWORD)
-PG_KEYWORD("cursor", CURSOR, UNRESERVED_KEYWORD)
-PG_KEYWORD("cycle", CYCLE, UNRESERVED_KEYWORD)
-PG_KEYWORD("data", DATA_P, UNRESERVED_KEYWORD)
-PG_KEYWORD("database", DATABASE, UNRESERVED_KEYWORD)
-PG_KEYWORD("day", DAY_P, UNRESERVED_KEYWORD)
-PG_KEYWORD("deallocate", DEALLOCATE, UNRESERVED_KEYWORD)
-PG_KEYWORD("dec", DEC, COL_NAME_KEYWORD)
-PG_KEYWORD("decimal", DECIMAL_P, COL_NAME_KEYWORD)
-PG_KEYWORD("declare", DECLARE, UNRESERVED_KEYWORD)
-PG_KEYWORD("default", DEFAULT, RESERVED_KEYWORD)
-PG_KEYWORD("defaults", DEFAULTS, UNRESERVED_KEYWORD)
-PG_KEYWORD("deferrable", DEFERRABLE, RESERVED_KEYWORD)
-PG_KEYWORD("deferred", DEFERRED, UNRESERVED_KEYWORD)
-PG_KEYWORD("definer", DEFINER, UNRESERVED_KEYWORD)
-PG_KEYWORD("delete", DELETE_P, UNRESERVED_KEYWORD)
-PG_KEYWORD("delimiter", DELIMITER, UNRESERVED_KEYWORD)
-PG_KEYWORD("delimiters", DELIMITERS, UNRESERVED_KEYWORD)
-PG_KEYWORD("depends", DEPENDS, UNRESERVED_KEYWORD)
-PG_KEYWORD("desc", DESC, RESERVED_KEYWORD)
-PG_KEYWORD("detach", DETACH, UNRESERVED_KEYWORD)
-PG_KEYWORD("dictionary", DICTIONARY, UNRESERVED_KEYWORD)
-PG_KEYWORD("disable", DISABLE_P, UNRESERVED_KEYWORD)
-PG_KEYWORD("discard", DISCARD, UNRESERVED_KEYWORD)
-PG_KEYWORD("distinct", DISTINCT, RESERVED_KEYWORD)
-PG_KEYWORD("do", DO, RESERVED_KEYWORD)
-PG_KEYWORD("document", DOCUMENT_P, UNRESERVED_KEYWORD)
-PG_KEYWORD("domain", DOMAIN_P, UNRESERVED_KEYWORD)
-PG_KEYWORD("double", DOUBLE_P, UNRESERVED_KEYWORD)
-PG_KEYWORD("drop", DROP, UNRESERVED_KEYWORD)
-PG_KEYWORD("each", EACH, UNRESERVED_KEYWORD)
-PG_KEYWORD("else", ELSE, RESERVED_KEYWORD)
-PG_KEYWORD("enable", ENABLE_P, UNRESERVED_KEYWORD)
-PG_KEYWORD("encoding", ENCODING, UNRESERVED_KEYWORD)
-PG_KEYWORD("encrypted", ENCRYPTED, UNRESERVED_KEYWORD)
-PG_KEYWORD("end", END_P, RESERVED_KEYWORD)
-PG_KEYWORD("enum", ENUM_P, UNRESERVED_KEYWORD)
-PG_KEYWORD("escape", ESCAPE, UNRESERVED_KEYWORD)
-PG_KEYWORD("event", EVENT, UNRESERVED_KEYWORD)
-PG_KEYWORD("except", EXCEPT, RESERVED_KEYWORD)
-PG_KEYWORD("exclude", EXCLUDE, UNRESERVED_KEYWORD)
-PG_KEYWORD("excluding", EXCLUDING, UNRESERVED_KEYWORD)
-PG_KEYWORD("exclusive", EXCLUSIVE, UNRESERVED_KEYWORD)
-PG_KEYWORD("execute", EXECUTE, UNRESERVED_KEYWORD)
-PG_KEYWORD("exists", EXISTS, COL_NAME_KEYWORD)
-PG_KEYWORD("explain", EXPLAIN, UNRESERVED_KEYWORD)
-PG_KEYWORD("expression", EXPRESSION, UNRESERVED_KEYWORD)
-PG_KEYWORD("extension", EXTENSION, UNRESERVED_KEYWORD)
-PG_KEYWORD("external", EXTERNAL, UNRESERVED_KEYWORD)
-PG_KEYWORD("extract", EXTRACT, COL_NAME_KEYWORD)
-PG_KEYWORD("false", FALSE_P, RESERVED_KEYWORD)
-PG_KEYWORD("family", FAMILY, UNRESERVED_KEYWORD)
-PG_KEYWORD("fetch", FETCH, RESERVED_KEYWORD)
-PG_KEYWORD("filter", FILTER, UNRESERVED_KEYWORD)
-PG_KEYWORD("first", FIRST_P, UNRESERVED_KEYWORD)
-PG_KEYWORD("float", FLOAT_P, COL_NAME_KEYWORD)
-PG_KEYWORD("following", FOLLOWING, UNRESERVED_KEYWORD)
-PG_KEYWORD("for", FOR, RESERVED_KEYWORD)
-PG_KEYWORD("force", FORCE, UNRESERVED_KEYWORD)
-PG_KEYWORD("foreign", FOREIGN, RESERVED_KEYWORD)
-PG_KEYWORD("forward", FORWARD, UNRESERVED_KEYWORD)
-PG_KEYWORD("freeze", FREEZE, TYPE_FUNC_NAME_KEYWORD)
-PG_KEYWORD("from", FROM, RESERVED_KEYWORD)
-PG_KEYWORD("full", FULL, TYPE_FUNC_NAME_KEYWORD)
-PG_KEYWORD("function", FUNCTION, UNRESERVED_KEYWORD)
-PG_KEYWORD("functions", FUNCTIONS, UNRESERVED_KEYWORD)
-PG_KEYWORD("generated", GENERATED, UNRESERVED_KEYWORD)
-PG_KEYWORD("global", GLOBAL, UNRESERVED_KEYWORD)
-PG_KEYWORD("grant", GRANT, RESERVED_KEYWORD)
-PG_KEYWORD("granted", GRANTED, UNRESERVED_KEYWORD)
-PG_KEYWORD("greatest", GREATEST, COL_NAME_KEYWORD)
-PG_KEYWORD("group", GROUP_P, RESERVED_KEYWORD)
-PG_KEYWORD("grouping", GROUPING, COL_NAME_KEYWORD)
-PG_KEYWORD("groups", GROUPS, UNRESERVED_KEYWORD)
-PG_KEYWORD("handler", HANDLER, UNRESERVED_KEYWORD)
-PG_KEYWORD("having", HAVING, RESERVED_KEYWORD)
-PG_KEYWORD("header", HEADER_P, UNRESERVED_KEYWORD)
-PG_KEYWORD("hold", HOLD, UNRESERVED_KEYWORD)
-PG_KEYWORD("hour", HOUR_P, UNRESERVED_KEYWORD)
-PG_KEYWORD("identity", IDENTITY_P, UNRESERVED_KEYWORD)
-PG_KEYWORD("if", IF_P, UNRESERVED_KEYWORD)
-PG_KEYWORD("ilike", ILIKE, TYPE_FUNC_NAME_KEYWORD)
-PG_KEYWORD("immediate", IMMEDIATE, UNRESERVED_KEYWORD)
-PG_KEYWORD("immutable", IMMUTABLE, UNRESERVED_KEYWORD)
-PG_KEYWORD("implicit", IMPLICIT_P, UNRESERVED_KEYWORD)
-PG_KEYWORD("import", IMPORT_P, UNRESERVED_KEYWORD)
-PG_KEYWORD("in", IN_P, RESERVED_KEYWORD)
-PG_KEYWORD("include", INCLUDE, UNRESERVED_KEYWORD)
-PG_KEYWORD("including", INCLUDING, UNRESERVED_KEYWORD)
-PG_KEYWORD("increment", INCREMENT, UNRESERVED_KEYWORD)
-PG_KEYWORD("index", INDEX, UNRESERVED_KEYWORD)
-PG_KEYWORD("indexes", INDEXES, UNRESERVED_KEYWORD)
-PG_KEYWORD("inherit", INHERIT, UNRESERVED_KEYWORD)
-PG_KEYWORD("inherits", INHERITS, UNRESERVED_KEYWORD)
-PG_KEYWORD("initially", INITIALLY, RESERVED_KEYWORD)
-PG_KEYWORD("inline", INLINE_P, UNRESERVED_KEYWORD)
-PG_KEYWORD("inner", INNER_P, TYPE_FUNC_NAME_KEYWORD)
-PG_KEYWORD("inout", INOUT, COL_NAME_KEYWORD)
-PG_KEYWORD("input", INPUT_P, UNRESERVED_KEYWORD)
-PG_KEYWORD("insensitive", INSENSITIVE, UNRESERVED_KEYWORD)
-PG_KEYWORD("insert", INSERT, UNRESERVED_KEYWORD)
-PG_KEYWORD("instead", INSTEAD, UNRESERVED_KEYWORD)
-PG_KEYWORD("int", INT_P, COL_NAME_KEYWORD)
-PG_KEYWORD("integer", INTEGER, COL_NAME_KEYWORD)
-PG_KEYWORD("intersect", INTERSECT, RESERVED_KEYWORD)
-PG_KEYWORD("interval", INTERVAL, COL_NAME_KEYWORD)
-PG_KEYWORD("into", INTO, RESERVED_KEYWORD)
-PG_KEYWORD("invoker", INVOKER, UNRESERVED_KEYWORD)
-PG_KEYWORD("is", IS, TYPE_FUNC_NAME_KEYWORD)
-PG_KEYWORD("isnull", ISNULL, TYPE_FUNC_NAME_KEYWORD)
-PG_KEYWORD("isolation", ISOLATION, UNRESERVED_KEYWORD)
-PG_KEYWORD("join", JOIN, TYPE_FUNC_NAME_KEYWORD)
-PG_KEYWORD("key", KEY, UNRESERVED_KEYWORD)
-PG_KEYWORD("label", LABEL, UNRESERVED_KEYWORD)
-PG_KEYWORD("language", LANGUAGE, UNRESERVED_KEYWORD)
-PG_KEYWORD("large", LARGE_P, UNRESERVED_KEYWORD)
-PG_KEYWORD("last", LAST_P, UNRESERVED_KEYWORD)
-PG_KEYWORD("lateral", LATERAL_P, RESERVED_KEYWORD)
-PG_KEYWORD("leading", LEADING, RESERVED_KEYWORD)
-PG_KEYWORD("leakproof", LEAKPROOF, UNRESERVED_KEYWORD)
-PG_KEYWORD("least", LEAST, COL_NAME_KEYWORD)
-PG_KEYWORD("left", LEFT, TYPE_FUNC_NAME_KEYWORD)
-PG_KEYWORD("level", LEVEL, UNRESERVED_KEYWORD)
-PG_KEYWORD("like", LIKE, TYPE_FUNC_NAME_KEYWORD)
-PG_KEYWORD("limit", LIMIT, RESERVED_KEYWORD)
-PG_KEYWORD("listen", LISTEN, UNRESERVED_KEYWORD)
-PG_KEYWORD("load", LOAD, UNRESERVED_KEYWORD)
-PG_KEYWORD("local", LOCAL, UNRESERVED_KEYWORD)
-PG_KEYWORD("localtime", LOCALTIME, RESERVED_KEYWORD)
-PG_KEYWORD("localtimestamp", LOCALTIMESTAMP, RESERVED_KEYWORD)
-PG_KEYWORD("location", LOCATION, UNRESERVED_KEYWORD)
-PG_KEYWORD("lock", LOCK_P, UNRESERVED_KEYWORD)
-PG_KEYWORD("locked", LOCKED, UNRESERVED_KEYWORD)
-PG_KEYWORD("logged", LOGGED, UNRESERVED_KEYWORD)
-PG_KEYWORD("mapping", MAPPING, UNRESERVED_KEYWORD)
-PG_KEYWORD("match", MATCH, UNRESERVED_KEYWORD)
-PG_KEYWORD("materialized", MATERIALIZED, UNRESERVED_KEYWORD)
-PG_KEYWORD("maxvalue", MAXVALUE, UNRESERVED_KEYWORD)
-PG_KEYWORD("method", METHOD, UNRESERVED_KEYWORD)
-PG_KEYWORD("minute", MINUTE_P, UNRESERVED_KEYWORD)
-PG_KEYWORD("minvalue", MINVALUE, UNRESERVED_KEYWORD)
-PG_KEYWORD("mode", MODE, UNRESERVED_KEYWORD)
-PG_KEYWORD("month", MONTH_P, UNRESERVED_KEYWORD)
-PG_KEYWORD("move", MOVE, UNRESERVED_KEYWORD)
-PG_KEYWORD("name", NAME_P, UNRESERVED_KEYWORD)
-PG_KEYWORD("names", NAMES, UNRESERVED_KEYWORD)
-PG_KEYWORD("national", NATIONAL, COL_NAME_KEYWORD)
-PG_KEYWORD("natural", NATURAL, TYPE_FUNC_NAME_KEYWORD)
-PG_KEYWORD("nchar", NCHAR, COL_NAME_KEYWORD)
-PG_KEYWORD("new", NEW, UNRESERVED_KEYWORD)
-PG_KEYWORD("next", NEXT, UNRESERVED_KEYWORD)
-PG_KEYWORD("nfc", NFC, UNRESERVED_KEYWORD)
-PG_KEYWORD("nfd", NFD, UNRESERVED_KEYWORD)
-PG_KEYWORD("nfkc", NFKC, UNRESERVED_KEYWORD)
-PG_KEYWORD("nfkd", NFKD, UNRESERVED_KEYWORD)
-PG_KEYWORD("no", NO, UNRESERVED_KEYWORD)
-PG_KEYWORD("none", NONE, COL_NAME_KEYWORD)
-PG_KEYWORD("normalize", NORMALIZE, COL_NAME_KEYWORD)
-PG_KEYWORD("normalized", NORMALIZED, UNRESERVED_KEYWORD)
-PG_KEYWORD("not", NOT, RESERVED_KEYWORD)
-PG_KEYWORD("nothing", NOTHING, UNRESERVED_KEYWORD)
-PG_KEYWORD("notify", NOTIFY, UNRESERVED_KEYWORD)
-PG_KEYWORD("notnull", NOTNULL, TYPE_FUNC_NAME_KEYWORD)
-PG_KEYWORD("nowait", NOWAIT, UNRESERVED_KEYWORD)
-PG_KEYWORD("null", NULL_P, RESERVED_KEYWORD)
-PG_KEYWORD("nullif", NULLIF, COL_NAME_KEYWORD)
-PG_KEYWORD("nulls", NULLS_P, UNRESERVED_KEYWORD)
-PG_KEYWORD("numeric", NUMERIC, COL_NAME_KEYWORD)
-PG_KEYWORD("object", OBJECT_P, UNRESERVED_KEYWORD)
-PG_KEYWORD("of", OF, UNRESERVED_KEYWORD)
-PG_KEYWORD("off", OFF, UNRESERVED_KEYWORD)
-PG_KEYWORD("offset", OFFSET, RESERVED_KEYWORD)
-PG_KEYWORD("oids", OIDS, UNRESERVED_KEYWORD)
-PG_KEYWORD("old", OLD, UNRESERVED_KEYWORD)
-PG_KEYWORD("on", ON, RESERVED_KEYWORD)
-PG_KEYWORD("only", ONLY, RESERVED_KEYWORD)
-PG_KEYWORD("operator", OPERATOR, UNRESERVED_KEYWORD)
-PG_KEYWORD("option", OPTION, UNRESERVED_KEYWORD)
-PG_KEYWORD("options", OPTIONS, UNRESERVED_KEYWORD)
-PG_KEYWORD("or", OR, RESERVED_KEYWORD)
-PG_KEYWORD("order", ORDER, RESERVED_KEYWORD)
-PG_KEYWORD("ordinality", ORDINALITY, UNRESERVED_KEYWORD)
-PG_KEYWORD("others", OTHERS, UNRESERVED_KEYWORD)
-PG_KEYWORD("out", OUT_P, COL_NAME_KEYWORD)
-PG_KEYWORD("outer", OUTER_P, TYPE_FUNC_NAME_KEYWORD)
-PG_KEYWORD("over", OVER, UNRESERVED_KEYWORD)
-PG_KEYWORD("overlaps", OVERLAPS, TYPE_FUNC_NAME_KEYWORD)
-PG_KEYWORD("overlay", OVERLAY, COL_NAME_KEYWORD)
-PG_KEYWORD("overriding", OVERRIDING, UNRESERVED_KEYWORD)
-PG_KEYWORD("owned", OWNED, UNRESERVED_KEYWORD)
-PG_KEYWORD("owner", OWNER, UNRESERVED_KEYWORD)
-PG_KEYWORD("parallel", PARALLEL, UNRESERVED_KEYWORD)
-PG_KEYWORD("parser", PARSER, UNRESERVED_KEYWORD)
-PG_KEYWORD("partial", PARTIAL, UNRESERVED_KEYWORD)
-PG_KEYWORD("partition", PARTITION, UNRESERVED_KEYWORD)
-PG_KEYWORD("passing", PASSING, UNRESERVED_KEYWORD)
-PG_KEYWORD("password", PASSWORD, UNRESERVED_KEYWORD)
-PG_KEYWORD("placing", PLACING, RESERVED_KEYWORD)
-PG_KEYWORD("plans", PLANS, UNRESERVED_KEYWORD)
-PG_KEYWORD("policy", POLICY, UNRESERVED_KEYWORD)
-PG_KEYWORD("position", POSITION, COL_NAME_KEYWORD)
-PG_KEYWORD("preceding", PRECEDING, UNRESERVED_KEYWORD)
-PG_KEYWORD("precision", PRECISION, COL_NAME_KEYWORD)
-PG_KEYWORD("prepare", PREPARE, UNRESERVED_KEYWORD)
-PG_KEYWORD("prepared", PREPARED, UNRESERVED_KEYWORD)
-PG_KEYWORD("preserve", PRESERVE, UNRESERVED_KEYWORD)
-PG_KEYWORD("primary", PRIMARY, RESERVED_KEYWORD)
-PG_KEYWORD("prior", PRIOR, UNRESERVED_KEYWORD)
-PG_KEYWORD("privileges", PRIVILEGES, UNRESERVED_KEYWORD)
-PG_KEYWORD("procedural", PROCEDURAL, UNRESERVED_KEYWORD)
-PG_KEYWORD("procedure", PROCEDURE, UNRESERVED_KEYWORD)
-PG_KEYWORD("procedures", PROCEDURES, UNRESERVED_KEYWORD)
-PG_KEYWORD("program", PROGRAM, UNRESERVED_KEYWORD)
-PG_KEYWORD("publication", PUBLICATION, UNRESERVED_KEYWORD)
-PG_KEYWORD("quote", QUOTE, UNRESERVED_KEYWORD)
-PG_KEYWORD("range", RANGE, UNRESERVED_KEYWORD)
-PG_KEYWORD("read", READ, UNRESERVED_KEYWORD)
-PG_KEYWORD("real", REAL, COL_NAME_KEYWORD)
-PG_KEYWORD("reassign", REASSIGN, UNRESERVED_KEYWORD)
-PG_KEYWORD("recheck", RECHECK, UNRESERVED_KEYWORD)
-PG_KEYWORD("recursive", RECURSIVE, UNRESERVED_KEYWORD)
-PG_KEYWORD("ref", REF, UNRESERVED_KEYWORD)
-PG_KEYWORD("references", REFERENCES, RESERVED_KEYWORD)
-PG_KEYWORD("referencing", REFERENCING, UNRESERVED_KEYWORD)
-PG_KEYWORD("refresh", REFRESH, UNRESERVED_KEYWORD)
-PG_KEYWORD("reindex", REINDEX, UNRESERVED_KEYWORD)
-PG_KEYWORD("relative", RELATIVE_P, UNRESERVED_KEYWORD)
-PG_KEYWORD("release", RELEASE, UNRESERVED_KEYWORD)
-PG_KEYWORD("rename", RENAME, UNRESERVED_KEYWORD)
-PG_KEYWORD("repeatable", REPEATABLE, UNRESERVED_KEYWORD)
-PG_KEYWORD("replace", REPLACE, UNRESERVED_KEYWORD)
-PG_KEYWORD("replica", REPLICA, UNRESERVED_KEYWORD)
-PG_KEYWORD("reset", RESET, UNRESERVED_KEYWORD)
-PG_KEYWORD("restart", RESTART, UNRESERVED_KEYWORD)
-PG_KEYWORD("restrict", RESTRICT, UNRESERVED_KEYWORD)
-PG_KEYWORD("returning", RETURNING, RESERVED_KEYWORD)
-PG_KEYWORD("returns", RETURNS, UNRESERVED_KEYWORD)
-PG_KEYWORD("revoke", REVOKE, UNRESERVED_KEYWORD)
-PG_KEYWORD("right", RIGHT, TYPE_FUNC_NAME_KEYWORD)
-PG_KEYWORD("role", ROLE, UNRESERVED_KEYWORD)
-PG_KEYWORD("rollback", ROLLBACK, UNRESERVED_KEYWORD)
-PG_KEYWORD("rollup", ROLLUP, UNRESERVED_KEYWORD)
-PG_KEYWORD("routine", ROUTINE, UNRESERVED_KEYWORD)
-PG_KEYWORD("routines", ROUTINES, UNRESERVED_KEYWORD)
-PG_KEYWORD("row", ROW, COL_NAME_KEYWORD)
-PG_KEYWORD("rows", ROWS, UNRESERVED_KEYWORD)
-PG_KEYWORD("rule", RULE, UNRESERVED_KEYWORD)
-PG_KEYWORD("savepoint", SAVEPOINT, UNRESERVED_KEYWORD)
-PG_KEYWORD("schema", SCHEMA, UNRESERVED_KEYWORD)
-PG_KEYWORD("schemas", SCHEMAS, UNRESERVED_KEYWORD)
-PG_KEYWORD("scroll", SCROLL, UNRESERVED_KEYWORD)
-PG_KEYWORD("search", SEARCH, UNRESERVED_KEYWORD)
-PG_KEYWORD("second", SECOND_P, UNRESERVED_KEYWORD)
-PG_KEYWORD("security", SECURITY, UNRESERVED_KEYWORD)
-PG_KEYWORD("select", SELECT, RESERVED_KEYWORD)
-PG_KEYWORD("sequence", SEQUENCE, UNRESERVED_KEYWORD)
-PG_KEYWORD("sequences", SEQUENCES, UNRESERVED_KEYWORD)
-PG_KEYWORD("serializable", SERIALIZABLE, UNRESERVED_KEYWORD)
-PG_KEYWORD("server", SERVER, UNRESERVED_KEYWORD)
-PG_KEYWORD("session", SESSION, UNRESERVED_KEYWORD)
-PG_KEYWORD("session_user", SESSION_USER, RESERVED_KEYWORD)
-PG_KEYWORD("set", SET, UNRESERVED_KEYWORD)
-PG_KEYWORD("setof", SETOF, COL_NAME_KEYWORD)
-PG_KEYWORD("sets", SETS, UNRESERVED_KEYWORD)
-PG_KEYWORD("share", SHARE, UNRESERVED_KEYWORD)
-PG_KEYWORD("show", SHOW, UNRESERVED_KEYWORD)
-PG_KEYWORD("similar", SIMILAR, TYPE_FUNC_NAME_KEYWORD)
-PG_KEYWORD("simple", SIMPLE, UNRESERVED_KEYWORD)
-PG_KEYWORD("skip", SKIP, UNRESERVED_KEYWORD)
-PG_KEYWORD("smallint", SMALLINT, COL_NAME_KEYWORD)
-PG_KEYWORD("snapshot", SNAPSHOT, UNRESERVED_KEYWORD)
-PG_KEYWORD("some", SOME, RESERVED_KEYWORD)
-PG_KEYWORD("sql", SQL_P, UNRESERVED_KEYWORD)
-PG_KEYWORD("stable", STABLE, UNRESERVED_KEYWORD)
-PG_KEYWORD("standalone", STANDALONE_P, UNRESERVED_KEYWORD)
-PG_KEYWORD("start", START, UNRESERVED_KEYWORD)
-PG_KEYWORD("statement", STATEMENT, UNRESERVED_KEYWORD)
-PG_KEYWORD("statistics", STATISTICS, UNRESERVED_KEYWORD)
-PG_KEYWORD("stdin", STDIN, UNRESERVED_KEYWORD)
-PG_KEYWORD("stdout", STDOUT, UNRESERVED_KEYWORD)
-PG_KEYWORD("storage", STORAGE, UNRESERVED_KEYWORD)
-PG_KEYWORD("stored", STORED, UNRESERVED_KEYWORD)
-PG_KEYWORD("strict", STRICT_P, UNRESERVED_KEYWORD)
-PG_KEYWORD("strip", STRIP_P, UNRESERVED_KEYWORD)
-PG_KEYWORD("subscription", SUBSCRIPTION, UNRESERVED_KEYWORD)
-PG_KEYWORD("substring", SUBSTRING, COL_NAME_KEYWORD)
-PG_KEYWORD("support", SUPPORT, UNRESERVED_KEYWORD)
-PG_KEYWORD("symmetric", SYMMETRIC, RESERVED_KEYWORD)
-PG_KEYWORD("sysid", SYSID, UNRESERVED_KEYWORD)
-PG_KEYWORD("system", SYSTEM_P, UNRESERVED_KEYWORD)
-PG_KEYWORD("table", TABLE, RESERVED_KEYWORD)
-PG_KEYWORD("tables", TABLES, UNRESERVED_KEYWORD)
-PG_KEYWORD("tablesample", TABLESAMPLE, TYPE_FUNC_NAME_KEYWORD)
-PG_KEYWORD("tablespace", TABLESPACE, UNRESERVED_KEYWORD)
-PG_KEYWORD("temp", TEMP, UNRESERVED_KEYWORD)
-PG_KEYWORD("template", TEMPLATE, UNRESERVED_KEYWORD)
-PG_KEYWORD("temporary", TEMPORARY, UNRESERVED_KEYWORD)
-PG_KEYWORD("text", TEXT_P, UNRESERVED_KEYWORD)
-PG_KEYWORD("then", THEN, RESERVED_KEYWORD)
-PG_KEYWORD("ties", TIES, UNRESERVED_KEYWORD)
-PG_KEYWORD("time", TIME, COL_NAME_KEYWORD)
-PG_KEYWORD("timestamp", TIMESTAMP, COL_NAME_KEYWORD)
-PG_KEYWORD("to", TO, RESERVED_KEYWORD)
-PG_KEYWORD("trailing", TRAILING, RESERVED_KEYWORD)
-PG_KEYWORD("transaction", TRANSACTION, UNRESERVED_KEYWORD)
-PG_KEYWORD("transform", TRANSFORM, UNRESERVED_KEYWORD)
-PG_KEYWORD("treat", TREAT, COL_NAME_KEYWORD)
-PG_KEYWORD("trigger", TRIGGER, UNRESERVED_KEYWORD)
-PG_KEYWORD("trim", TRIM, COL_NAME_KEYWORD)
-PG_KEYWORD("true", TRUE_P, RESERVED_KEYWORD)
-PG_KEYWORD("truncate", TRUNCATE, UNRESERVED_KEYWORD)
-PG_KEYWORD("trusted", TRUSTED, UNRESERVED_KEYWORD)
-PG_KEYWORD("type", TYPE_P, UNRESERVED_KEYWORD)
-PG_KEYWORD("types", TYPES_P, UNRESERVED_KEYWORD)
-PG_KEYWORD("uescape", UESCAPE, UNRESERVED_KEYWORD)
-PG_KEYWORD("unbounded", UNBOUNDED, UNRESERVED_KEYWORD)
-PG_KEYWORD("uncommitted", UNCOMMITTED, UNRESERVED_KEYWORD)
-PG_KEYWORD("unencrypted", UNENCRYPTED, UNRESERVED_KEYWORD)
-PG_KEYWORD("union", UNION, RESERVED_KEYWORD)
-PG_KEYWORD("unique", UNIQUE, RESERVED_KEYWORD)
-PG_KEYWORD("unknown", UNKNOWN, UNRESERVED_KEYWORD)
-PG_KEYWORD("unlisten", UNLISTEN, UNRESERVED_KEYWORD)
-PG_KEYWORD("unlogged", UNLOGGED, UNRESERVED_KEYWORD)
-PG_KEYWORD("until", UNTIL, UNRESERVED_KEYWORD)
-PG_KEYWORD("update", UPDATE, UNRESERVED_KEYWORD)
-PG_KEYWORD("user", USER, RESERVED_KEYWORD)
-PG_KEYWORD("using", USING, RESERVED_KEYWORD)
-PG_KEYWORD("vacuum", VACUUM, UNRESERVED_KEYWORD)
-PG_KEYWORD("valid", VALID, UNRESERVED_KEYWORD)
-PG_KEYWORD("validate", VALIDATE, UNRESERVED_KEYWORD)
-PG_KEYWORD("validator", VALIDATOR, UNRESERVED_KEYWORD)
-PG_KEYWORD("value", VALUE_P, UNRESERVED_KEYWORD)
-PG_KEYWORD("values", VALUES, COL_NAME_KEYWORD)
-PG_KEYWORD("varchar", VARCHAR, COL_NAME_KEYWORD)
-PG_KEYWORD("variadic", VARIADIC, RESERVED_KEYWORD)
-PG_KEYWORD("varying", VARYING, UNRESERVED_KEYWORD)
-PG_KEYWORD("verbose", VERBOSE, TYPE_FUNC_NAME_KEYWORD)
-PG_KEYWORD("version", VERSION_P, UNRESERVED_KEYWORD)
-PG_KEYWORD("view", VIEW, UNRESERVED_KEYWORD)
-PG_KEYWORD("views", VIEWS, UNRESERVED_KEYWORD)
-PG_KEYWORD("volatile", VOLATILE, UNRESERVED_KEYWORD)
-PG_KEYWORD("when", WHEN, RESERVED_KEYWORD)
-PG_KEYWORD("where", WHERE, RESERVED_KEYWORD)
-PG_KEYWORD("whitespace", WHITESPACE_P, UNRESERVED_KEYWORD)
-PG_KEYWORD("window", WINDOW, RESERVED_KEYWORD)
-PG_KEYWORD("with", WITH, RESERVED_KEYWORD)
-PG_KEYWORD("within", WITHIN, UNRESERVED_KEYWORD)
-PG_KEYWORD("without", WITHOUT, UNRESERVED_KEYWORD)
-PG_KEYWORD("work", WORK, UNRESERVED_KEYWORD)
-PG_KEYWORD("wrapper", WRAPPER, UNRESERVED_KEYWORD)
-PG_KEYWORD("write", WRITE, UNRESERVED_KEYWORD)
-PG_KEYWORD("xml", XML_P, UNRESERVED_KEYWORD)
-PG_KEYWORD("xmlattributes", XMLATTRIBUTES, COL_NAME_KEYWORD)
-PG_KEYWORD("xmlconcat", XMLCONCAT, COL_NAME_KEYWORD)
-PG_KEYWORD("xmlelement", XMLELEMENT, COL_NAME_KEYWORD)
-PG_KEYWORD("xmlexists", XMLEXISTS, COL_NAME_KEYWORD)
-PG_KEYWORD("xmlforest", XMLFOREST, COL_NAME_KEYWORD)
-PG_KEYWORD("xmlnamespaces", XMLNAMESPACES, COL_NAME_KEYWORD)
-PG_KEYWORD("xmlparse", XMLPARSE, COL_NAME_KEYWORD)
-PG_KEYWORD("xmlpi", XMLPI, COL_NAME_KEYWORD)
-PG_KEYWORD("xmlroot", XMLROOT, COL_NAME_KEYWORD)
-PG_KEYWORD("xmlserialize", XMLSERIALIZE, COL_NAME_KEYWORD)
-PG_KEYWORD("xmltable", XMLTABLE, COL_NAME_KEYWORD)
-PG_KEYWORD("year", YEAR_P, UNRESERVED_KEYWORD)
-PG_KEYWORD("yes", YES_P, UNRESERVED_KEYWORD)
-PG_KEYWORD("zone", ZONE, UNRESERVED_KEYWORD)
+/* name, value, category, aliastype */
+PG_KEYWORD("abort", ABORT_P, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("absolute", ABSOLUTE_P, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("access", ACCESS, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("action", ACTION, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("add", ADD_P, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("admin", ADMIN, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("after", AFTER, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("aggregate", AGGREGATE, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("all", ALL, RESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("also", ALSO, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("alter", ALTER, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("always", ALWAYS, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("analyse", ANALYSE, RESERVED_KEYWORD, IMPLICIT_ALIAS)		/* British spelling */
+PG_KEYWORD("analyze", ANALYZE, RESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("and", AND, RESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("any", ANY, RESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("array", ARRAY, RESERVED_KEYWORD, EXPLICIT_ALIAS)
+PG_KEYWORD("as", AS, RESERVED_KEYWORD, EXPLICIT_ALIAS)
+PG_KEYWORD("asc", ASC, RESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("assertion", ASSERTION, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("assignment", ASSIGNMENT, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("asymmetric", ASYMMETRIC, RESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("at", AT, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("attach", ATTACH, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("attribute", ATTRIBUTE, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("authorization", AUTHORIZATION, TYPE_FUNC_NAME_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("backward", BACKWARD, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("before", BEFORE, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("begin", BEGIN_P, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("between", BETWEEN, COL_NAME_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("bigint", BIGINT, COL_NAME_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("binary", BINARY, TYPE_FUNC_NAME_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("bit", BIT, COL_NAME_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("boolean", BOOLEAN_P, COL_NAME_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("both", BOTH, RESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("by", BY, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("cache", CACHE, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("call", CALL, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("called", CALLED, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("cascade", CASCADE, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("cascaded", CASCADED, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("case", CASE, RESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("cast", CAST, RESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("catalog", CATALOG_P, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("chain", CHAIN, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("char", CHAR_P, COL_NAME_KEYWORD, EXPLICIT_ALIAS)
+PG_KEYWORD("character", CHARACTER, COL_NAME_KEYWORD, EXPLICIT_ALIAS)
+PG_KEYWORD("characteristics", CHARACTERISTICS, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("check", CHECK, RESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("checkpoint", CHECKPOINT, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("class", CLASS, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("close", CLOSE, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("cluster", CLUSTER, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("coalesce", COALESCE, COL_NAME_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("collate", COLLATE, RESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("collation", COLLATION, TYPE_FUNC_NAME_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("column", COLUMN, RESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("columns", COLUMNS, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("comment", COMMENT, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("comments", COMMENTS, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("commit", COMMIT, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("committed", COMMITTED, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("concurrently", CONCURRENTLY, TYPE_FUNC_NAME_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("configuration", CONFIGURATION, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("conflict", CONFLICT, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("connection", CONNECTION, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("constraint", CONSTRAINT, RESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("constraints", CONSTRAINTS, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("content", CONTENT_P, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("continue", CONTINUE_P, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("conversion", CONVERSION_P, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("copy", COPY, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("cost", COST, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("create", CREATE, RESERVED_KEYWORD, EXPLICIT_ALIAS)
+PG_KEYWORD("cross", CROSS, TYPE_FUNC_NAME_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("csv", CSV, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("cube", CUBE, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("current", CURRENT_P, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("current_catalog", CURRENT_CATALOG, RESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("current_date", CURRENT_DATE, RESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("current_role", CURRENT_ROLE, RESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("current_schema", CURRENT_SCHEMA, TYPE_FUNC_NAME_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("current_time", CURRENT_TIME, RESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("current_timestamp", CURRENT_TIMESTAMP, RESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("current_user", CURRENT_USER, RESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("cursor", CURSOR, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("cycle", CYCLE, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("data", DATA_P, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("database", DATABASE, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("day", DAY_P, UNRESERVED_KEYWORD, EXPLICIT_ALIAS)
+PG_KEYWORD("deallocate", DEALLOCATE, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("dec", DEC, COL_NAME_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("decimal", DECIMAL_P, COL_NAME_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("declare", DECLARE, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("default", DEFAULT, RESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("defaults", DEFAULTS, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("deferrable", DEFERRABLE, RESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("deferred", DEFERRED, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("definer", DEFINER, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("delete", DELETE_P, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("delimiter", DELIMITER, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("delimiters", DELIMITERS, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("depends", DEPENDS, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("desc", DESC, RESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("detach", DETACH, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("dictionary", DICTIONARY, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("disable", DISABLE_P, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("discard", DISCARD, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("distinct", DISTINCT, RESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("do", DO, RESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("document", DOCUMENT_P, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("domain", DOMAIN_P, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("double", DOUBLE_P, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("drop", DROP, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("each", EACH, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("else", ELSE, RESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("enable", ENABLE_P, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("encoding", ENCODING, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("encrypted", ENCRYPTED, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("end", END_P, RESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("enum", ENUM_P, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("escape", ESCAPE, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("event", EVENT, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("except", EXCEPT, RESERVED_KEYWORD, EXPLICIT_ALIAS)
+PG_KEYWORD("exclude", EXCLUDE, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("excluding", EXCLUDING, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("exclusive", EXCLUSIVE, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("execute", EXECUTE, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("exists", EXISTS, COL_NAME_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("explain", EXPLAIN, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("expression", EXPRESSION, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("extension", EXTENSION, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("external", EXTERNAL, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("extract", EXTRACT, COL_NAME_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("false", FALSE_P, RESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("family", FAMILY, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("fetch", FETCH, RESERVED_KEYWORD, EXPLICIT_ALIAS)
+PG_KEYWORD("filter", FILTER, UNRESERVED_KEYWORD, EXPLICIT_ALIAS)
+PG_KEYWORD("first", FIRST_P, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("float", FLOAT_P, COL_NAME_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("following", FOLLOWING, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("for", FOR, RESERVED_KEYWORD, EXPLICIT_ALIAS)
+PG_KEYWORD("force", FORCE, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("foreign", FOREIGN, RESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("forward", FORWARD, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("freeze", FREEZE, TYPE_FUNC_NAME_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("from", FROM, RESERVED_KEYWORD, EXPLICIT_ALIAS)
+PG_KEYWORD("full", FULL, TYPE_FUNC_NAME_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("function", FUNCTION, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("functions", FUNCTIONS, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("generated", GENERATED, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("global", GLOBAL, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("grant", GRANT, RESERVED_KEYWORD, EXPLICIT_ALIAS)
+PG_KEYWORD("granted", GRANTED, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("greatest", GREATEST, COL_NAME_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("group", GROUP_P, RESERVED_KEYWORD, EXPLICIT_ALIAS)
+PG_KEYWORD("grouping", GROUPING, COL_NAME_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("groups", GROUPS, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("handler", HANDLER, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("having", HAVING, RESERVED_KEYWORD, EXPLICIT_ALIAS)
+PG_KEYWORD("header", HEADER_P, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("hold", HOLD, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("hour", HOUR_P, UNRESERVED_KEYWORD, EXPLICIT_ALIAS)
+PG_KEYWORD("identity", IDENTITY_P, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("if", IF_P, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("ilike", ILIKE, TYPE_FUNC_NAME_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("immediate", IMMEDIATE, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("immutable", IMMUTABLE, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("implicit", IMPLICIT_P, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("import", IMPORT_P, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("in", IN_P, RESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("include", INCLUDE, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("including", INCLUDING, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("increment", INCREMENT, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("index", INDEX, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("indexes", INDEXES, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("inherit", INHERIT, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("inherits", INHERITS, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("initially", INITIALLY, RESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("inline", INLINE_P, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("inner", INNER_P, TYPE_FUNC_NAME_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("inout", INOUT, COL_NAME_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("input", INPUT_P, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("insensitive", INSENSITIVE, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("insert", INSERT, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("instead", INSTEAD, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("int", INT_P, COL_NAME_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("integer", INTEGER, COL_NAME_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("intersect", INTERSECT, RESERVED_KEYWORD, EXPLICIT_ALIAS)
+PG_KEYWORD("interval", INTERVAL, COL_NAME_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("into", INTO, RESERVED_KEYWORD, EXPLICIT_ALIAS)
+PG_KEYWORD("invoker", INVOKER, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("is", IS, TYPE_FUNC_NAME_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("isnull", ISNULL, TYPE_FUNC_NAME_KEYWORD, EXPLICIT_ALIAS)
+PG_KEYWORD("isolation", ISOLATION, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("join", JOIN, TYPE_FUNC_NAME_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("key", KEY, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("label", LABEL, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("language", LANGUAGE, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("large", LARGE_P, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("last", LAST_P, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("lateral", LATERAL_P, RESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("leading", LEADING, RESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("leakproof", LEAKPROOF, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("least", LEAST, COL_NAME_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("left", LEFT, TYPE_FUNC_NAME_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("level", LEVEL, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("like", LIKE, TYPE_FUNC_NAME_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("limit", LIMIT, RESERVED_KEYWORD, EXPLICIT_ALIAS)
+PG_KEYWORD("listen", LISTEN, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("load", LOAD, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("local", LOCAL, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("localtime", LOCALTIME, RESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("localtimestamp", LOCALTIMESTAMP, RESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("location", LOCATION, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("lock", LOCK_P, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("locked", LOCKED, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("logged", LOGGED, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("mapping", MAPPING, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("match", MATCH, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("materialized", MATERIALIZED, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("maxvalue", MAXVALUE, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("method", METHOD, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("minute", MINUTE_P, UNRESERVED_KEYWORD, EXPLICIT_ALIAS)
+PG_KEYWORD("minvalue", MINVALUE, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("mode", MODE, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("month", MONTH_P, UNRESERVED_KEYWORD, EXPLICIT_ALIAS)
+PG_KEYWORD("move", MOVE, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("name", NAME_P, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("names", NAMES, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("national", NATIONAL, COL_NAME_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("natural", NATURAL, TYPE_FUNC_NAME_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("nchar", NCHAR, COL_NAME_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("new", NEW, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("next", NEXT, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("nfc", NFC, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("nfd", NFD, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("nfkc", NFKC, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("nfkd", NFKD, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("no", NO, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("none", NONE, COL_NAME_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("normalize", NORMALIZE, COL_NAME_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("normalized", NORMALIZED, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("not", NOT, RESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("nothing", NOTHING, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("notify", NOTIFY, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("notnull", NOTNULL, TYPE_FUNC_NAME_KEYWORD, EXPLICIT_ALIAS)
+PG_KEYWORD("nowait", NOWAIT, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("null", NULL_P, RESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("nullif", NULLIF, COL_NAME_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("nulls", NULLS_P, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("numeric", NUMERIC, COL_NAME_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("object", OBJECT_P, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("of", OF, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("off", OFF, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("offset", OFFSET, RESERVED_KEYWORD, EXPLICIT_ALIAS)
+PG_KEYWORD("oids", OIDS, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("old", OLD, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("on", ON, RESERVED_KEYWORD, EXPLICIT_ALIAS)
+PG_KEYWORD("only", ONLY, RESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("operator", OPERATOR, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("option", OPTION, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("options", OPTIONS, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("or", OR, RESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("order", ORDER, RESERVED_KEYWORD, EXPLICIT_ALIAS)
+PG_KEYWORD("ordinality", ORDINALITY, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("others", OTHERS, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("out", OUT_P, COL_NAME_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("outer", OUTER_P, TYPE_FUNC_NAME_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("over", OVER, UNRESERVED_KEYWORD, EXPLICIT_ALIAS)
+PG_KEYWORD("overlaps", OVERLAPS, TYPE_FUNC_NAME_KEYWORD, EXPLICIT_ALIAS)
+PG_KEYWORD("overlay", OVERLAY, COL_NAME_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("overriding", OVERRIDING, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("owned", OWNED, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("owner", OWNER, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("parallel", PARALLEL, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("parser", PARSER, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("partial", PARTIAL, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("partition", PARTITION, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("passing", PASSING, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("password", PASSWORD, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("placing", PLACING, RESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("plans", PLANS, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("policy", POLICY, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("position", POSITION, COL_NAME_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("preceding", PRECEDING, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("precision", PRECISION, COL_NAME_KEYWORD, EXPLICIT_ALIAS)
+PG_KEYWORD("prepare", PREPARE, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("prepared", PREPARED, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("preserve", PRESERVE, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("primary", PRIMARY, RESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("prior", PRIOR, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("privileges", PRIVILEGES, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("procedural", PROCEDURAL, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("procedure", PROCEDURE, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("procedures", PROCEDURES, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("program", PROGRAM, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("publication", PUBLICATION, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("quote", QUOTE, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("range", RANGE, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("read", READ, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("real", REAL, COL_NAME_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("reassign", REASSIGN, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("recheck", RECHECK, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("recursive", RECURSIVE, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("ref", REF, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("references", REFERENCES, RESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("referencing", REFERENCING, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("refresh", REFRESH, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("reindex", REINDEX, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("relative", RELATIVE_P, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("release", RELEASE, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("rename", RENAME, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("repeatable", REPEATABLE, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("replace", REPLACE, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("replica", REPLICA, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("reset", RESET, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("restart", RESTART, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("restrict", RESTRICT, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("returning", RETURNING, RESERVED_KEYWORD, EXPLICIT_ALIAS)
+PG_KEYWORD("returns", RETURNS, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("revoke", REVOKE, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("right", RIGHT, TYPE_FUNC_NAME_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("role", ROLE, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("rollback", ROLLBACK, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("rollup", ROLLUP, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("routine", ROUTINE, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("routines", ROUTINES, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("row", ROW, COL_NAME_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("rows", ROWS, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("rule", RULE, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("savepoint", SAVEPOINT, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("schema", SCHEMA, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("schemas", SCHEMAS, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("scroll", SCROLL, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("search", SEARCH, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("second", SECOND_P, UNRESERVED_KEYWORD, EXPLICIT_ALIAS)
+PG_KEYWORD("security", SECURITY, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("select", SELECT, RESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("sequence", SEQUENCE, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("sequences", SEQUENCES, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("serializable", SERIALIZABLE, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("server", SERVER, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("session", SESSION, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("session_user", SESSION_USER, RESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("set", SET, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("setof", SETOF, COL_NAME_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("sets", SETS, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("share", SHARE, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("show", SHOW, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("similar", SIMILAR, TYPE_FUNC_NAME_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("simple", SIMPLE, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("skip", SKIP, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("smallint", SMALLINT, COL_NAME_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("snapshot", SNAPSHOT, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("some", SOME, RESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("sql", SQL_P, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("stable", STABLE, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("standalone", STANDALONE_P, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("start", START, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("statement", STATEMENT, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("statistics", STATISTICS, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("stdin", STDIN, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("stdout", STDOUT, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("storage", STORAGE, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("stored", STORED, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("strict", STRICT_P, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("strip", STRIP_P, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("subscription", SUBSCRIPTION, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("substring", SUBSTRING, COL_NAME_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("support", SUPPORT, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("symmetric", SYMMETRIC, RESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("sysid", SYSID, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("system", SYSTEM_P, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("table", TABLE, RESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("tables", TABLES, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("tablesample", TABLESAMPLE, TYPE_FUNC_NAME_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("tablespace", TABLESPACE, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("temp", TEMP, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("template", TEMPLATE, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("temporary", TEMPORARY, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("text", TEXT_P, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("then", THEN, RESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("ties", TIES, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("time", TIME, COL_NAME_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("timestamp", TIMESTAMP, COL_NAME_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("to", TO, RESERVED_KEYWORD, EXPLICIT_ALIAS)
+PG_KEYWORD("trailing", TRAILING, RESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("transaction", TRANSACTION, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("transform", TRANSFORM, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("treat", TREAT, COL_NAME_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("trigger", TRIGGER, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("trim", TRIM, COL_NAME_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("true", TRUE_P, RESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("truncate", TRUNCATE, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("trusted", TRUSTED, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("type", TYPE_P, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("types", TYPES_P, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("uescape", UESCAPE, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("unbounded", UNBOUNDED, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("uncommitted", UNCOMMITTED, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("unencrypted", UNENCRYPTED, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("union", UNION, RESERVED_KEYWORD, EXPLICIT_ALIAS)
+PG_KEYWORD("unique", UNIQUE, RESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("unknown", UNKNOWN, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("unlisten", UNLISTEN, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("unlogged", UNLOGGED, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("until", UNTIL, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("update", UPDATE, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("user", USER, RESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("using", USING, RESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("vacuum", VACUUM, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("valid", VALID, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("validate", VALIDATE, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("validator", VALIDATOR, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("value", VALUE_P, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("values", VALUES, COL_NAME_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("varchar", VARCHAR, COL_NAME_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("variadic", VARIADIC, RESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("varying", VARYING, UNRESERVED_KEYWORD, EXPLICIT_ALIAS)
+PG_KEYWORD("verbose", VERBOSE, TYPE_FUNC_NAME_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("version", VERSION_P, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("view", VIEW, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("views", VIEWS, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("volatile", VOLATILE, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("when", WHEN, RESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("where", WHERE, RESERVED_KEYWORD, EXPLICIT_ALIAS)
+PG_KEYWORD("whitespace", WHITESPACE_P, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("window", WINDOW, RESERVED_KEYWORD, EXPLICIT_ALIAS)
+PG_KEYWORD("with", WITH, RESERVED_KEYWORD, EXPLICIT_ALIAS)
+PG_KEYWORD("within", WITHIN, UNRESERVED_KEYWORD, EXPLICIT_ALIAS)
+PG_KEYWORD("without", WITHOUT, UNRESERVED_KEYWORD, EXPLICIT_ALIAS)
+PG_KEYWORD("work", WORK, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("wrapper", WRAPPER, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("write", WRITE, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("xml", XML_P, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("xmlattributes", XMLATTRIBUTES, COL_NAME_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("xmlconcat", XMLCONCAT, COL_NAME_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("xmlelement", XMLELEMENT, COL_NAME_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("xmlexists", XMLEXISTS, COL_NAME_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("xmlforest", XMLFOREST, COL_NAME_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("xmlnamespaces", XMLNAMESPACES, COL_NAME_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("xmlparse", XMLPARSE, COL_NAME_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("xmlpi", XMLPI, COL_NAME_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("xmlroot", XMLROOT, COL_NAME_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("xmlserialize", XMLSERIALIZE, COL_NAME_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("xmltable", XMLTABLE, COL_NAME_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("year", YEAR_P, UNRESERVED_KEYWORD, EXPLICIT_ALIAS)
+PG_KEYWORD("yes", YES_P, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
+PG_KEYWORD("zone", ZONE, UNRESERVED_KEYWORD, IMPLICIT_ALIAS)
diff --git a/src/interfaces/ecpg/preproc/keywords.c b/src/interfaces/ecpg/preproc/keywords.c
index f82764aeb9..624b8bfe60 100644
--- a/src/interfaces/ecpg/preproc/keywords.c
+++ b/src/interfaces/ecpg/preproc/keywords.c
@@ -29,7 +29,7 @@
 #include "preproc_extern.h"
 #include "preproc.h"
 
-#define PG_KEYWORD(kwname, value, category) value,
+#define PG_KEYWORD(kwname, value, category, aliastype) value,
 
 const uint16 SQLScanKeywordTokens[] = {
 #include "parser/kwlist.h"
diff --git a/src/tools/gen_keywordlist.pl b/src/tools/gen_keywordlist.pl
index e9250b8fb2..ad433d416e 100644
--- a/src/tools/gen_keywordlist.pl
+++ b/src/tools/gen_keywordlist.pl
@@ -93,11 +93,27 @@ EOM
 
 # Parse input file for keyword names.
 my @keywords;
+my @implicit_alias;
+my %transform = ( IMPLICIT_ALIAS => 'true', EXPLICIT_ALIAS => 'false');
 while (<$kif>)
 {
 	if (/^PG_KEYWORD\("(\w+)"/)
 	{
-		push @keywords, $1;
+		my $kword = $1;
+		push @keywords, $kword;
+
+		if (/^PG_KEYWORD\("\w+", .*, (IMPLICIT_ALIAS|EXPLICIT_ALIAS)\)/)
+		{
+			push @implicit_alias, $transform{$1};
+		}
+		else
+		{
+			# parser/kwlist.h lists each keyword as either an implicit or an
+			# explicit alias, but other kwlist files do not, and for them, it
+			# won't matter what we use here as long as it is a valid boolean,
+			# so we arbitrarily use 'true'.
+			push @implicit_alias, 'true';
+		}
 	}
 }
 
@@ -153,6 +169,17 @@ foreach my $name (@keywords)
 
 print $kwdef "};\n\n";
 
+# Emit an array of boolean as implicit alias values
+
+printf $kwdef "static const bool %s_kw_is_implicit[] = {\n", $varname;
+
+foreach my $bool (@implicit_alias)
+{
+	print $kwdef "\t$bool,\n";
+}
+
+print $kwdef "};\n\n";
+
 # Emit a macro defining the number of keywords.
 # (In some places it's useful to have access to that as a constant.)
 
@@ -173,6 +200,7 @@ printf $kwdef "static " if !$extern;
 printf $kwdef "const ScanKeywordList %s = {\n", $varname;
 printf $kwdef qq|\t%s_kw_string,\n|,            $varname;
 printf $kwdef qq|\t%s_kw_offsets,\n|,           $varname;
+printf $kwdef qq|\t%s_kw_is_implicit,\n|,       $varname;
 printf $kwdef qq|\t%s,\n|,                      $funcname;
 printf $kwdef qq|\t%s_NUM_KEYWORDS,\n|,         uc $varname;
 printf $kwdef qq|\t%d\n|,                       $max_len;
-- 
2.21.1 (Apple Git-122.3)

