mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-12-09 19:57:20 +01:00
fcl-db: postgresql: catalog_name for GetSchemaInfoSQL
git-svn-id: trunk@23200 -
This commit is contained in:
parent
f9dbcbd0c3
commit
30f96442ca
@ -988,48 +988,46 @@ var s : string;
|
||||
begin
|
||||
case SchemaType of
|
||||
stTables : s := 'select '+
|
||||
'relfilenode as recno, '+
|
||||
'''' + DatabaseName + ''' as catalog_name, '+
|
||||
'nspname as schema_name, '+
|
||||
'relname as table_name, '+
|
||||
'0 as table_type '+
|
||||
'from '+
|
||||
'pg_class c left join pg_namespace n on c.relnamespace=n.oid '+
|
||||
'where '+
|
||||
'relkind=''r''' +
|
||||
'relfilenode as recno, '+
|
||||
'current_database() as catalog_name, '+
|
||||
'nspname as schema_name, '+
|
||||
'relname as table_name, '+
|
||||
'0 as table_type '+
|
||||
'from pg_class c '+
|
||||
'left join pg_namespace n on c.relnamespace=n.oid '+
|
||||
'where relkind=''r''' +
|
||||
'order by relname';
|
||||
|
||||
stSysTables : s := 'select '+
|
||||
'relfilenode as recno, '+
|
||||
'''' + DatabaseName + ''' as catalog_name, '+
|
||||
'nspname as schema_name, '+
|
||||
'relname as table_name, '+
|
||||
'0 as table_type '+
|
||||
'from '+
|
||||
'pg_class c left join pg_namespace n on c.relnamespace=n.oid '+
|
||||
'where '+
|
||||
'relkind=''r'' and nspname=''pg_catalog'' ' + // only system tables
|
||||
'relfilenode as recno, '+
|
||||
'current_database() as catalog_name, '+
|
||||
'nspname as schema_name, '+
|
||||
'relname as table_name, '+
|
||||
'0 as table_type '+
|
||||
'from pg_class c '+
|
||||
'left join pg_namespace n on c.relnamespace=n.oid '+
|
||||
'where relkind=''r'' and nspname=''pg_catalog'' ' + // only system tables
|
||||
'order by relname';
|
||||
stColumns : s := 'select '+
|
||||
'a.attnum as recno, '+
|
||||
''''' as catalog_name, '+
|
||||
''''' as schema_name, '+
|
||||
'c.relname as table_name, '+
|
||||
'a.attname as column_name, '+
|
||||
'0 as column_position, '+
|
||||
'0 as column_type, '+
|
||||
'0 as column_datatype, '+
|
||||
''''' as column_typename, '+
|
||||
'0 as column_subtype, '+
|
||||
'0 as column_precision, '+
|
||||
'0 as column_scale, '+
|
||||
'a.atttypmod as column_length, '+
|
||||
'not a.attnotnull as column_nullable '+
|
||||
'from '+
|
||||
' pg_class c, pg_attribute a '+
|
||||
'WHERE '+
|
||||
// This can lead to problems when case-sensitive tablenames are used.
|
||||
'(c.oid=a.attrelid) and (a.attnum>0) and (not a.attisdropped) and (upper(c.relname)=''' + Uppercase(SchemaObjectName) + ''') ' +
|
||||
'a.attnum as recno, '+
|
||||
'current_database() as catalog_name, '+
|
||||
'nspname as schema_name, '+
|
||||
'c.relname as table_name, '+
|
||||
'a.attname as column_name, '+
|
||||
'0 as column_position, '+
|
||||
'0 as column_type, '+
|
||||
'0 as column_datatype, '+
|
||||
''''' as column_typename, '+
|
||||
'0 as column_subtype, '+
|
||||
'0 as column_precision, '+
|
||||
'0 as column_scale, '+
|
||||
'a.atttypmod as column_length, '+
|
||||
'not a.attnotnull as column_nullable '+
|
||||
'from pg_class c '+
|
||||
'join pg_attribute a on c.oid=a.attrelid '+
|
||||
'left join pg_namespace n on c.relnamespace=n.oid '+
|
||||
// This can lead to problems when case-sensitive tablenames are used.
|
||||
'where (a.attnum>0) and (not a.attisdropped) and (upper(c.relname)=''' + Uppercase(SchemaObjectName) + ''') '+
|
||||
'order by a.attname';
|
||||
else
|
||||
DatabaseError(SMetadataUnavailable)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user