Menu

#219 Bug - MsQSL and multiple schemas : List index out of bounds

7.1.4-Stable
closed
Bug Report
2020-09-29
2017-10-17
Nicoledit
No

Hi,

I have the following exception when I try to execute a query with version 7.0.3 and also with version 7.1.4 :

List index out of bounds (66)

The query :

SELECT * FROM SCHEMA1.TBLTEST

This message appear when you have 2 tables with the same name in 2 distinct schemas.

CREATE DATABASE [DBTEST]
GO
USE [DBTEST]
GO
CREATE SCHEMA [SCHEMA1]
GO
CREATE SCHEMA [SCHEMA2]
GO
CREATE TABLE [SCHEMA1].[TBLTEST](
    [ID_0] [int] NOT NULL
) ON [PRIMARY]
GO
CREATE TABLE [SCHEMA2].[TBLTEST](
    [ID_0] [int] NOT NULL
) ON [PRIMARY]
GO

In ZDbcDbLibMetadata.pas, function UncachedGetColumns (line 1893) the query doesn't care about the schema.
I was able to correct this problem by adding in the where clause something like this :

and o.uid=SCHEMA_ID(<SchemaPattern>)

There may be other requests that could cause problems (like the one in UncachedGetProcedureColumns on line 2711 and in UncachedGetProcedureColumns line 3005), but I didn't have the courage to check them all.

Thanks.

Discussion

  • marsupilami79

    marsupilami79 - 2017-10-18

    Hello Nicoledit,

    I assume, you added that condition to the second query, that retrieves information from syscolumns?

    with best regards,

    Jan

     
  • Nicoledit

    Nicoledit - 2017-10-18

    Hi,

    yes, you're right.

        with GetStatement.ExecuteQuery(
          Format('select c.colid, c.name, c.type, c.prec, c.scale, c.colstat, c.status, c.iscomputed '
    
          + ' from syscolumns c inner join sysobjects o '
          + ' on (o.id = c.id) '
          + ' where o.name COLLATE Latin1_General_CS_AS = %s and c.number=0 '
          + '     and o.uid=SCHEMA_ID(%s) '
          + ' order by colid ',
          [DeComposeObjectString(TableNamePattern),DeComposeObjectString(SchemaPattern)])) do
    
     
    • marsupilami79

      marsupilami79 - 2017-10-26

      Hello Nicloedit,

      I checked in your fix into the Zeos 7.2 branch. I will have to check the other UncachedGet* procedures at another time.

      With best regards,

      Jan

       
      • marsupilami79

        marsupilami79 - 2020-06-12

        Note: See [r4052] for the example implementation.

         

        Related

        Commit: [r4052]

  • EgonHugeist

    EgonHugeist - 2020-09-29
    • status: open --> closed
    • assigned_to: EgonHugeist
    • Type: --> Bug Report
     
  • EgonHugeist

    EgonHugeist - 2020-09-29

    Closed yet. Too old and resolved propably. If there are remaining things todo-> reopen plz.
    Regards, Michael

     

Log in to post a comment.

MongoDB Logo MongoDB