Return-Path: Delivered-To: apmail-db-derby-dev-archive@www.apache.org Received: (qmail 63861 invoked from network); 24 Jan 2005 19:43:57 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur-2.apache.org with SMTP; 24 Jan 2005 19:43:57 -0000 Received: (qmail 75623 invoked by uid 500); 24 Jan 2005 19:43:56 -0000 Delivered-To: apmail-db-derby-dev-archive@db.apache.org Received: (qmail 75595 invoked by uid 500); 24 Jan 2005 19:43:56 -0000 Mailing-List: contact derby-dev-help@db.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: list-post: List-Id: Reply-To: "Derby Development" Delivered-To: mailing list derby-dev@db.apache.org Received: (qmail 75581 invoked by uid 99); 24 Jan 2005 19:43:56 -0000 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests= X-Spam-Check-By: apache.org Received-SPF: neutral (hermes.apache.org: local policy) Received: from pimout1-ext.prodigy.net (HELO pimout1-ext.prodigy.net) (207.115.63.77) by apache.org (qpsmtpd/0.28) with ESMTP; Mon, 24 Jan 2005 11:43:55 -0800 Received: from [67.122.109.167] (adsl-67-122-109-167.dsl.pltn13.pacbell.net [67.122.109.167]) by pimout1-ext.prodigy.net (8.12.10 milter /8.12.10) with ESMTP id j0OJhFGR269422 for ; Mon, 24 Jan 2005 14:43:32 -0500 Message-ID: <41F55095.8060801@Mutagen.Net> Date: Mon, 24 Jan 2005 11:46:29 -0800 From: Jack Klebanoff User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.1) Gecko/20040707 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Derby Development Subject: Re: On DERBY-107 : ODBC Metadata functions References: <41F18707.4060700@golux.com> In-Reply-To: <41F18707.4060700@golux.com> X-Enigmail-Version: 0.85.0.0 X-Enigmail-Supports: pgp-inline, pgp-mime Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N Army wrote: > [snip] > > DISCUSSION: > > The question is now this: what's the best/preferred way to propagate > this ODBC/JDBC duality from the "SystemProcedures.java" file to the > corresponding methods in > org.apache.derby.impl.jdbc.EmbedDatabaseMetadata.java (hereafter > referred to as "EDM")? > > Option I: > > Add new SQL statements, such as "getColumnsForODBC", to the existing > metadata.properties file, as described in the proposal for DERBY-107. > Then, since EDM has to know which version of a given SQL statement to > execute--for example, should it call the regular "getColumns" version, > or should it call the new "getColumnsForODBC" version?--we could add > new methods (such as "setForODBC()") to EDM that could be used by > SystemProcedures to indicate (to EDM) that ODBC metadata should be > returned, intead of JDBC metadata. Note that, since SystemProcedures > is in a different package than EDM, the new methods on EDM would (I > think) have to be _public_. > > Regarding this approach, one must ask: > > [ #1 **** COMMUNITY INPUT? **** ] > > What's the general attitude toward adding public methods to a Derby > class that is implementing a specific JDBC class? In the context of > this discussion, is it or is it not acceptable/desireable to add > Derby-specific public methods to a class like > EmbedDatabaseMetadata.java, which is an implementation of > java.sql.DatabaseMetaData? Technically speaking, I don't think the > addition of public classes breaks the JDBC standard (so long as we > aren't telling people that they can import EmbedDatabaseMetadata in > their apps--which we aren't), but I'm curious as to whether there's a > "good programming practice" here that the Derby community would like > to (or already does?) hold to? > > [ #1 **** End **** ] I would prefer that the ODBC support not be put in the EmbedDatabaseMetadata class. Then applications that do not use ODBC do not have to load ODBC support into their JVM. > > Option II: > > Add new SQL statements, such as "getColumnsForODBC", to the existing > metadata.properties file, as described in the proposal for DERBY-107. > Then we could extend the EDM class with a new, simple class that sets > ODBC-related state, and modify EDM to check the state and execute the > appropriate statements. For example, we could add a protected > variable "forODBC" to EDM, default it to "false", and then set it to > true in the extended class for ODBC. EDM would then check the flag > and execute the corresponding metadata statement. The presumption > here is that SystemProcedures would check for the ODBC indicator and, > if found, use an instance of the new subclass for the metadata calls, > instead of using an instance of the existing EDM. > > This approach allows us to avoid adding new (non-JDBC) public classes > to EDM, at the cost of creating another (albeit fairly simple) > metadata class. > > With this approach, we could even go further and add another file, say > "odbc_metadata.properties" that holds the ODBC metadata statements > (instead of adding them to the existing metadata.properties file). > The new subclass could then load _that_ file instead of the current > metadata.properties file, which gives us a nice separation of > functionality: all of the ODBC code cleanly separated from the JDBC > code. Of course, that could be a bad thing, too, since 1) we'd then > have TWO metadata files to worry about in the codeline, instead of > just one, which introduces room for error if/when metadata-related > processing changes occur in Derby, and 2) we'd have to duplicate any > SQL statements that are the same for ODBC and JDBC (ex. several of the > "getBestRowIdentifier" queries) in both files. So I'm guessing we > wouldn't want to create another metadata file...but I thought I'd > bring it up, just in case. > > Option III: > > Create some kind of internal VTI for ODBC metadata and use that. I > have to admit that I don't know too much about how VTIs work, but > Kathey gave me some places to look, so I'm going to read up. > Apparently, we can execute the same metadata SQL statements that > already exist for JDBC, then use a VTI to "massage" the result set > into something that complies with ODBC specifications. This might be > a good choice given that most of the differences between ODBC and JDBC > are in the types of the columns returned. For example, JDBC might say > that any String will do, whereas ODBC will say it has to be VARCHAR. > In that case, a literal value ' ' will be fine for JDBC, but since > it's treated as a CHAR value by Derby, it would be breaking ODBC > standard. With a VTI, we could theoretically accomplish the same > things that we'd be doing with new SQL statements--such as casting ' ' > to VARCHAR in this particular case. Other modifications we'd have to > implement include casting certain integer columns to smallints, and > replacing null values in JDBC (such as for "sql_data_type" and > "buffer_length" columns) to legal values (neither column is supposed > to be null for ODBC). > > Upside to this is that we still only have a single metadata.properties > file, which (theoretically) makes maintenance of metadata procedures > easier. As I don't know much about VTIs, I can't say what else this > approach would require, but it seems safe to say that it would at > least require another class to serve as the ODBC VTI. How that would > tie into the SystemProcedures and EmbedDatabaseMetadata classes, I > don't know yet... > > So... > > [ #2 **** COMMUNITY INPUT? **** ] > I think that the VTI option offers the most flexibility. VTIs are not limited to massaging the results of standard JDBC metadata queries, they can query the system tables in an entirely different way if necessary. They are not loaded until necessary so JDBC only servers are not burdened with ODBC support. [snip] Jack