Also, could you tell me during which stage(whether parser,optimizer or executor) does the table name gets stored, and if possible could you tell me which program specifically does that.
Usually parser, optimizer and command execution work with data from pg_class table. I don't understand to second question. if you need some points to postgresql source code - then magic word is "relname"