diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2012-04-06 15:02:35 -0400 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2012-04-06 15:02:35 -0400 |
commit | 263d9de66b867b7800fac82c222e004b795b724a (patch) | |
tree | 4ecc70b6e75339304b2829a2ced3cb084f0aacdb /src/include/foreign/fdwapi.h | |
parent | 8cb53654dbdb4c386369eb988062d0bbb6de725e (diff) |
Allow statistics to be collected for foreign tables.
ANALYZE now accepts foreign tables and allows the table's FDW to control
how the sample rows are collected. (But only manual ANALYZEs will touch
foreign tables, for the moment, since among other things it's not very
clear how to handle remote permissions checks in an auto-analyze.)
contrib/file_fdw is extended to support this.
Etsuro Fujita, reviewed by Shigeru Hanada, some further tweaking by me.
Diffstat (limited to 'src/include/foreign/fdwapi.h')
-rw-r--r-- | src/include/foreign/fdwapi.h | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/src/include/foreign/fdwapi.h b/src/include/foreign/fdwapi.h index 854f17755c4..6bf3a5e2306 100644 --- a/src/include/foreign/fdwapi.h +++ b/src/include/foreign/fdwapi.h @@ -50,20 +50,32 @@ typedef void (*ReScanForeignScan_function) (ForeignScanState *node); typedef void (*EndForeignScan_function) (ForeignScanState *node); +typedef int (*AcquireSampleRowsFunc) (Relation relation, int elevel, + HeapTuple *rows, int targrows, + double *totalrows, + double *totaldeadrows, + BlockNumber *totalpages); + +typedef AcquireSampleRowsFunc (*AnalyzeForeignTable_function) (Relation relation); + /* * FdwRoutine is the struct returned by a foreign-data wrapper's handler * function. It provides pointers to the callback functions needed by the * planner and executor. * - * Currently, all functions must be supplied. Later there may be optional - * additions. It's recommended that the handler initialize the struct with - * makeNode(FdwRoutine) so that all fields are set to zero. + * More function pointers are likely to be added in the future. Therefore + * it's recommended that the handler initialize the struct with + * makeNode(FdwRoutine) so that all fields are set to NULL. This will + * ensure that no fields are accidentally left undefined. */ typedef struct FdwRoutine { NodeTag type; + /* + * These functions are required. + */ GetForeignRelSize_function GetForeignRelSize; GetForeignPaths_function GetForeignPaths; GetForeignPlan_function GetForeignPlan; @@ -72,6 +84,12 @@ typedef struct FdwRoutine IterateForeignScan_function IterateForeignScan; ReScanForeignScan_function ReScanForeignScan; EndForeignScan_function EndForeignScan; + + /* + * These functions are optional. Set the pointer to NULL for any + * that are not provided. + */ + AnalyzeForeignTable_function AnalyzeForeignTable; } FdwRoutine; |