https://bugs.documentfoundation.org/show_bug.cgi?id=67302

--- Comment #20 from Pavankumar Batchu <[email protected]> ---
For this bug,I made changes in following files:

1. pq_xtables.cxx Changes
#include <connectivity/dbtools.hxx>

OUString tableName = ::dbtools::composeTableNameForSelect(
    m_origin,
    catalog,
    escapePostgreSQLIdentifier(schema),
    escapePostgreSQLIdentifier(name));

m_values.push_back(Any(Reference<css::beans::XPropertySet>(pTable)));
map[tableName] = tableIndex;

2. pq_resultsetmetadata.cxx Changes
if (tables.is()) {
    const OUString name(getTableName(1));
    const OUString schema(getSchemaName(1));
    const OUString composedName = schema.isEmpty() ?
        ::dbtools::composeTableNameForSelect(
            m_connection,
            "",  
            "",  // empty schema
            escapePostgreSQLIdentifier(name)) :
        ::dbtools::composeTableNameForSelect(
            m_connection,
            "",  // catalog
            escapePostgreSQLIdentifier(schema),
            escapePostgreSQLIdentifier(name));

    tables->getByName(composedName) >>= m_table;
}

3. pq_tools.hxx Changes
inline OUString escapePostgreSQLIdentifier(const OUString& identifier) {
    if (identifier.isEmpty())
        return identifier;

    if (identifier.indexOf('.') != -1 || 
        identifier.indexOf(' ') != -1 ||
        identifier.indexOf('"') != -1 ||
        identifier != identifier.toAsciiLowerCase()) 
    {
        return "\"" + identifier.replaceAll("\"", "\"\"") + "\"";
    }
    return identifier;
}

4. pq_xtable.cxx Changes

void Table::rename(const OUString& newName)
{
    if (!::dbtools::splitComposedTableName(newName, &newSchemaName,
&newTableName, nullptr))
    {
        if (newName.indexOf('.') >= 0) {
            splitConcatenatedIdentifier(newName, &newSchemaName,
&newTableName);
        } else {
            newTableName = newName;
            newSchemaName = schema;
        }
    }

    OUString fullOldName = ::dbtools::composeTableNameForSelect(
        m_conn, "", oldSchema, oldName);
    OUString fullNewName = ::dbtools::composeTableNameForSelect(
        m_conn, "", newSchemaName, newTableName);

}

5.pq_xview.cxx Changes
(Same changes as pq_xtable.cxx applied to view rename operations)

6. pq_xviews.cxx Changes
void Views::refresh()
{
    while (rs->next()) {
        OUString table = xRow->getString(2);
        OUString schema = xRow->getString(1);
        OUString command = xRow->getString(3);

        rtl::Reference<View> pView = new View(m_xMutex, m_origin, m_pSettings);
        OUString displayName = ::dbtools::composeTableNameForSelect(
            m_origin,
            catalog,
            escapePostgreSQLIdentifier(schema),
            escapePostgreSQLIdentifier(table));

        m_values.push_back(Any(Reference<css::beans::XPropertySet>(pView)));
        map[displayName] = viewIndex++;
    }
    m_name2index.swap(map);
}

Please tell me if I am going in right direction.

-- 
You are receiving this mail because:
You are the assignee for the bug.

Reply via email to