Changes between Version 51 and Version 52 of FDORfc33


Ignore:
Timestamp:
Aug 3, 2009, 2:34:02 AM (15 years ago)
Author:
Aleck
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • FDORfc33

    v51 v52  
    1 = FDO RFC 33 - Enhanced SQL Command Support =
     1= FDO RFC 33 - Parameter Binding Direction Enhancement =
    22
    33This page contains an change request (RFC) for the FDO Open Source project. 
     
    99||RFC Template Version||(1.0)||
    1010||Submission Date|| April 9, 2009 ||
    11 ||Last Modified|| Greg Boone [[Timestamp]]||
    12 ||Author||Greg Boone, Orest Halustchak||
    13 ||RFC Status||Draft||
     11||Last Modified|| Aleck Sun [[Timestamp]]||
     12||Author||Aleck Sun||
     13||RFC Status||ready for review||
    1414||Implementation Status||Pending||
    1515||Proposed Milestone||3.5.0.0||
     
    2121||-1|| ||
    2222
     23== Overview ==
     24
     25The purpose of this RFC is to enhance the FDO API to improve parameter binding  support needed for SQL pass-through.
     26
    2327== Motivation ==
    2428
    25 The FDO API currently defines support for a SQL command that allows for pass-through execution of SQL statements either through !NonQuery execution of the SQL statement directly in the underlying Data Store, or through a query mechanism that returns a simple data reader listing the properties returned as a result of the SQL execution. The definition of the SQL command has remained fairly static over the last number of releases as primary development efforts have focused on extending other aspects of the FDO API, implementing new providers, etc. However, requirements for change to the SQL command have accumulated as RDBMS providers have implemented SQL support and clients have attempted to integrate use of the command into their applications in a seamless manner.
    26 
    27 One key request has been the desire to have the FDO API support SQL pass-through commands that return an FDO feature reader, referencing a proper FDO schema, not simply an FDO data reader. The feature reader will contain proper geometry properties, relations and associations. This enhancement is also intended to allow client applications that use FDO Feature Readers to code their applications in a generic manner so that data coming back from Select or SQL Pass Through statements can be processed in a uniform manner, thus reducing complexity, costs and time to implement.
    28 
    29 Other more SQL specific requirements have also arisen, including:
    30 
    31     - A need to allow a client to set the size of the fetch array an FDO provider will use when executing SQL statements
    32     - A need to specify an array of data values on which the command will execute
    33     - A need to specify the type of SQL command being executed; either straight text or stored procedure
    34     - A need to specify the direction in which parameters to the SQL command are to be used, specifically, Input, Output, Input/Output or Return parameters
    35 
    36 This RFC will outline changes that are required in the FDO API to accommodate these requests.
    37 
    38 == Overview ==
    39 
    40 In general, the intent of SQL pass-through is to deal with physical schemas. There is no parsing of the SQL statements, and what is identified are physical schema tables, columns, functions, commands, etc. The SQL statement can be any SQL command, not just select, but any DML (select, insert, update, delete) or any DDL (create, drop, alter, …). However, FDO feature readers deal with FDO logical schemas, which is at a different conceptual level. It’s mixing these levels that causes difficulty for applications using the FDO API. Applications are required to use different code pathways to handle select statement as opposed to direct SQL execution. If clients could use the result of both these types of operations in a generic routine or component, such as a Data Table or Symbolization packages, applications would be provided a much more seamless and dynamic mechanism on which they can build and extend their applications.
    41 
    42 To a certain degree, the current FDO feature reader implementation assumes an FDO class definition is directly related to the properties being returned. With physical schema SQL (let’s say just Select command), there isn’t necessarily any FDO class definition that applies. This is why currently the SQL command's Execute method returns a data reader, which handles any generically returned data. Note that the FDO select aggregates command doesn’t return a feature reader either, since it’s returning computed data.
    43 
    44 One response to this issue has been to suggest that providers reverse engineer the select results and attempt to find the FDO class definition (coming from a describe schema request) that matches it. Other suggestions have been to construct a class definition on the fly, one that would not result from a call to describe schema. If the select is from a single table, providers would find the class definition that is based on that table and use it. However, then matching up the columns being selected with the properties in the logical schema, there may be some slight differences. This would result in the mixing of physical schema and logical schema elements together. For example, class names that are not the same as table names, property names that are not the same as column names, the use of additional computed columns, inclusion of pkey columns, etc. Granted that in many cases, the logical and physical views would be virtually identical. However, since that cannot be guaranteed, the design that is adopted will have to be able to handle the general case.
    45 
    46 To account for these scenarios, providers will need to be modified to reverse engineer class definitions from the selected data and not attempt to match the select request to an existing FDO class. IN reality, FDO Providers will be required to handle this in any case since a generic SQL select may not match up at all with an existing FDO class. An example of this can be found when selecting from a table with an owner that is different from the connected data store. For example, Connect to data store called Denver and select from Boulder.Roads – the schema may or may not be similar to Denver.Roads. In these types of circumstances, providers should manufacture a new class definition unless they could determine with certainty that the select is on a table that matches one of the already defined FDO classes.
    47 
    48 In cases where the resulting columns come from an existing FDO feature table, a provider can return the class definition corresponding to that table. In cases where the columns come from an unknown table, a class definition can be constructed on the fly. By definition, the FDO class definition returned by a feature reader does not necessarily correspond exactly to an existing FDO class definition. Existing class definitions may contain the properties that were asked for in the Select command, plus additional computed properties. It is perfectly legal to return a constructed class definition, which is only valid for the select that was executed, and not usable for further updates or inserts.
    49 
    50 In the circumstance that a computed class is generated, the FDO class definition’s !IsComputed property will return true. In this manner, applications are able to distinguish the content of the feature reader responses coming from the providers and tailor their implementation accordingly. In such a situation, some care will also need to be given to the name of the generated FDO schema and class definitions. At this point no standards exist for naming auto-generated schema, class and property names. It would be beneficial if, as a result of this RFC, some uniform naming conventions could be adopted.
    51 
    52 Providers that do return feature readers from SQL commands will need to come up with the appropriate class definition that the feature reader could expose. Here are a few general use cases that should be used to guide provider implementation:
    53 
    54     - Select is against a table that has an existing class definition and the select returns the same information as defined by the class definition (e.g. select * from roads).
    55     - Select is against a table that has an existing class definition, but the select returns other information such as a subset of properties or additional computed properties. The FDO select command handles this type of case as well. The class definition returned by the feature reader includes the specific properties for that select.
    56     - Select is against a table that doesn’t have an existing class definition. Providers will be required to generate a temporary class definition.
    57     - Select is against a table that has an existing class definition, but the select is an aggregation that doesn’t return actual objects (e.g. select count(*), max(length) from roads). In this case it doesn’t make sense for the provider to return the same class name as for the underlying table since it is not actually returning road objects at all. This is basically another temporary class definition.
     29The current FDO API for parameter binding support for FdoISQLCommand is to add parameters through the FdoICommand interface. However, the current parameter value interface does not specify the parameter direction (in/out). To be able to use SQL stored procedures and functions, the ability to specify parameter direction for each of the parameters is necessary.  Thus, we will enhance the parameter value interface to specify the direction.
    5830
    5931== Requirements ==
    6032
    61 === FDO API ===
    62 
    63 In order to support the SQL pass-through objective outlined above, the FDO API will need to be modified to provide new functions to state that this support is enabled, and return an explicit FDO Feature Reader. It is preferential to add these new methods, as opposed to editing existing functionality, so that currently designed and running applications can continue to work as designed and implemented.
    64 
    65 ==== Command Capabilities ====
    66 
    67 An objective of this proposal is allow Provider the option to support SQL pass-through commands that return an FDO feature reader. If a provider decides to support this functionality, it can do so using the SupportsFeatureReaderFromSQLCommand method on the FdoICommandCapabilities interface.
    68 
    69 {{{
    70 /// \brief
    71 /// The FdoICommandCapabilities interface declares the feature
    72 /// provider's level of support for Commands.
    73 class FdoICommandCapabilities : public FdoIDisposable
    74 {
    75 public:
    76 ...
    77 ...
    78 ...
    79 
    80     /// \brief
    81     /// Determines if the provider supports the ExecuteFeatureReader
    82     /// function on the SQL Command.
    83     ///
    84     /// \return
    85     /// Returns true if the provider supports ExecuteFeatureReader.
    86     FDO_API virtual bool SupportsFeatureReaderFromSQLCommand();
    87 };
    88 }}}
    89 
     33In order to support the above item, the FDO API will be updated to add more methods.
    9034
    9135==== Parameter Direction Enumeration ====
    9236
    93 A new enumeration, !FdoParameterDirection, will be added to the FDO API for use within FDO Commands that utilize parameters. !FdoParameterDirection defines the direction in which the command will utilize the parameter upon execution. Parameter direction values are typically Input, Output, !InputOutput and Return, with the  default value is typically Input.
    94 
     37A new enumeration, !FdoParameterDirection, will be added to the FDO API for use within FDO Commands that utilize parameters. !FdoParameterDirection defines the direction in which the command will utilize the parameter upon execution. Parameter direction values are typically Input, Output, !InputOutput and Return, with the default value is typically Input.
    9538{{{
    9639/// \brief
     
    11053==== Parameter Value Interface ====
    11154
    112 The !FdoParameterValue class will be updated to add an additional property Direction, which will indicate the direction in which the parameter will be used within the context of command using the parameters within the context of their execution.
     55The !FdoParameterValue class will be updated to add an additional property Direction, which will indicate the direction in which the parameter will be used within the context of command if the parameter direction  is applicable for the command. If the command does not support parameter direction, or the parameter direction is fixed as for FDO Select, the direction will be ignored
    11356
    11457{{{
     
    12669    /// Sets the function direction of the parameter value.
    12770    /// Values can be Input, Output, InputOutput and Return.
     71    /// The default value for direction property in Input
    12872    ///
    12973    /// \param value
     
    14690}}}
    14791
    148 ==== SQL Command Type Enumeration ====
    14992
    150 A new enumeration, FdoSQLCommandType, will be added to the FDO API for use in the SQL Command. FdoSQLCommandType represents the type of SQL statement being sent to the provider for execution. The acceptable values of the enumeration are either Text or Stored Procedure. Stored Procedure are often executed as PL/SQL blocks.
    151 
    152 {{{
    153 /// \brief
    154 /// The FdoSQLCommandType enumeration defines the type of SQL
    155 /// statement that will be executed. Statements can either be
    156 /// simple Text or a represent a StoredProcedure.
    157 /// The default value is FdoSQLCommandType_Text.
    158 enum FdoSQLCommandType
    159 {
    160     FdoSQLCommandType_Text,
    161     FdoSQLCommandType_StoredProcedure
    162 };
    163 }}}
    164 
    165 ==== SQL Command Interface ====
    166 
    167 In order to allow Providers to return an FDO feature reader from the FDO SQL command, a new !ExecuteFeatureReader method will be added to the FdoISQLCommand interface. Providers that implement this level of functionality will need to implement this command and provide support for the use cases (which are not yet a definative list) listed above.
    168 
    169 The FdoISQLCommand interface will also be extended to support Fetch Size, Batch Parameter values and Command Types.
    170 
    171 {{{
    172 /// \brief
    173 /// The FdoISQLCommand interface defines the SQL command, which
    174 /// supports the execution of a SQL statement against an underlying
    175 /// RDBMS. Three execute methods are provided to distinguish between
    176 /// statements that return data versus those that execute
    177 /// non query type operations.
    178 class FdoISQLCommand : public FdoICommand
    179 {
    180 public:
    181 ...
    182 ...
    183 ...
    184 
    185     /// \brief
    186     /// Gets the fetch size of the data set used by
    187     /// the SQL command when executing statements against the
    188     /// underlying Data Store. This parameter is typically set
    189     /// in situations where large amout of data are expected
    190     /// when the SQL command is executed and providers need
    191     /// to minimize the number of Data Store round trips
    192     /// For example, fetch 100 rows in one execution step.
    193     ///
    194     /// \return
    195     /// Returns the SQL commands batch fetch size.
    196     ///
    197     FDO_API virtual FdoInt32 GetFetchSize() = 0;
    198 
    199     /// \brief
    200     /// Sets the fetch size of the data set used by
    201     /// the SQL command when executing statements against the
    202     /// underlying Data Store. This parameter is typically set
    203     /// in situations where large amout of data are expected
    204     /// when the SQL command is executed and providers need
    205     /// to minimize the number of Data Store round trips
    206     /// For example, fetch 100 rows in one execution step.
    207     ///
    208     /// \param value
    209     /// Input the SQL commands batch fetch size.
    210     ///
    211     /// \return
    212     /// Returns nothing
    213     ///
    214     FDO_API virtual void SetFetchSize(FdoInt32 fetchSize) = 0;
    215 
    216     /// \brief
    217     /// Gets the Batch ParameterValue Collection that will be used for optimized
    218     /// batch execution of multiple statements with a single command. Batch
    219     /// execution can be performed by using parameters for each of the property
    220     /// values, then adding collections of parameter values to the Batch
    221     /// ParameterValue Collection. Each Collection in the ParameterValue Collection
    222     /// should contain one FdoParameterValue for each of the parameters specified
    223     /// for property values.
    224     ///
    225     /// \return
    226     /// Returns FdoBatchParameterValueCollection
    227     ///
    228     FDO_API virtual FdoBatchParameterValueCollection* GetBatchParameterValues() = 0;
    229 
    230     /// \brief
    231     /// Gets the SQL statement type that is to be executed.
    232     ///
    233     /// \return
    234     /// Returns the SQL statement type.
    235     ///
    236     FDO_API virtual FdoSQLCommandType GetCommandType() = 0;
    237 
    238     /// \brief
    239     /// Sets the SQL statement type that is to be executed.
    240     ///
    241     /// \param value
    242     /// Input the SQL statement type.
    243     ///
    244     /// \return
    245     /// Returns nothing
    246     ///
    247     FDO_API virtual void SetCommandType(FdoSQLCommandType value) = 0;
    248 
    249     /// \brief
    250     /// Executes the SQL statement against the connection object and returns
    251     /// a Feature Reader exposing the physical data returned by the reader
    252     /// as FDO features. The Feature Reader may return a computed class that
    253     /// maps the physical schema elements, referenced by the execute, to a logical
    254     /// FDO schema.
    255     ///
    256     /// \return
    257     /// Returns an FDO feature reader referncing a computed class that
    258     /// maps the physical schema elements, referenced by the execute, to a logical
    259     /// FDO schema.
    260     ///
    261     FDO_API virtual FdoIFeatureReader* ExecuteFeatureReader();
    262 };
    263 }}}
    26493
    26594== Managed FDO API ==
     
    26998== Provider Implementation ==
    27099
    271 The question concerning which providers will need to be modified to support the SQL pass through enhancement is an open one and will depend on available development resources. I am fairly confident SQLite will be enahced to add the additional SQL Pass Through support. Adding support to SQL Server Spatial should also be high on the priority list. However, depending on resourcing, this may not be achievable in FDO 3.5.0. Support for ODBC and MySQL are considered nice to have and will be implemented if resourcing and funding can be obtained.
     100SQLite will be enahced to add the additional parameter direction support. Adding support to SQL Server Spatial should also be high on the priority list. However, depending on resourcing, this may not be achievable in FDO 3.5.0. Support for ODBC and MySQL are considered nice to have and will be implemented if resourcing and funding can be obtained.
    272101
    273102== Test Plan ==