853 |
853 |
QString fieldElem = QString::fromUtf8( PQgetvalue( oidResult, 0, 2 ) );
|
854 |
854 |
int fieldSize = QString::fromUtf8( PQgetvalue( oidResult, 0, 3 ) ).toInt();
|
855 |
855 |
|
856 |
|
if ( tableoid >= 0 )
|
|
856 |
if ( tableoid > 0 )
|
857 |
857 |
{
|
858 |
|
sql = QString( "SELECT attnum FROM pg_attribute WHERE attrelid=%1 AND attname=%2" )
|
|
858 |
sql = QString( "SELECT d.description FROM pg_description AS d JOIN pg_attribute AS a ON d.objoid=a.attrelid"
|
|
859 |
" WHERE d.objoid=%1 AND a.attname=%2 AND objsubid=a.attnum" )
|
859 |
860 |
.arg( tableoid ).arg( quotedValue( fieldName ) );
|
860 |
861 |
|
861 |
862 |
Result tresult = connectionRO->PQexec( sql );
|
862 |
|
QString attnum = QString::fromUtf8( PQgetvalue( tresult, 0, 0 ) );
|
863 |
|
|
864 |
|
sql = QString( "SELECT description FROM pg_description WHERE objoid=%1 AND objsubid=%2" )
|
865 |
|
.arg( tableoid ).arg( attnum );
|
866 |
|
|
867 |
|
tresult = connectionRO->PQexec( sql );
|
868 |
863 |
if ( PQntuples( tresult ) > 0 )
|
869 |
864 |
fieldComment = QString::fromUtf8( PQgetvalue( tresult, 0, 0 ) );
|
870 |
865 |
}
|
... | ... | |
2940 |
2935 |
for ( i = 0; i < PQnfields( res ); i++ )
|
2941 |
2936 |
{
|
2942 |
2937 |
int tableoid = PQftable( res, i );
|
2943 |
|
if ( tableoid >= 0 )
|
|
2938 |
if ( tableoid > 0 )
|
2944 |
2939 |
{
|
2945 |
2940 |
oidValue = QString::number( tableoid );
|
2946 |
2941 |
break;
|
... | ... | |
3000 |
2995 |
valid = false;
|
3001 |
2996 |
QStringList log;
|
3002 |
2997 |
|
|
2998 |
QString tableName;
|
|
2999 |
QString schemaName;
|
|
3000 |
|
3003 |
3001 |
Result result;
|
3004 |
3002 |
QString sql;
|
3005 |
3003 |
|
3006 |
|
if ( !isQuery )
|
|
3004 |
// get the geometry column's schema and table
|
|
3005 |
if ( isQuery )
|
3007 |
3006 |
{
|
|
3007 |
sql = QString( "select %1 from %2 LIMIT 0" )
|
|
3008 |
.arg( quotedIdentifier( geometryColumn ) )
|
|
3009 |
.arg( mQuery );
|
|
3010 |
|
|
3011 |
result = connectionRO->PQexec( sql );
|
|
3012 |
|
|
3013 |
int tableoid = PQftable( result, 0 );
|
|
3014 |
if ( tableoid > 0 )
|
|
3015 |
{
|
|
3016 |
sql = QString( "SELECT t.relname, n.nspname FROM pg_class AS t JOIN pg_namespace AS n ON t.relnamespace = n.oid"
|
|
3017 |
" WHERE t.oid=%1" )
|
|
3018 |
.arg( tableoid );
|
|
3019 |
|
|
3020 |
result = connectionRO->PQexec( sql );
|
|
3021 |
if ( PQntuples( result ) > 0 )
|
|
3022 |
{
|
|
3023 |
tableName = QString::fromUtf8( PQgetvalue( result, 0, 0 ) );
|
|
3024 |
schemaName = QString::fromUtf8( PQgetvalue( result, 0, 1 ) );
|
|
3025 |
}
|
|
3026 |
}
|
|
3027 |
}
|
|
3028 |
else
|
|
3029 |
{
|
|
3030 |
tableName = mTableName;
|
|
3031 |
schemaName = mSchemaName;
|
|
3032 |
}
|
|
3033 |
|
|
3034 |
if ( !tableName.isEmpty() )
|
|
3035 |
{
|
3008 |
3036 |
sql = QString( "select type,srid from geometry_columns"
|
3009 |
3037 |
" where f_table_name=%1 and f_geometry_column=%2 and f_table_schema=%3" )
|
3010 |
|
.arg( quotedValue( mTableName ) )
|
|
3038 |
.arg( quotedValue( tableName ) )
|
3011 |
3039 |
.arg( quotedValue( geometryColumn ) )
|
3012 |
|
.arg( quotedValue( mSchemaName ) );
|
|
3040 |
.arg( quotedValue( schemaName ) );
|
3013 |
3041 |
|
3014 |
3042 |
QgsDebugMsg( "Getting geometry column: " + sql );
|
3015 |
3043 |
|