Re: What do these terms mean in the SOURCE CODE?

Lists: pgsql-hackers
From: Vaibhav Kaushal <vaibhavkaushal123(at)gmail(dot)com>
To: pgsql-hackers(at)postgresql(dot)org
Subject: What do these terms mean in the SOURCE CODE?
Date: 2010-11-19 15:41:09
Message-ID: AANLkTinLGKhCbULd7fcP+hSwE5+wcusHz9oSOFPz=ic7@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

I am going through the Executor code and come across the following terms
quite often. Can someone tell me what do they mean (in a few (may be a
couple of) sentences)?

1. Scan State
2. Plan State
3. Tuple Projection
4. EState
5. Qual
6. Expression

They sound quite ambiguous in the source code, specially when some of them
already have terms which have multiple meanings.

Thanks for your time.

-Vaibhav (*_*)


From: Vaibhav Kaushal <vaibhavkaushal123(at)gmail(dot)com>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Fwd: What do these terms mean in the SOURCE CODE?
Date: 2010-11-20 03:51:33
Message-ID: AANLkTiniECXfB6iPQCDwXnB4eX9uJ4jkdmF-obShJ6tw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Is no one ready to help on this? :(

-Vaibhav
---------- Forwarded message ----------
From: Vaibhav Kaushal <vaibhavkaushal123(at)gmail(dot)com>
Date: Fri, Nov 19, 2010 at 9:11 PM
Subject: What do these terms mean in the SOURCE CODE?
To: pgsql-hackers(at)postgresql(dot)org

I am going through the Executor code and come across the following terms
quite often. Can someone tell me what do they mean (in a few (may be a
couple of) sentences)?

1. Scan State
2. Plan State
3. Tuple Projection
4. EState
5. Qual
6. Expression

They sound quite ambiguous in the source code, specially when some of them
already have terms which have multiple meanings.

Thanks for your time.

-Vaibhav (*_*)


From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: Vaibhav Kaushal <vaibhavkaushal123(at)gmail(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Fwd: What do these terms mean in the SOURCE CODE?
Date: 2010-11-20 18:55:19
Message-ID: AANLkTinYPgWHYfh-Qzty87Dq_PJivGyDg5nyrm2CCPmJ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Fri, Nov 19, 2010 at 10:51 PM, Vaibhav Kaushal
<vaibhavkaushal123(at)gmail(dot)com> wrote:
> Is no one ready to help on this? :(

Apparently, no one is ready to drop what they are doing to immediately
answer your email before all the other ones they need to answer, but I
wouldn't infer from that that no one wants to help. It doesn't seem
very realistic to me to expect a 12-hour turnaround on free support,
but what do I know?

With regards to your question, for each type of plan node, there is an
associated "plan state" node. This is an important distinction
because, IIUC, plans can be reused, so plan state contains the
information that might need to be reset on each run. Scan state is
just a plan state node for a scan node. I believe a tuple projection
is what you get when you do something like SELECT
generate_series(1,10) FROM tbl - the set-returning function has to be
"projected" in multiple tuples. EState I could use some hints on
myself. A qual is a filter condition, e.g. in SELECT * FROM tbl WHERE
x = 1, the "x = 1" part is a qual. It's helpful to grep src/include
for the structures in question; the information they contain often
helps to understand their purpose.

--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company


From: Vaibhav Kaushal <vaibhavkaushal123(at)gmail(dot)com>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Fwd: What do these terms mean in the SOURCE CODE?
Date: 2010-11-20 18:59:32
Message-ID: AANLkTikKF3tApRxMg-HCBXidUgychzasntDoMKHfBsz4@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Thanks a lot for the answer. I see a lot of people discussing so many things
so I thought my email would have been ignored by those with a lot coming in
already. Thanks for the enlightenment.

-Vaibhav (*_*)

On Sun, Nov 21, 2010 at 12:25 AM, Robert Haas <robertmhaas(at)gmail(dot)com> wrote:

> On Fri, Nov 19, 2010 at 10:51 PM, Vaibhav Kaushal
> <vaibhavkaushal123(at)gmail(dot)com> wrote:
> > Is no one ready to help on this? :(
>
> Apparently, no one is ready to drop what they are doing to immediately
> answer your email before all the other ones they need to answer, but I
> wouldn't infer from that that no one wants to help. It doesn't seem
> very realistic to me to expect a 12-hour turnaround on free support,
> but what do I know?
>
> With regards to your question, for each type of plan node, there is an
> associated "plan state" node. This is an important distinction
> because, IIUC, plans can be reused, so plan state contains the
> information that might need to be reset on each run. Scan state is
> just a plan state node for a scan node. I believe a tuple projection
> is what you get when you do something like SELECT
> generate_series(1,10) FROM tbl - the set-returning function has to be
> "projected" in multiple tuples. EState I could use some hints on
> myself. A qual is a filter condition, e.g. in SELECT * FROM tbl WHERE
> x = 1, the "x = 1" part is a qual. It's helpful to grep src/include
> for the structures in question; the information they contain often
> helps to understand their purpose.
>
> --
> Robert Haas
> EnterpriseDB: http://www.enterprisedb.com
> The Enterprise PostgreSQL Company
>


From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: Vaibhav Kaushal <vaibhavkaushal123(at)gmail(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Fwd: What do these terms mean in the SOURCE CODE?
Date: 2010-11-20 19:03:50
Message-ID: AANLkTim0HKLHLL93ADMi0HC8s8OChZnyX+78saijXoBZ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Sat, Nov 20, 2010 at 1:59 PM, Vaibhav Kaushal
<vaibhavkaushal123(at)gmail(dot)com> wrote:
> Thanks a lot for the answer. I see a lot of people discussing so many things
> so I thought my email would have been ignored by those with a lot coming in
> already. Thanks for the enlightenment.

Sure. Just FYI, with these kinds of things, I do try to keep track of
them because I like to try to make sure that everyone gets an answer
back. But, I don't always have time to do it immediately, and
sometimes I wait even if I do, if I think that someone more
knowledgeable on that particular topic might chime in.

--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company


From: Vaibhav Kaushal <vaibhavkaushal123(at)gmail(dot)com>
To: Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Fwd: What do these terms mean in the SOURCE CODE?
Date: 2010-11-20 19:08:42
Message-ID: AANLkTinnu4bFjTtuCQAsHYRfp9SUfT12NijDcEJ80FQA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

I sure do respect that. Appreciated. :)

-Vaibhav (*_*)

On Sun, Nov 21, 2010 at 12:33 AM, Robert Haas <robertmhaas(at)gmail(dot)com> wrote:

> On Sat, Nov 20, 2010 at 1:59 PM, Vaibhav Kaushal
> <vaibhavkaushal123(at)gmail(dot)com> wrote:
> > Thanks a lot for the answer. I see a lot of people discussing so many
> things
> > so I thought my email would have been ignored by those with a lot coming
> in
> > already. Thanks for the enlightenment.
>
> Sure. Just FYI, with these kinds of things, I do try to keep track of
> them because I like to try to make sure that everyone gets an answer
> back. But, I don't always have time to do it immediately, and
> sometimes I wait even if I do, if I think that someone more
> knowledgeable on that particular topic might chime in.
>
> --
> Robert Haas
> EnterpriseDB: http://www.enterprisedb.com
> The Enterprise PostgreSQL Company
>


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: Vaibhav Kaushal <vaibhavkaushal123(at)gmail(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Fwd: What do these terms mean in the SOURCE CODE?
Date: 2010-11-20 20:51:39
Message-ID: 3926.1290286299@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Some additional comments ...

Robert Haas <robertmhaas(at)gmail(dot)com> writes:
> With regards to your question, for each type of plan node, there is an
> associated "plan state" node. This is an important distinction
> because, IIUC, plans can be reused, so plan state contains the
> information that might need to be reset on each run.

Yeah. The plan tree is supposed to be read-only so far as the executor
is concerned, so it needs a parallel "plan state" tree to hold its
runtime state.

> I believe a tuple projection
> is what you get when you do something like SELECT
> generate_series(1,10) FROM tbl - the set-returning function has to be
> "projected" in multiple tuples.

I think "projection" is a term out of relational theory, referring to
any sort of tuple-by-tuple manipulation of the data. For instance,
if you have a row "a, b, c" and you compute "a, c+1" based on that,
that's a projection. ExecProject() does this in the general case.
The business with SRFs in a targetlist possibly producing multiple
rows is a PostQUEL-ism that doesn't have any standard technical name
that I know of.

> A qual is a filter condition, e.g. in SELECT * FROM tbl WHERE
> x = 1, the "x = 1" part is a qual.

qual = qualifier. We use that term with various shades of meaning;
notably an indexqual is a qualifier that is useful for searching an
index. Large parts of the planner also use the term "clause" to mean
about the same thing.

> It's helpful to grep src/include
> for the structures in question;

Here's my single biggest tip for newcomers to the Postgres source:
if you don't use ctags, glimpse, or some other tool that can quickly
show you all references to a given identifier, go out and get one.
It's one of the easiest ways to learn about things.

regards, tom lane


From: Dimitri Fontaine <dimitri(at)2ndQuadrant(dot)fr>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Robert Haas <robertmhaas(at)gmail(dot)com>, Vaibhav Kaushal <vaibhavkaushal123(at)gmail(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Fwd: What do these terms mean in the SOURCE CODE?
Date: 2010-11-20 21:19:28
Message-ID: m2bp5jlmlb.fsf@2ndQuadrant.fr
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> writes:
> Here's my single biggest tip for newcomers to the Postgres source:
> if you don't use ctags, glimpse, or some other tool that can quickly
> show you all references to a given identifier, go out and get one.
> It's one of the easiest ways to learn about things.

I've been using cscope (out of advice from Joshua Tolley), and even
better its integration into Emacs which is called xcscope.el --- I
wouldn't have been able to come up with the extension patch series
without that.

http://cscope.sourceforge.net/

And as a quick teaser, the keys I mostly use:

C-c s d cscope-find-global-definition
C-c s s cscope-find-this-symbol
C-c s f cscope-find-this-file
C-c s I cscope-index-files

Regards,
--
Dimitri Fontaine
http://2ndQuadrant.fr PostgreSQL : Expertise, Formation et Support


From: Vaibhav Kaushal <vaibhavkaushal123(at)gmail(dot)com>
To: Dimitri Fontaine <dimitri(at)2ndquadrant(dot)fr>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Robert Haas <robertmhaas(at)gmail(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Fwd: What do these terms mean in the SOURCE CODE?
Date: 2010-11-21 05:06:10
Message-ID: AANLkTikmZiVSt8dR2edE88wkW2eYKKAzeZYVMQ0EdUKZ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Thanks for your concerns about my question. I am really happy to get the
answers.

@Mr. Tom Lane: Thanks for your explanation but I am already using Eclipse
which gets me to the definitions real easy. I do not post my questions on
the Hackers forum with any intention to disturb anyone. I just ask for help
when I am not able to understand it all. PG is my first attempt at OSS
development so it is particularly difficult. Of course PG has great support
for us because almost everything has got its comment, elaborating its use /
importance. However since I don't know everything yet about PG or even about
the OSS development, I come here asking. I have never been in so much of
code with so many Data Structures and typedefs. It gets confusing very
easily. This is the reason I came here asking.

I ask here after I have done my homework; and after I get messed up with the
code. Moreover the comments are those of developers. So when someone says
that "expression does not match qual" in the code, it is not so clear to me
as it might be to you people; because you know the terms, I don't. Thanks
for all the support I have been getting here to all of you. I will try to
ask as less as possible from now on.

@Mr. Dimitri Fontaine: Thanks for telling me the name of the tool. But I
like the GUI interfaces more and Eclipse has been serving me well for
browsing (only) the source code. I do not fear command line / shell but
prefer GUI more. Thanks for your answer.

-Vaibhav (*_*)

On Sun, Nov 21, 2010 at 2:49 AM, Dimitri Fontaine <dimitri(at)2ndquadrant(dot)fr>wrote:

> Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> writes:
> > Here's my single biggest tip for newcomers to the Postgres source:
> > if you don't use ctags, glimpse, or some other tool that can quickly
> > show you all references to a given identifier, go out and get one.
> > It's one of the easiest ways to learn about things.
>
> I've been using cscope (out of advice from Joshua Tolley), and even
> better its integration into Emacs which is called xcscope.el --- I
> wouldn't have been able to come up with the extension patch series
> without that.
>
> http://cscope.sourceforge.net/
>
> And as a quick teaser, the keys I mostly use:
>
> C-c s d cscope-find-global-definition
> C-c s s cscope-find-this-symbol
> C-c s f cscope-find-this-file
> C-c s I cscope-index-files
>
> Regards,
> --
> Dimitri Fontaine
> http://2ndQuadrant.fr PostgreSQL : Expertise, Formation et Support
>


From: Leonardo Francalanci <m_lists(at)yahoo(dot)it>
To: pgsql-hackers(at)postgresql(dot)org
Cc: Vaibhav Kaushal <vaibhavkaushal123(at)gmail(dot)com>
Subject: Re: Fwd: What do these terms mean in the SOURCE CODE?
Date: 2010-11-21 08:59:06
Message-ID: 388890.66040.qm@web29019.mail.ird.yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

> Here's my single biggest tip for newcomers to the Postgres source:
> if you don't use ctags, glimpse, or some other tool that can quickly
> show you all references to a given identifier, go out and get one.
> It's one of the easiest ways to learn about things.

I guess Eclipse is the best tool for the "newcomer" as it gives
you all the references very easily and shows the functions/structs
declaration when you pass with the mouse over one...

http://wiki.postgresql.org/wiki/Working_with_Eclipse


From: Vaibhav Kaushal <vaibhavkaushal123(at)gmail(dot)com>
To: Leonardo Francalanci <m_lists(at)yahoo(dot)it>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Fwd: What do these terms mean in the SOURCE CODE?
Date: 2010-11-21 22:44:55
Message-ID: AANLkTikG-bHFinP=r6-_dLk+CqQpop8wD1ui0qaBPMU+@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Thanks for that informative article. :) Taught me a few new points about
Eclipse :)

On Sun, Nov 21, 2010 at 2:29 PM, Leonardo Francalanci <m_lists(at)yahoo(dot)it>wrote:

> > Here's my single biggest tip for newcomers to the Postgres source:
> > if you don't use ctags, glimpse, or some other tool that can quickly
> > show you all references to a given identifier, go out and get one.
> > It's one of the easiest ways to learn about things.
>
>
> I guess Eclipse is the best tool for the "newcomer" as it gives
> you all the references very easily and shows the functions/structs
> declaration when you pass with the mouse over one...
>
> http://wiki.postgresql.org/wiki/Working_with_Eclipse
>
>
>
>


From: Bruce Momjian <bruce(at)momjian(dot)us>
To: Vaibhav Kaushal <vaibhavkaushal123(at)gmail(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: What do these terms mean in the SOURCE CODE?
Date: 2010-11-27 22:30:11
Message-ID: 201011272230.oARMUBe07508@momjian.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Vaibhav Kaushal wrote:
> I am going through the Executor code and come across the following terms
> quite often. Can someone tell me what do they mean (in a few (may be a
> couple of) sentences)?
>
> 1. Scan State
> 2. Plan State
> 3. Tuple Projection
> 4. EState
> 5. Qual
> 6. Expression
>
> They sound quite ambiguous in the source code, specially when some of them
> already have terms which have multiple meanings.

Have you read src/backend/executor/README? It is hard to explain what
these mean without understanding the executor.

--
Bruce Momjian <bruce(at)momjian(dot)us> http://momjian.us
EnterpriseDB http://enterprisedb.com

+ It's impossible for everything to be true. +