Reason: I need a mechanism by which I can extract the names of the tables used in a query which has been parsed. My plan is to check for a match of each word in the query with a list of names of the tables used in the current DB so that each hit confirms a 'table name' in the query in most cases.
This sounds rather flaky.
Maybe it would be better to just EXPLAIN the query and see if you get error code 42P01
postgres=# \set VERBOSITY verbose
postgres=# explain select * from doesnotexist;
ERROR: 42P01: relation "doesnotexist" does not exist
LINE 1: explain select * from doesnotexist;
Unfortunately this won't help you much if you want to know all of the tables that don't exist.