Skip to content

DatabaseMetaData.getFunctions(…) should accept a null schema #165

@desruisseaux

Description

@desruisseaux

The JDBC Javadoc of DatabaseMetaData.getFunctions(…) said:

schemaPattern - a schema name pattern; must match the schema name as it is stored in the database; "" retrieves those without a schema; null means that the schema name should not be used to narrow the search

Therefore, setting the schemaPattern argument to null in the following code snippet should return all functions. However, that code prints nothing with DuckDB 1.2.1:

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;

public class TestDuckDB {
    public static void main(String[] args) throws Exception {
        try (Connection c = DriverManager.getConnection("jdbc:duckdb:/...something.db")) {
            try (ResultSet r = c.getMetaData().getFunctions(null, null, "%")) {
                while (r.next()) {
                    System.out.println(r.getString("FUNCTION_NAME"));
                }
            }
        }
    }
}

If we replace the schemaPattern argument (the last null) by "%" in the call to getFunctions(…), it works. The fix for this issue may be simply to replace null by "%" internally in the JDBC driver.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions