/*
 * DBeaver - Universal Database Manager
 * Copyright (C) 2010-2015 Serge Rieder (serge@jkiss.org)
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License (version 2)
 * as published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License along
 * with this program; if not, write to the Free Software Foundation, Inc.,
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 */
package org.jkiss.dbeaver.ext.postgresql.model.jdbc;

import org.jkiss.dbeaver.model.exec.jdbc.JDBCResultSet;
import org.jkiss.dbeaver.model.impl.jdbc.JDBCUtils;
import org.jkiss.dbeaver.model.impl.jdbc.exec.JDBCResultSetMetaDataImpl;

import java.lang.reflect.InvocationTargetException;
import java.sql.SQLException;

/**
 * PostgreResultSetMetaDataImpl
 */
public class PostgreResultSetMetaDataImpl extends JDBCResultSetMetaDataImpl
{

    public PostgreResultSetMetaDataImpl(JDBCResultSet resultSet) throws SQLException {
        super(resultSet);
    }

    @Override
    public String getSchemaName(int column) throws SQLException {
        String schemaName;
        try {
            schemaName = (String)original.getClass().getMethod("getBaseSchemaName", Integer.TYPE).invoke(original, column);
        } catch (InvocationTargetException e) {
            throw new SQLException("Error getting schema name", e.getTargetException());
        } catch (Exception e) {
            throw new SQLException("Error getting schema name", e);
        }
        return JDBCUtils.normalizeIdentifier(schemaName);
    }

}

@@ -1870,10 +1870,559 @@
 %0A    %7D%0A%0A
+    @Override%0A    public String getTableName(int column) throws SQLException %7B%0A        String tableName;%0A        try %7B%0A            tableName = (String)original.getClass().getMethod(%22getBaseTableName%22, Integer.TYPE).invoke(original, column);%0A        %7D catch (InvocationTargetException e) %7B%0A            throw new SQLException(%22Error getting table name%22, e.getTargetException());%0A        %7D catch (Exception e) %7B%0A            throw new SQLException(%22Error getting table name%22, e);%0A        %7D%0A        return JDBCUtils.normalizeIdentifier(tableName);%0A    %7D%0A
 %7D%0A

Obtain table name from postgre RS metadata.