Very strange SQL PostgreSQL

Our PostgreSQL SERVER version 8.4 has Strange SQL. This is similar to the system sql that the PG server is exploiting! I have no idea about this sql? Does anyone know this?

- Strange sql

SELECT NULL AS TABLE_CAT, 
       n.nspname AS TABLE_SCHEM, 
       c.relname AS TABLE_NAME,  
       CASE n.nspname ~ '^pg_' OR n.nspname = 'information_schema'  
          WHEN true THEN 
            CASE 
               WHEN n.nspname = 'pg_catalog' OR n.nspname = 'information_schema' THEN 
                 CASE c.relkind   
                   WHEN 'r' THEN 'SYSTEM TABLE'   
                   WHEN 'v' THEN 'SYSTEM VIEW'   
                   WHEN 'i' THEN 'SYSTEM INDEX'   
                   ELSE NULL   
                 END  
               WHEN n.nspname = 'pg_toast' THEN 
                 CASE c.relkind 
                   WHEN 'r' THEN 'SYSTEM TOAST TABLE'   
                   WHEN 'i' THEN 'SYSTEM TOAST INDEX'   
                   ELSE NULL   
                 END  
               ELSE 
                 CASE c.relkind   
                   WHEN 'r' THEN 'TEMPORARY TABLE'   
                   WHEN 'i' THEN 'TEMPORARY INDEX'   
                   ELSE NULL   
                 END  
             END  
             WHEN false THEN 
               CASE c.relkind  
                 WHEN 'r' THEN 'TABLE'  
                 WHEN 'i' THEN 'INDEX'  
                 WHEN 'S' THEN 'SEQUENCE'  
                 WHEN 'v' THEN 'VIEW'  
                 ELSE NULL  
               END  
             ELSE NULL  
           END  AS TABLE_TYPE, 
           d.description AS REMARKS  
      FROM pg_catalog.pg_namespace n, 
           pg_catalog.pg_class c  
 LEFT JOIN pg_catalog.pg_description d ON (c.oid = d.objoid 
                                      AND d.objsubid = 0)  
 LEFT JOIN pg_catalog.pg_class dc ON (d.classoid = dc.oid 
                                 AND dc.relname='pg_class'
+5
source share
2 answers

This is part of the implementation getTables()in the JDBC postgresql driver.

Google codesearch will lead you to this.

+7
source

This problem also occurs when your application uses some kind of connection manager, such as c3p0. C3P0 has an option preferredTestQuerythat defines the request that must be completed before acquiring a connection from the connection pool.

, - sql-, preferredTestQuery=SELECT 1

+1

All Articles