subselects

Started by Bruce Momjianalmost 28 years ago9 messages
#1Bruce Momjian
maillist@candle.pha.pa.us

OK, I have added code to allow the SubLinks make it to the optimizer.

I implemented ParseState->parentParseState, but not parentQuery, because
the parentParseState is much more valuable to me, and Vadim thought it
might be useful, but was not positive. Also, keeping that parentQuery
pointer valid through rewrite may be difficult, so I dropped it.
ParseState is only valid in the parser.

I have not done:

correlated subquery column references
added Var->sublevels_up
gotten this to work in the rewrite system
have not added full CopyNode support

I will address these in the next few days.

--
Bruce Momjian
maillist@candle.pha.pa.us

#2Vadim B. Mikheev
vadim@sable.krasnoyarsk.su
In reply to: Bruce Momjian (#1)
Re: subselects

Bruce Momjian wrote:

OK, I have added code to allow the SubLinks make it to the optimizer.

I implemented ParseState->parentParseState, but not parentQuery, because
the parentParseState is much more valuable to me, and Vadim thought it
might be useful, but was not positive. Also, keeping that parentQuery
pointer valid through rewrite may be difficult, so I dropped it.
ParseState is only valid in the parser.

I have not done:

correlated subquery column references
added Var->sublevels_up
gotten this to work in the rewrite system
have not added full CopyNode support

I will address these in the next few days.

Nice! I'm starting with non-correlated subqueries...

Vadim

#3Bruce Momjian
maillist@candle.pha.pa.us
In reply to: Vadim B. Mikheev (#2)
Re: [HACKERS] Re: subselects

I have not done:

correlated subquery column references
added Var->sublevels_up
gotten this to work in the rewrite system
have not added full CopyNode support

I will address these in the next few days.

OK, had some bugs, but now it works. Ran postmaster with full debug,
and saw proper values in SubLink structure. In fact, the optimizer
seems to pass this through fine, only to error out in the executor with
'unknown node.'

--
Bruce Momjian
maillist@candle.pha.pa.us

#4Bruce Momjian
maillist@candle.pha.pa.us
In reply to: Vadim B. Mikheev (#2)
Re: [HACKERS] Re: subselects

I have not done:

correlated subquery column references
added Var->sublevels_up
gotten this to work in the rewrite system

This item is done now:

have not added full CopyNode support

--
Bruce Momjian
maillist@candle.pha.pa.us

#5Bruce Momjian
maillist@candle.pha.pa.us
In reply to: Vadim B. Mikheev (#2)
Re: [HACKERS] Re: subselects

I have not done:

correlated subquery column references
added Var->sublevels_up
gotten this to work in the rewrite system
have not added full CopyNode support

OK, these are all done now.

--
Bruce Momjian
maillist@candle.pha.pa.us

#6Zeugswetter Andreas DBT
Andreas.Zeugswetter@telecom.at
In reply to: Bruce Momjian (#5)
Re: subselects

Bruce wrote:

I have completed adding Var.varlevelsup, and have added code to the
parser to properly set the field. It will allow correlated references
in the WHERE clause, but not in the target list.

select i2.ip1, i1.ip4 from nameip i1 where ip1 = (select ip1 from nameip
i2);
522: Table (i2) not selected in query.
select i1.ip4 from nameip i1 where ip1 = (select i1.ip1 from nameip i2);
284: A subquery has returned not exactly one row.
select i1.ip4 from nameip i1 where ip1 = (select i1.ip1 from nameip i2
where name='zeus');
2 row(s) retrieved.

Informix allows correlated references in the target list. It also allows
subselects in the target list as in:
select i1.ip4, (select i1.ip1 from nameip i2) from nameip i1;
284: A subquery has returned not exactly one row.
select i1.ip4, (select i1.ip1 from nameip i2 where name='zeus') from
nameip i1;
2 row(s) retrieved.

Is this what you were looking for ?

Andreas

#7Bruce Momjian
maillist@candle.pha.pa.us
In reply to: Zeugswetter Andreas DBT (#6)
Re: [HACKERS] Re: subselects

Bruce wrote:

I have completed adding Var.varlevelsup, and have added code to the
parser to properly set the field. It will allow correlated references
in the WHERE clause, but not in the target list.

select i2.ip1, i1.ip4 from nameip i1 where ip1 = (select ip1 from nameip
i2);
522: Table (i2) not selected in query.
select i1.ip4 from nameip i1 where ip1 = (select i1.ip1 from nameip i2);
284: A subquery has returned not exactly one row.
select i1.ip4 from nameip i1 where ip1 = (select i1.ip1 from nameip i2
where name='zeus');
2 row(s) retrieved.

Informix allows correlated references in the target list. It also allows
subselects in the target list as in:
select i1.ip4, (select i1.ip1 from nameip i2) from nameip i1;
284: A subquery has returned not exactly one row.
select i1.ip4, (select i1.ip1 from nameip i2 where name='zeus') from
nameip i1;
2 row(s) retrieved.

Is this what you were looking for ?

Andreas

Yes, I know other engines support subqueries and references in the
target list. I want to know if we are going to do that for 6.3.
Personally, I have never seen much use for it.

--
Bruce Momjian
maillist@candle.pha.pa.us

#8The Hermit Hacker
scrappy@hub.org
In reply to: Bruce Momjian (#7)
Re: [HACKERS] Re: subselects

On Wed, 21 Jan 1998, Bruce Momjian wrote:

Bruce wrote:

I have completed adding Var.varlevelsup, and have added code to the
parser to properly set the field. It will allow correlated references
in the WHERE clause, but not in the target list.

select i2.ip1, i1.ip4 from nameip i1 where ip1 = (select ip1 from nameip
i2);
522: Table (i2) not selected in query.
select i1.ip4 from nameip i1 where ip1 = (select i1.ip1 from nameip i2);
284: A subquery has returned not exactly one row.
select i1.ip4 from nameip i1 where ip1 = (select i1.ip1 from nameip i2
where name='zeus');
2 row(s) retrieved.

Informix allows correlated references in the target list. It also allows
subselects in the target list as in:
select i1.ip4, (select i1.ip1 from nameip i2) from nameip i1;
284: A subquery has returned not exactly one row.
select i1.ip4, (select i1.ip1 from nameip i2 where name='zeus') from
nameip i1;
2 row(s) retrieved.

Is this what you were looking for ?

Andreas

Yes, I know other engines support subqueries and references in the
target list. I want to know if we are going to do that for 6.3.
Personally, I have never seen much use for it.

If its easy to add in the next couple of days, sure, go for
it...but can someone explain to me *why* you would use a subselect in the
target list? I've actually never seen that before :9

#9Bruce Momjian
maillist@candle.pha.pa.us
In reply to: The Hermit Hacker (#8)
Re: [HACKERS] Re: subselects

Yes, I know other engines support subqueries and references in the
target list. I want to know if we are going to do that for 6.3.
Personally, I have never seen much use for it.

If its easy to add in the next couple of days, sure, go for
it...but can someone explain to me *why* you would use a subselect in the
target list? I've actually never seen that before :9

I have no idea why someone would want to do that. I have enough trouble
figuring out how the engine is going to execute normal queries, let
alone strange ones like that.

--
Bruce Momjian
maillist@candle.pha.pa.us