generate_system_columns.py 934 B

12345678910111213141516171819202122232425262728
  1. #!/usr/bin/env python3
  2. with open("pg_class.txt") as f:
  3. pg_class_file = f.readlines()
  4. with open("pg_class.generated.h","w") as f:
  5. for p in pg_class_file[2:-2]:
  6. s=p.split("|")
  7. oid=int(s[0].strip())
  8. relkind=s[1].strip()
  9. relname=s[2].strip()
  10. nspname=s[3].strip()
  11. print(oid,relkind,relname,nspname)
  12. print('{{"' + nspname + '", "' + relname + '"}, ERelKind::' + ("Relation" if relkind == 'r' else "View") +", " + str(oid) + "},", file=f)
  13. with open("columns.txt") as f:
  14. columns_file = f.readlines()
  15. with open("columns.generated.h","w") as f:
  16. for p in columns_file[2:-2]:
  17. s=p.split("|")
  18. print(s)
  19. name=s[0].strip()
  20. relname=s[1].strip()
  21. schemaname=s[2].strip()
  22. udt=s[3].strip()
  23. print(schemaname,relname,name,udt)
  24. print('{"' + schemaname + '", "' + relname + '", "' + name + '", "' + udt + '"},', file=f)