Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

A very Strange SQL of PostgreSQL

Tags:

sql

postgresql

There is a Strange SQL in our PostgreSQL SERVER, version 8.4. It is looks like a system sql which excuted by PG server ! I have no idea about this sql? 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'
like image 809
francs Avatar asked Mar 28 '11 02:03

francs


People also ask

Which is best SQL or PostgreSQL?

From the above comparisons, PostgreSQL trumps SQL Server in several scenarios. Not only is it open-source and free, but it also has several features that are easily available and can be implemented automatically, unlike Microsoft SQL Server. Moreover, PostgreSQL has a more suitable concurrency management system.

What is special about PostgreSQL?

It is a highly stable database management system, backed by more than 20 years of community development which has contributed to its high levels of resilience, integrity, and correctness. PostgreSQL is used as the primary data store or data warehouse for many web, mobile, geospatial, and analytics applications.

What type of SQL is PostgreSQL?

What is PostgreSQL? PostgreSQL is a powerful, open source object-relational database system that uses and extends the SQL language combined with many features that safely store and scale the most complicated data workloads.

Is PostgreSQL outdated?

The PostgreSQL Global Development Group supports a major version for 5 years after its initial release. After its five year anniversary, a major version will have one last minor release containing any fixes and will be considered end-of-life (EOL) and no longer supported.


1 Answers

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

Update

While Google Code Search was retired a few years after this answer was originally posted, you can see this logic today in the pgjdbc "meta data" sources.

like image 65
pilcrow Avatar answered Sep 21 '22 20:09

pilcrow