@ -2046,6 +2046,26 @@ selectDumpablePublicationObject(DumpableObject *dobj, Archive *fout)
DUMP_COMPONENT_ALL : DUMP_COMPONENT_NONE ;
}
/*
* selectDumpableStatisticsObject : policy - setting subroutine
* Mark an extended statistics object as to be dumped or not
*
* We dump an extended statistics object if the schema it ' s in and the table
* it ' s for are being dumped . ( This ' ll need more thought if statistics
* objects ever support cross - table stats . )
*/
static void
selectDumpableStatisticsObject ( StatsExtInfo * sobj , Archive * fout )
{
if ( checkExtensionMembership ( & sobj - > dobj , fout ) )
return ; /* extension membership overrides all else */
sobj - > dobj . dump = sobj - > dobj . namespace - > dobj . dump_contains ;
if ( sobj - > stattable = = NULL | |
! ( sobj - > stattable - > dobj . dump & DUMP_COMPONENT_DEFINITION ) )
sobj - > dobj . dump = DUMP_COMPONENT_NONE ;
}
/*
* selectDumpableObject : policy - setting subroutine
* Mark a generic dumpable object as to be dumped or not
@ -7291,6 +7311,7 @@ getExtendedStatistics(Archive *fout)
int i_stxname ;
int i_stxnamespace ;
int i_stxowner ;
int i_stxrelid ;
int i_stattarget ;
int i ;
@ -7302,11 +7323,11 @@ getExtendedStatistics(Archive *fout)
if ( fout - > remoteVersion < 130000 )
appendPQExpBufferStr ( query , " SELECT tableoid, oid, stxname, "
" stxnamespace, stxowner, (-1) AS stxstattarget "
" stxnamespace, stxowner, stxrelid, (-1) AS stxstattarget "
" FROM pg_catalog.pg_statistic_ext " ) ;
else
appendPQExpBufferStr ( query , " SELECT tableoid, oid, stxname, "
" stxnamespace, stxowner, stxstattarget "
" stxnamespace, stxowner, stxrelid, stx stattarget "
" FROM pg_catalog.pg_statistic_ext " ) ;
res = ExecuteSqlQuery ( fout , query - > data , PGRES_TUPLES_OK ) ;
@ -7318,6 +7339,7 @@ getExtendedStatistics(Archive *fout)
i_stxname = PQfnumber ( res , " stxname " ) ;
i_stxnamespace = PQfnumber ( res , " stxnamespace " ) ;
i_stxowner = PQfnumber ( res , " stxowner " ) ;
i_stxrelid = PQfnumber ( res , " stxrelid " ) ;
i_stattarget = PQfnumber ( res , " stxstattarget " ) ;
statsextinfo = ( StatsExtInfo * ) pg_malloc ( ntups * sizeof ( StatsExtInfo ) ) ;
@ -7332,10 +7354,12 @@ getExtendedStatistics(Archive *fout)
statsextinfo [ i ] . dobj . namespace =
findNamespace ( atooid ( PQgetvalue ( res , i , i_stxnamespace ) ) ) ;
statsextinfo [ i ] . rolname = getRoleName ( PQgetvalue ( res , i , i_stxowner ) ) ;
statsextinfo [ i ] . stattable =
findTableByOid ( atooid ( PQgetvalue ( res , i , i_stxrelid ) ) ) ;
statsextinfo [ i ] . stattarget = atoi ( PQgetvalue ( res , i , i_stattarget ) ) ;
/* Decide whether we want to dump it */
selectDumpableObject ( & ( statsextinfo [ i ] . dobj ) , fout ) ;
selectDumpableStatistics Object ( & ( statsextinfo [ i ] ) , fout ) ;
}
PQclear ( res ) ;