LucidDB / luciddb

DEFUNCT: See README
https://github.com/LucidDB/luciddb
Apache License 2.0
53 stars 24 forks source link

[FRG-251] UDX column list lookup doesn't see aliases in cursor #621

Closed dynamobi-build closed 12 years ago

dynamobi-build commented 12 years ago

[reporter="jvs", created="Sat, 20 Jan 2007 16:02:12 -0500 (GMT-05:00)"] select sname, creator, crc_value from table(
     applib.generate_crc(
        cursor(select schema_name as sname, creator from sys_root.dba_schemas),
        row(sname),
        true
     )
);

gives

Error: From line 4, column 13 to line 4, column 17: Column 'SNAME' not found in any table (state=,code=0)

This works fine:

select sname, creator, crc_value from table(
     applib.generate_crc(
        cursor(select schema_name as sname, creator from sys_root.dba_schemas)
     )
);

Whereas this one incorrectly passes validation, but then fails at execution:

select sname, creator, crc_value from table(
     applib.generate_crc(
        cursor(select schema_name as sname, creator from sys_root.dba_schemas),
        row(schema_name),
        true
     )
);

with

Error: column 'SCHEMA_NAME' not found (state=,code=0)

dynamobi-build commented 12 years ago

[author="zfong", created="Mon, 22 Jan 2007 09:34:52 -0500 (GMT-05:00)"] The problem seems to be that the select within the CURSOR() parameter is never registered with the parent query. Therefore, when the ROW() parameter trying resolving its argument, it uses a scope that doesn't reflect the actual projection result of the subselect within the CURSOR parameter.

dynamobi-build commented 12 years ago

[author="zfong", created="Mon, 22 Jan 2007 15:26:37 -0500 (GMT-05:00)"] Fix checked into Eigenchange 8566.

Queries containing CURSOR constructors now have a cursorScopes. The namespaces corresponding to the result of selects that are arguments to CURSOR constructors are now registered with these new cursorScopes. That way, when resolving column list parameters, we use that scope instead of the selectScopes. Using selectScopes is incorrect because it maps to the tables referenced within the select query, which effectively ignores any column aliases specified in the select.

Note that Eigenchange 8566 also contains the fix for FRG-250.