[ 
https://issues.apache.org/jira/browse/DERBY-6004?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13503844#comment-13503844
 ] 

Rick Hillegas commented on DERBY-6004:
--------------------------------------

Declaring the order of table function results could be as straightforward as 
just adding an ORDER BY clause to the CREATE FUNCTION statement. This would 
only be allowed if the parameter style were DERBY_JDBC_RESULT_SET. That, in 
turn, would fit this feature inside the existing Derby extension to table 
function SQL. So, something like the following should work:

create function getPrimaryKeys
(
        catalogName varchar( 128 ),
    schemaName varchar( 128 ),
    tableName varchar( 128 )
)
returns TABLE
  (
     table_cat varchar( 128 ),
     table_schema   varchar( 128 ),
     table_name   varchar( 128 ),
     column_name   varchar( 128 ),
     key_seq smallint,
     pk_name varchar( 128 )
  )
language java
parameter style DERBY_JDBC_RESULT_SET
reads sql data
order by table_cat, table_schema, table_name, key_seq
external name 'DBMetaData.getPrimaryKeys'
;

Other thoughts?
                
> Make it possible for table functions to declare that they return sorted 
> results and make the optimizer exploit this information.
> --------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: DERBY-6004
>                 URL: https://issues.apache.org/jira/browse/DERBY-6004
>             Project: Derby
>          Issue Type: Improvement
>          Components: SQL
>    Affects Versions: 10.10.0.0
>            Reporter: Rick Hillegas
>
> A derby-dev discussion has highlighted the need for table functions to return 
> sorted results which the optimizer can exploit. See 
> http://old.nabble.com/Have-Derby-Network-Server-having-an-out-of-memory-%28PermGen%29-to34704415.html#a34706722

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Reply via email to