And then, just for kicks, please have a look at Postgres source code: well-organized, separated into well-designed components you will get acquainted with certain satisfaction to components that do parsing, planning, optimization, execution, and other functions.