Re: Some questions about PostgreSQL source code - Mailing list pgsql-hackers

From Tom Lane
Subject Re: Some questions about PostgreSQL source code
Date
Msg-id 6781.1241624089@sss.pgh.pa.us
Whole thread Raw
In response to Some questions about PostgreSQL source code  (Олег Царев <zabivator@gmail.com>)
List pgsql-hackers
Олег Царев <zabivator@gmail.com> writes:
> I need help in study internal structures of PosrgreSQL. Sorry for my bad
> english.
> I try to get information from source code and spend five days for that, but
> now have many questions and few understanding =(
> Source code it's clear, great commented, but studing so difficult system as
> DBMS it's very strong only from source code.

Have you read
http://developer.postgresql.org/pgdocs/postgres/overview.html
?  Also, many of the backend modules have README files that are
worth looking at.

> 1) Than AST go to planner for plan normalization and optimization.
> Planner work on AST structures, or build self internal tree of logical plan?

Well, both.  The input is a query tree and the output is a plan tree.

> 2) Who set types of any columns? Parser or planner?

The parse analysis phase determines all data types.  In principle the
semantics of the query are fully specified by the query tree.

> 1) Where in source build executor's node from logical plan (result of
> planner)?

The planner builds the plan tree (see createplan.c).  There's also
a "plan state" tree that's built during ExecutorStart to hold run-time
variables for each plan node.  This is needed because the plan tree is
read-only as far as the executor is concerned.

> I try look for  this information in source code, and found execAim.c, with
> big swtich.
> In that switch mixed brachnes of nodes, node states, some expressions and
> aggregation.

Uh, no, execAmi just works with planstate trees (I think there's one
function in it that works with plan trees).
        regards, tom lane


pgsql-hackers by date:

Previous
From: Peter Eisentraut
Date:
Subject: Re: bytea vs. pg_dump
Next
From: Heikki Linnakangas
Date:
Subject: Re: Some questions about PostgreSQL source code