package test;

import java.sql.*;

public class Test19 implements Test.Case
{
    private String error;
    private Exception ex;

    public boolean run() throws Exception {
        Class.forName("org.sqlite.JDBC");
        Connection conn = DriverManager.getConnection("jdbc:sqlite:");
        Statement stat = conn.createStatement();
        stat.executeUpdate(
            "create table test19 (id integer primary key, fn, sn);");
        stat.executeUpdate("create view test19view as select * from test19;");
        stat.close();

        DatabaseMetaData meta = conn.getMetaData();
        if (meta == null) { error = "expected meta data"; return false; }

        // check getTables
        ResultSet rs = meta.getTables(null, null, null, null);
        if (rs == null) { error = "expected getTables RS"; return false; }
        if (!rs.next()) { error = "expected table"; return false; }
        if (!"test19".equals(rs.getString("TABLE_NAME"))) {
            error = "bad table name"; return false; }
        if (!"test19".equals(rs.getString(3))) {
            error = "bad table name (ordered)"; return false; }
        if (!"TABLE".equals(rs.getString("TABLE_TYPE"))) {
            error = "bad table type"; return false; }
        if (!"TABLE".equals(rs.getString(4))) {
            error = "bad table type (ordered)"; return false; }

        if (!rs.next()) { error = "expected view"; return false; }
        if (!"test19view".equals(rs.getString("TABLE_NAME"))) {
            error = "bad view name"; return false; }
        if (!"VIEW".equals(rs.getString("TABLE_TYPE"))) {
            error = "bad view type"; return false; }

        // check getTableTypes
        rs = meta.getTableTypes();
        if (!rs.next()) { error = "expected type table"; return false; }
        if (!"TABLE".equals(rs.getString("TABLE_TYPE"))) {
            error =" bad table type for 'table'"; return false; }
        if (!rs.next()) { error = "expected type view"; return false; }
        if (!"VIEW".equals(rs.getString("TABLE_TYPE"))) {
            error =" bad table type for 'view'"; return false; }

        conn.close();

        return true;
    }

    public String name() { return "DatabaseMetaData"; }
    public String error() { return error; }
    public Exception ex() { return ex; }
}

@@ -649,32 +649,55 @@
 eturn false; %7D%0A%0A
+        ResultSet rs;%0A%0A
         // check
@@ -715,26 +715,16 @@
         
-ResultSet 
 rs = met
@@ -1644,32 +1644,364 @@
 eturn false; %7D%0A%0A
+        rs = meta.getTables(null, null, %22bob%22, null);%0A        if (rs.next()) %7B error = %22unexpected results%22; return false; %7D%0A%0A        rs = meta.getTables(null, null, %22test19%22, null);%0A        if (!rs.next()) %7B error = %22results missing%22; return false; %7D%0A        if (rs.next()) %7B error = %22unexpected second results%22; return false; %7D%0A%0A%0A
         // check
@@ -2370,32 +2370,32 @@
 ABLE_TYPE%22))) %7B%0A
-
             erro
@@ -2436,32 +2436,455 @@
 eturn false; %7D%0A%0A
+        // check getTypeInfo%0A        rs = meta.getTypeInfo();%0A        String%5B%5D types = new String%5B%5D %7B%0A            %22BLOB%22, %22INTEGER%22, %22NULL%22, %22REAL%22, %22TEXT%22 %7D;%0A        for (int i=0; i %3C types.length; i++) %7B%0A            if (!rs.next()) %7B error = %22expected type %22 + i; return false; %7D%0A            if (!types%5Bi%5D.equals(rs.getString(%22TYPE_NAME%22))) %7B%0A                error = %22type %22 + i + %22 mismatch%22; return false; %7D%0A        %7D%0A%0A
         conn.clo

test for getTypeInfo()