From 492f701535ccbb7a728a1c5b38bd4ec993908ae8 Mon Sep 17 00:00:00 2001
From: John Naylor <jcnaylor@gmail.com>
Date: Sun, 15 Apr 2018 22:59:44 +0700
Subject: [PATCH 1/3] Quote all non-word characters in postgres.bki

This simplifies both genbki.pl and bootscanner.l. As a result, negative
numbers and lone dashes are now double-quoted in postgres.bki. As of
commit 4f85f664695, there are no longer octals in the data, but if they're
added in the future, they will be double-quoted as well.
---
 src/backend/bootstrap/bootscanner.l | 3 +--
 src/backend/catalog/genbki.pl       | 7 +------
 2 files changed, 2 insertions(+), 8 deletions(-)

diff --git a/src/backend/bootstrap/bootscanner.l b/src/backend/bootstrap/bootscanner.l
index 2ce6e52..d9af1cb 100644
--- a/src/backend/bootstrap/bootscanner.l
+++ b/src/backend/bootstrap/bootscanner.l
@@ -66,8 +66,7 @@ static int	yyline = 1;			/* line number for error reporting */
 
 
 D		[0-9]
-oct		\\{D}{D}{D}
-id		([A-Za-z0-9_]|{oct}|\-)+
+id		[A-Za-z0-9_]+
 sid		\"([^\"])*\"
 arrayid [A-Za-z0-9_]+\[{D}*\]
 
diff --git a/src/backend/catalog/genbki.pl b/src/backend/catalog/genbki.pl
index a1894f8..c44f5f8 100644
--- a/src/backend/catalog/genbki.pl
+++ b/src/backend/catalog/genbki.pl
@@ -678,12 +678,7 @@ sub print_bki_insert
 				or $atttype eq 'int2vector'
 				or $atttype =~ /\[\]$/
 
-				# Quote strings that have non-word characters. We make
-				# exceptions for values that are octals or negative numbers,
-				# for the same historical reason as above.
-				or (    $bki_value =~ /\W/
-					and $bki_value !~ /^\\\d{3}$/
-					and $bki_value !~ /^-\d*$/));
+				or ($bki_value =~ /\W/));     # Contains non-word characters
 
 		push @bki_values, $bki_value;
 	}
-- 
2.7.4

