Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

kwcheck.py: compare postgres keywords table

  • Loading branch information...
commit e99a53bfd59eda75d499c811ceb9696620777234 1 parent 7524030
@markokr authored
Showing with 50 additions and 0 deletions.
  1. +50 −0 misc/kwcheck.py
View
50 misc/kwcheck.py
@@ -0,0 +1,50 @@
+#! /usr/bin/env python
+
+import sys
+import re
+
+import pkgloader
+pkgloader.require('skytools', '3.0')
+import skytools.quoting
+
+kwmap = skytools.quoting._ident_kwmap
+
+fn = "/opt/src/pgsql/postgresql/src/include/parser/kwlist.h"
+if len(sys.argv) == 2:
+ fn = sys.argv[1]
+
+rc = re.compile(r'PG_KEYWORD[(]"(.*)" , \s* \w+ , \s* (\w+) [)]', re.X)
+
+data = open(fn, 'r').read()
+full_map = {}
+cur_map = {}
+print "== new =="
+for kw, cat in rc.findall(data):
+ full_map[kw] = 1
+ if cat == 'UNRESERVED_KEYWORD':
+ continue
+ if cat == 'COL_NAME_KEYWORD':
+ continue
+ cur_map[kw] = 1
+ if kw not in kwmap:
+ print kw, cat
+ kwmap[kw] = 1
+
+print "== obsolete =="
+kws = kwmap.keys()
+kws.sort()
+for k in kws:
+ if k not in full_map:
+ print k, '(not in full_map)'
+ elif k not in cur_map:
+ print k, '(not in cur_map)'
+
+print "== full list =="
+ln = ""
+for k in kws:
+ ln += '"%s":1, ' % k
+ if len(ln) > 70:
+ print ln.strip()
+ ln = ""
+print ln.strip()
+
Please sign in to comment.
Something went wrong with that request. Please try again.