$OpenBSD: patch-sql_pgq_triggers_stringutil_c,v 1.2 2020/02/06 00:40:06 jeremy Exp $

Fix build on PostgreSQL 9.6, patch taken from
https://github.com/markokr/skytools/pull/56

More fixes for PostgreSQL 12.

Index: sql/pgq/triggers/stringutil.c
--- sql/pgq/triggers/stringutil.c.orig
+++ sql/pgq/triggers/stringutil.c
@@ -16,10 +16,15 @@
  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */
 
+#include <strings.h>
 #include <postgres.h>
 #include <lib/stringinfo.h>
 #include <mb/pg_wchar.h>
+#if PG_VERSION_NUM >= 90600
+#include <common/keywords.h>
+#else
 #include <parser/keywords.h>
+#endif
 #include <utils/memutils.h>
 
 #include "stringutil.h"
@@ -146,23 +151,10 @@ static int pgq_quote_literal(char *dst, const uint8 *s
 /* check if ident is keyword that needs quoting */
 static bool is_keyword(const char *ident)
 {
-	const ScanKeyword *kw;
-
-	/* do the lookup */
-#if PG_VERSION_NUM >= 80500
-	kw = ScanKeywordLookup(ident, ScanKeywords, NumScanKeywords);
-#else
-	kw = ScanKeywordLookup(ident);
-#endif
-
-	/* unreserved? */
-#if PG_VERSION_NUM >= 80300
-	if (kw && kw->category == UNRESERVED_KEYWORD)
-		return false;
-#endif
-
-	/* found anything? */
-	return kw != NULL;
+#define PG_KEYWORD(kwname, id, value) if(strcasecmp(kwname, ident) == 0) return true;
+#include <parser/kwlist.h>
+#undef PG_KEYWORD
+	return false;
 }
 
 /*
