Browse Source

* Corrected statements for tables and system tables

git-svn-id: trunk@23445 -
michael 12 years ago
parent
commit
5df0afb5c6
1 changed files with 5 additions and 2 deletions
  1. 5 2
      packages/fcl-db/src/sqldb/postgres/pqconnection.pp

+ 5 - 2
packages/fcl-db/src/sqldb/postgres/pqconnection.pp

@@ -1077,6 +1077,9 @@ function TPQConnection.GetSchemaInfoSQL(SchemaType: TSchemaType;
 var s : string;
 var s : string;
 
 
 begin
 begin
+  // select * from information_schema.tables with 
+  // where table_schema [not] in ('pg_catalog','information_schema') may be better.
+  // But the following should work:
   case SchemaType of
   case SchemaType of
     stTables     : s := 'select '+
     stTables     : s := 'select '+
                           'relfilenode        as recno, '+
                           'relfilenode        as recno, '+
@@ -1086,7 +1089,7 @@ begin
                           '0                  as table_type '+
                           '0                  as table_type '+
                         'from pg_class c '+
                         'from pg_class c '+
                           'left join pg_namespace n on c.relnamespace=n.oid '+
                           'left join pg_namespace n on c.relnamespace=n.oid '+
-                        'where relkind=''r''' +
+                        'where (relkind=''r'') and not (nspname in (''pg_catalog'',''information_schema''))' +
                         'order by relname';
                         'order by relname';
 
 
     stSysTables  : s := 'select '+
     stSysTables  : s := 'select '+
@@ -1097,7 +1100,7 @@ begin
                           '0                  as table_type '+
                           '0                  as table_type '+
                         'from pg_class c '+
                         'from pg_class c '+
                           'left join pg_namespace n on c.relnamespace=n.oid '+
                           'left join pg_namespace n on c.relnamespace=n.oid '+
-                        'where relkind=''r'' and nspname=''pg_catalog'' ' + // only system tables
+                        'where (relkind=''r'') and nspname in ((''pg_catalog'',''information_schema'')) ' + // only system tables
                         'order by relname';
                         'order by relname';
     stColumns    : s := 'select '+
     stColumns    : s := 'select '+
                           'a.attnum           as recno, '+
                           'a.attnum           as recno, '+