BUG PostgreSQL SchemaName with Solution
Posted: 15.06.2011, 18:53
A bug was found on the consultation of the postgres schemas that I could see the visible table schema, there were two identical table in different schemas
Even after setting:
- SET TO search_path public;
the problem remained.
Example:
(Schema, table) historic.test
(Schema, table) public.test
In a regular SQL.
- Select * from test
the component associated to the table and not in historic.test public.teste that this case is correct.
############################
SOLUTION TO THE PROBLEM
Zeos 6.1.5 version:
############################
FileName: ZDbcPostgreSqlMetadata.pas
Function:
TZPostgreSQLDatabaseMetadata.GetColumns function (Catalog: string;
SchemaPattern: string; TableNamePattern: string;
ColumnNamePattern: string): IZResultSet;
.....
SQL: = SQL + 'AND n.nspname LIKE''' + EscapeQuotes (SchemaPattern) +'''';
----------------------------
Replace with:
----------------------------
if SchemaPattern <>''then begin
SQL: = SQL + 'AND n.nspname LIKE''' + EscapeQuotes (SchemaPattern) +'''';
end else begin
SQL: = SQL + 'AND pg_table_is_visible (c.oid)';
end;
############################
SOLUTION TO THE PROBLEM
Zeos 7.0.0 version:
############################
FileName: ZDbcPostgreSqlMetadata.pas
Function:
TZPostgreSQLDatabaseMetadata.UncachedGetColumns function (const Catalog: string;
const SchemaPattern: string; const TableNamePattern: string;
const ColumnNamePattern: string): IZResultSet;
......
if SchemaPattern <>''then
begin
SQL: = SQL + 'AND n.nspname LIKE'
+ EscapeString (SchemaPattern);
end;
----------------------------
Replace with:
----------------------------
if SchemaPattern <>''then begin
SQL: = SQL + 'AND n.nspname LIKE''' + EscapeString (SchemaPattern) +'''';
end else begin
SQL: = SQL + 'AND pg_table_is_visible (c.oid)';
end;
Please fix this for future versions.
Force ZeosLib the project:)
[']s
Even after setting:
- SET TO search_path public;
the problem remained.
Example:
(Schema, table) historic.test
(Schema, table) public.test
In a regular SQL.
- Select * from test
the component associated to the table and not in historic.test public.teste that this case is correct.
############################
SOLUTION TO THE PROBLEM
Zeos 6.1.5 version:
############################
FileName: ZDbcPostgreSqlMetadata.pas
Function:
TZPostgreSQLDatabaseMetadata.GetColumns function (Catalog: string;
SchemaPattern: string; TableNamePattern: string;
ColumnNamePattern: string): IZResultSet;
.....
SQL: = SQL + 'AND n.nspname LIKE''' + EscapeQuotes (SchemaPattern) +'''';
----------------------------
Replace with:
----------------------------
if SchemaPattern <>''then begin
SQL: = SQL + 'AND n.nspname LIKE''' + EscapeQuotes (SchemaPattern) +'''';
end else begin
SQL: = SQL + 'AND pg_table_is_visible (c.oid)';
end;
############################
SOLUTION TO THE PROBLEM
Zeos 7.0.0 version:
############################
FileName: ZDbcPostgreSqlMetadata.pas
Function:
TZPostgreSQLDatabaseMetadata.UncachedGetColumns function (const Catalog: string;
const SchemaPattern: string; const TableNamePattern: string;
const ColumnNamePattern: string): IZResultSet;
......
if SchemaPattern <>''then
begin
SQL: = SQL + 'AND n.nspname LIKE'
+ EscapeString (SchemaPattern);
end;
----------------------------
Replace with:
----------------------------
if SchemaPattern <>''then begin
SQL: = SQL + 'AND n.nspname LIKE''' + EscapeString (SchemaPattern) +'''';
end else begin
SQL: = SQL + 'AND pg_table_is_visible (c.oid)';
end;
Please fix this for future versions.
Force ZeosLib the project:)
[']s