~maria-captains/mariadb-java-client/trunk

« back to all changes in this revision

Viewing changes to src/main/java/org/mariadb/jdbc/MySQLDatabaseMetaData.java

  • Committer: Vladislav Vaintroub
  • Date: 2013-02-02 12:35:04 UTC
  • Revision ID: wlad@montyprogram.com-20130202123504-i0oociz534qp0xk0
CONJ-16 : Introduced nullCatalogMeansCurrent parameter, compatibly to ConnectorJ.

There are applications that depend on ConnectorJ default behavior, even if this behavior deviates from standard.

Show diffs side-by-side

added added

removed removed

Lines of Context:
127
127
            return "NULL";    
128
128
        return "'" + Utils.escapeString(s, connection.noBackslashEscapes) + "'";
129
129
    }
130
 
    
 
130
 
 
131
    /**
 
132
     * Generate part of the information schema query that restricts catalog names
 
133
     * In the driver, catalogs is the equivalent to MySQL schemas.
 
134
     * 
 
135
     * @param columnName - column name in the information schema table
 
136
     * @param catalog - catalog name.
 
137
     * 
 
138
     * This driver does not (always) follow JDBC standard for following special values, due 
 
139
     * to ConnectorJ compatibility
 
140
     * 
 
141
     * 1. empty string ("") - matches current catalog (i.e database).JDBC standard says
 
142
     * only tables without catalog should be returned - such tables do not exist in MySQL.
 
143
     * If there is no current catalog, then empty string matches any catalog.
 
144
     *   
 
145
     * 2. null  - if nullCatalogMeansCurrent=true (which is the default), then the handling is the same
 
146
     * as for "" . i.e return current catalog.
 
147
     *   
 
148
     * JDBC-conforming way would be to match any catalog with null parameter. This 
 
149
     * can be switched with nullCatalogMeansCurrent=false in the connection URL.
 
150
     * 
 
151
     * @return part of SQL query ,that restricts search for the catalog.
 
152
     */
131
153
    String catalogCond(String columnName, String catalog) {
132
 
        if (catalog == null){
 
154
        if (catalog == null && connection.nullCatalogMeansCurrent) {
 
155
            /* Treat null catalog as current */
 
156
            catalog = "";
 
157
        }
 
158
        
 
159
        if (catalog == null) {
133
160
            return "(1 = 1)"; 
134
161
        }
135
162
        if (catalog.equals("")) {