GPRE's REDUCED TO

33 views
Skip to first unread message

Adriano dos Santos Fernandes

unread,
May 15, 2024, 7:40:01 AMMay 15
to firebir...@googlegroups.com
Hi!

AFAIU, GPRE's REDUCED TO is equivalent to SQL DISTINCT.

But GPRE, nor the engine, disallow the use of fields not present in the
REDUCED TO list.

And there is code doing it, for example:

---
AutoCacheRequest request(tdbb, irq_ch_f_dpd, IRQ_REQUESTS);

FOR(REQUEST_HANDLE request)
DEP IN RDB$DEPENDENCIES
WITH DEP.RDB$DEPENDED_ON_NAME EQ dpdo_name
AND DEP.RDB$DEPENDED_ON_TYPE = dpdo_type
AND DEP.RDB$FIELD_NAME EQ field_name
AND DEP.RDB$PACKAGE_NAME EQUIV NULLIF(packageName.c_str(), '')
REDUCED TO DEP.RDB$DEPENDENT_NAME
{
// If the found object is also being deleted, there's no dependency

if (!find_depend_in_dfw(tdbb, DEP.RDB$DEPENDENT_NAME,
DEP.RDB$DEPENDENT_TYPE,
0, transaction))
{
++dep_counts[DEP.RDB$DEPENDENT_TYPE];
}
}
END_FOR
---

Where DEP.RDB$DEPENDENT_TYPE is used.

Is it a bug?


Adriano

Dimitry Sibiryakov

unread,
May 15, 2024, 7:50:05 AMMay 15
to firebir...@googlegroups.com
Adriano dos Santos Fernandes wrote 15.05.2024 13:39:
> Where DEP.RDB$DEPENDENT_TYPE is used.
>
> Is it a bug?

Not sure whether it can be considered as a bug but documentation has such
example so it is either bug in documentation as well or... other bug in
documentation.

> The following statement displays only the names of states in which the capitol is not the largest city:
>
> for s in states cross c in cities over state cross
> cs in cities with cs.state = c.state and
> cs.city = s.capitol and
> cs.population < c.population
> sorted by s.state
> reduced to s.state, s.capitol
> writeln (s.state_name, ’ contains cities larger than ’, s.capitol);
> end_for;
> commit;
> finish;
> end.

Taking into account that GPRE is frozen, better not to fix this.

--
WBR, SD.

Ann Harrison

unread,
May 15, 2024, 11:24:50 AMMay 15
to firebir...@googlegroups.com
Oh, wow! Serious ancient history.

That's the ancient language that DEC and InterBase supported while it, SQL, and QUEL were all considered
plausible relational languages.  By all means, leave it alone.  By 1987, the fight was over and SQL had won. 

By all means leave it alone. 

--
You received this message because you are subscribed to the Google Groups "firebird-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to firebird-deve...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/firebird-devel/8925b748-0827-45aa-9191-0697e89281d8%40ibphoenix.com.

Adriano dos Santos Fernandes

unread,
May 16, 2024, 5:45:57 AMMay 16
to firebir...@googlegroups.com
So we have, like MySQL's select un-grouped and un-agreggated column
(select a, b from t group by a), an unexplainable feature? Or is just
undefined behavior?

The idea is not to fix GPRE, but to understand, fix and not add more
bugs to Firebird queries using GPRE.


Adriano

Alex Peshkoff

unread,
May 16, 2024, 6:21:12 AMMay 16
to firebir...@googlegroups.com
In particular example s.state looks like PK column in states. If yes -
this query has well defined behavior and no ambiguties.
Reply all
Reply to author
Forward
0 new messages