aboutsummaryrefslogtreecommitdiffstats
path: root/yql/essentials/parser/pg_catalog/generate_system_columns.py
blob: 14764c3e1f008ddb1f067899ac6dca379772d944 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#!/usr/bin/env python3

with open("pg_class.txt") as f:
    pg_class_file = f.readlines()

with open("pg_class.generated.h","w") as f:
    for p in pg_class_file[2:-2]:
        s=p.split("|")
        oid=int(s[0].strip())
        relkind=s[1].strip()
        relname=s[2].strip()
        nspname=s[3].strip()
        print(oid,relkind,relname,nspname)
        print('{{"' + nspname + '", "' + relname + '"}, ERelKind::' + ("Relation" if relkind == 'r' else "View") +", " + str(oid) + "},", file=f)

with open("columns.txt") as f:
    columns_file = f.readlines()

with open("columns.generated.h","w") as f:
    for p in columns_file[2:-2]:
        s=p.split("|")
        print(s)
        name=s[0].strip()
        relname=s[1].strip()
        schemaname=s[2].strip()
        udt=s[3].strip()
        print(schemaname,relname,name,udt)
        print('{"' + schemaname + '", "' + relname + '", "' + name + '", "' + udt + '"},', file=f)