Thread: Requesting some information about the small portion of source code of postgreSQL

Requesting some information about the small portion of source code of postgreSQL

From
Srinivas Karthik V
Date:
Dear PostgresSQL Hackers,
   I am working in optimizer module of postgreSQL 9.4.1. I am trying to return a subplan for a query instead of full plan. For this I need to return an intermediate plan (or path) from the DP lattice (i.e.  from RelOptInfo *standard_join_search() at allpaths.c) instead of the full optimal plan (which is from the last level of root->join_rel_level()).
while doing so I am getting error :variable not found in subplan target lists at function fix_join_expr_mutator at setrefs.c. 

It will be great if you can give me some idea about why this error is happening, since this error is happening at fix_join_expr_mutator function at setrefs.c. Please give me more information about this portion of code. Also I would like to know for what targetlist stands for.


Thanks,
Srinivas Karthik
On 27 September 2016 at 14:13, Srinivas Karthik V
<skarthikv.iitb@gmail.com> wrote:
> Dear PostgresSQL Hackers,
>    I am working in optimizer module of postgreSQL 9.4.1.

Why would you target a severely obsolete patch release?

> Also I would like to know for what targetlist stands for.

Can't really comment on the rest, but the targetlist is what gets
projected. It is the query or subquery output. It also contains a
bunch of internal-use values that get discarded and are not returned
to the user; these are labeled "resjunk".

e.g. in

SELECT a, b, f(b,c) / 100, 'x'
FROM some_table;

the targetlist is 4 entries. Two simple column references to "a" and
"b". An expression for f(b,c)/100 containing the column-references for
"b" and "c" and various surrounding expression nodes. Finally a
literal entry for 'x'.

You'll find turning on the various debug print options for parsetrees,
rewriter output and plan trees helpful in understanding what's going
on.



-- Craig Ringer                   http://www.2ndQuadrant.com/PostgreSQL Development, 24x7 Support, Training & Services



Re: Requesting some information about the small portion of source code of postgreSQL

From
Ashutosh Bapat
Date:
On Tue, Sep 27, 2016 at 11:43 AM, Srinivas Karthik V
<skarthikv.iitb@gmail.com> wrote:
> Dear PostgresSQL Hackers,
>    I am working in optimizer module of postgreSQL 9.4.1. I am trying to
> return a subplan for a query instead of full plan.For this I need to return
> an intermediate plan (or path) from the DP lattice (i.e.  from RelOptInfo
> *standard_join_search() at allpaths.c) instead of the full optimal plan
> (which is from the last level of root->join_rel_level()).

Why do you want to do that?

> while doing so I am getting error :variable not found in subplan target
> lists at function fix_join_expr_mutator at setrefs.c.
>
> It will be great if you can give me some idea about why this error is
> happening, since this error is happening at fix_join_expr_mutator function
> at setrefs.c. Please give me more information about this portion of code.
> Also I would like to know for what targetlist stands for.
>

setref.c implements the final stage of planner, where the
variable/expression references in the parent plan nodes are fixed by
pointing them to expressions/parts of expressions/variables from their
children. This error means that some of the things that parent node is
referring to are not available in the children as expected.

-- 
Best Wishes,
Ashutosh Bapat
EnterpriseDB Corporation
The Postgres Database Company