Hachioji.pm #11
     2011/12/3
About Me

Hideaki Ohno
  Twitter : @hide_o_55
  Hatena: id:hide_o_55
  github: http://hideo55.github.com/
Theme
Theme
DB
DB
MySQL
PostgreSQL
PostgreSQL
Foreign Data Wrapper
       Perl
Foreign Data Wrapper

    SQL   MED(Management of External
Data)   PostgreSQL

           PostgreSQL



PostgreSQL 9.1

MySQL, Twitter, IMAP ...
Foreign Data Wrapper
typedef FdwPlan *(*PlanForeignScan_function) (Oid foreigntableid,
                                                          PlannerInfo
*root,
                                                        RelOptInfo
*baserel);
typedef void (*ExplainForeignScan_function) (ForeignScanState *node,
                                                    struct ExplainState
*es);
typedef void (*BeginForeignScan_function) (ForeignScanState *node,
                                                       int eflags);
typedef TupleTableSlot *(*IterateForeignScan_function) (ForeignScanState
*node);
typedef void (*ReScanForeignScan_function) (ForeignScanState *node);
typedef void (*EndForeignScan_function) (ForeignScanState *node);
typedef struct FdwRoutine
{
    NodeTag     type;
    PlanForeignScan_function PlanForeignScan;
    ExplainForeignScan_function ExplainForeignScan;
    BeginForeignScan_function BeginForeignScan;
    IterateForeignScan_function IterateForeignScan;
    ReScanForeignScan_function ReScanForeignScan;
    EndForeignScan_function EndForeignScan;
} FdwRoutine;
perl_fdw

Datum perl_fdw_handler( PG_FUNCTION_ARGS) {
    FdwRoutine *fdwroutine = makeNode(FdwRoutine);

    fdwroutine->PlanForeignScan = perlPlanForeignScan;
    fdwroutine->ExplainForeignScan = perlExplainForeignScan;
    fdwroutine->BeginForeignScan = perlBeginForeignScan;
    fdwroutine->IterateForeignScan = perlIterateForeignScan;
    fdwroutine->ReScanForeignScan = perlReScanForeignScan;
    fdwroutine->EndForeignScan = perlEndForeignScan;

    PG_RETURN_POINTER(fdwroutine);
}
perl_fdw
perl_fdw

CREATE EXTENSION perl_fdw;

CREATE SERVER perl_hoge FOREIGN
DATA WRAPPER perl_fdw
options (
   wrapper 'Foo::Bar'
);
perl_fdw

CREATE FOREIGN TABLE hoge (
   id INTEGER,
   name text
) SERVER perl_hoge OPTIONS(
   foo ‘bar’
);
m(__)m
PGXN(PostgreSQL Extension Network)


       Chrome Extension PGXN Search


https://github.com/hideo55/chrome-pgxn-search

Hachiojipm11

  • 1.
  • 2.
    About Me Hideaki Ohno Twitter : @hide_o_55 Hatena: id:hide_o_55 github: http://hideo55.github.com/
  • 3.
  • 4.
  • 5.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
    Foreign Data Wrapper SQL MED(Management of External Data) PostgreSQL PostgreSQL PostgreSQL 9.1 MySQL, Twitter, IMAP ...
  • 12.
    Foreign Data Wrapper typedefFdwPlan *(*PlanForeignScan_function) (Oid foreigntableid, PlannerInfo *root, RelOptInfo *baserel); typedef void (*ExplainForeignScan_function) (ForeignScanState *node, struct ExplainState *es); typedef void (*BeginForeignScan_function) (ForeignScanState *node, int eflags); typedef TupleTableSlot *(*IterateForeignScan_function) (ForeignScanState *node); typedef void (*ReScanForeignScan_function) (ForeignScanState *node); typedef void (*EndForeignScan_function) (ForeignScanState *node); typedef struct FdwRoutine { NodeTag type; PlanForeignScan_function PlanForeignScan; ExplainForeignScan_function ExplainForeignScan; BeginForeignScan_function BeginForeignScan; IterateForeignScan_function IterateForeignScan; ReScanForeignScan_function ReScanForeignScan; EndForeignScan_function EndForeignScan; } FdwRoutine;
  • 13.
    perl_fdw Datum perl_fdw_handler( PG_FUNCTION_ARGS){ FdwRoutine *fdwroutine = makeNode(FdwRoutine); fdwroutine->PlanForeignScan = perlPlanForeignScan; fdwroutine->ExplainForeignScan = perlExplainForeignScan; fdwroutine->BeginForeignScan = perlBeginForeignScan; fdwroutine->IterateForeignScan = perlIterateForeignScan; fdwroutine->ReScanForeignScan = perlReScanForeignScan; fdwroutine->EndForeignScan = perlEndForeignScan; PG_RETURN_POINTER(fdwroutine); }
  • 14.
  • 15.
    perl_fdw CREATE EXTENSION perl_fdw; CREATESERVER perl_hoge FOREIGN DATA WRAPPER perl_fdw options ( wrapper 'Foo::Bar' );
  • 16.
    perl_fdw CREATE FOREIGN TABLEhoge ( id INTEGER, name text ) SERVER perl_hoge OPTIONS( foo ‘bar’ );
  • 17.
  • 18.
    PGXN(PostgreSQL Extension Network) Chrome Extension PGXN Search https://github.com/hideo55/chrome-pgxn-search