From 92d9769b643ca042605e8a3881cd8e209477bdc4 Mon Sep 17 00:00:00 2001 From: Ansgar Becker Date: Mon, 17 Nov 2014 18:01:10 +0000 Subject: [PATCH] PostgreSQL: Make TPGConnection.FetchDbObjects compatible to pre-9.0 servers. See http://www.heidisql.com/forum.php?t=16996 --- source/dbconnection.pas | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/source/dbconnection.pas b/source/dbconnection.pas index 287f285a..1857ecbe 100644 --- a/source/dbconnection.pas +++ b/source/dbconnection.pas @@ -4218,7 +4218,7 @@ procedure TPGConnection.FetchDbObjects(db: String; var Cache: TDBObjectList); var obj: TDBObject; Results: TDBQuery; - tp, SchemaTable: String; + tp, SchemaTable, SizeClause: String; begin // Tables, views and procedures Results := nil; @@ -4228,8 +4228,13 @@ begin SchemaTable := 'QUOTE_IDENT(t.TABLE_SCHEMA) || '+EscapeString('.')+' || QUOTE_IDENT(t.TABLE_NAME)' else SchemaTable := EscapeString(FQuoteChar)+' || t.TABLE_SCHEMA || '+EscapeString(FQuoteChar+'.'+FQuoteChar)+' || t.TABLE_NAME || '+EscapeString(FQuoteChar); + // See http://www.heidisql.com/forum.php?t=16996 + if ServerVersionInt >= 90000 then + SizeClause := 'pg_table_size('+SchemaTable+')' + else + SizeClause := 'NULL'; Results := GetResults('SELECT *,'+ - ' pg_table_size('+SchemaTable+') AS data_length,'+ + ' '+SizeClause+' AS data_length,'+ ' pg_relation_size('+SchemaTable+') AS index_length,'+ ' c.reltuples, obj_description(c.oid) AS comment'+ ' FROM '+QuoteIdent('information_schema')+'.'+QuoteIdent('tables')+' AS t'+