SlideShare ist ein Scribd-Unternehmen logo
1 von 21
Downloaden Sie, um offline zu lesen
SQL/MED and PostgreSQL

        Peter Eisentraut


         FOSDEM 2009




    Peter Eisentraut   SQL/MED and PostgreSQL
What is SQL/MED?




    MED = Management of External Data
    Methods to access non-SQL data in SQL
    SQL/MED is ISO/IEC 9075-9




                  Peter Eisentraut   SQL/MED and PostgreSQL
Applications and Use Cases




     Connect to other DBMS (like DBI-Link)
     Connect to other PostgreSQL instances (like dblink)
     Read non-SQL data (CSV, XML)
     Manage data stored in file system
         Images
         Video
         Engineering data




                     Peter Eisentraut   SQL/MED and PostgreSQL
Why do we care?




     Powerful new functionality
     Unifies existing ad-hoc solutions.
     Implementation has begun in PostgreSQL 8.4.
     Several people have plans for PostgreSQL 8.5.
     See status report later in this presentation.




                      Peter Eisentraut   SQL/MED and PostgreSQL
Advantages




    Schema integration
    Access control
    Standard API
    Centralized control through DBMS




                     Peter Eisentraut   SQL/MED and PostgreSQL
Two Parts




  Wrapper interface Access other data sources, represent them
              as SQL tables
    Datalinks Manage files stored in file system, represent file
              references as column values




                      Peter Eisentraut   SQL/MED and PostgreSQL
Wrapper Interface Concepts




     Define a foreign table . . .
     On a foreign server . . .
     Accessed through a foreign-data wrapper




                       Peter Eisentraut   SQL/MED and PostgreSQL
Example: Foreign-Data Wrappers

  Foreign-data wrapper (FDW): a library that can communicate
  with external data sources

  CREATE FOREIGN DATA WRAPPER foosql
    LIBRARY ’foosql_fdw.so’
    LANGUAGE C;

      PostgreSQL communicates with foosql_fdw.so using
      SQL/MED FDW API.
      foosql_fdw.so communicates with FooSQL server
      using their own protocol.
      In theory, FooSQL, Inc. would ship foosql_fdw.so with
      their product.
      In practice, this is not so wide-spread.


                       Peter Eisentraut   SQL/MED and PostgreSQL
Example: Foreign Servers



  Foreign server: an instance of an external data source
  accessed through a FDW

  CREATE SERVER extradb
    FOREIGN DATA WRAPPER foosql
    OPTIONS (host ’foo.example.com’, port ’2345’);

      Options depend on FDW.




                       Peter Eisentraut   SQL/MED and PostgreSQL
Example: User Mappings



  User mapping: additional user-specific options for a foreign
  server

  CREATE USER MAPPING FOR peter SERVER extradb
    OPTIONS (user ’peter’, password ’seKret’);

      Options depend on FDW.
      Putting connection options into server vs. user mapping is
      a matter of convention or convenience.




                       Peter Eisentraut   SQL/MED and PostgreSQL
Example: Foreign Tables


  Foreign table: a table stored on a foreign server

  CREATE FOREIGN TABLE data
    SERVER extradb
    OPTIONS (tablename ’DATA123’);

      Now you can read and write the table as if it were local
      (depending on FDW features/implementation).
      Options specified for FDW, server, and user mapping are
      used as connection parameters (depending on FDW).




                       Peter Eisentraut   SQL/MED and PostgreSQL
Another Wrapper Interface Example

  Possible setup for accessing HTML tables stored in a web site
  as SQL tables:

  CREATE FOREIGN DATA WRAPPER htmlfile
    LIBRARY ’html_fdw.so’
    LANGUAGE C;

  CREATE SERVER intranetweb
    FOREIGN DATA WRAPPER htmlfile
    OPTIONS (baseurl ’http://intranet/data’);

  CREATE FOREIGN TABLE data
    SERVER intranetweb
    OPTIONS (path ’foo.html#//table[@id="table1"]’);



                      Peter Eisentraut   SQL/MED and PostgreSQL
More Wrapper Interface Features




     GRANT and REVOKE
     IMPORT FOREIGN SCHEMA
     CREATE ROUTINE MAPPING




                  Peter Eisentraut   SQL/MED and PostgreSQL
Status in PostgreSQL 8.4



  PostgreSQL 8.4 has:
      CREATE FOREIGN DATA WRAPPER, but no library
      support
      CREATE SERVER
      CREATE USER MAPPING
      ACL support
      Used by dblink and PL/Proxy to store connection
      information




                        Peter Eisentraut   SQL/MED and PostgreSQL
Status Worldwide




     IBM DB2 provides a full implementation
     MySQL and Farrago use some syntax elements
     No other known implementations




                    Peter Eisentraut   SQL/MED and PostgreSQL
Plan & Issues




     Write wrapper library and foreign table support for
     PostgreSQL 8.5
     Supply a few foreign-data wrapper libraries with
     PostgreSQL 8.5
     Use standard wrapper interface API or design our own
     API?




                      Peter Eisentraut   SQL/MED and PostgreSQL
Datalink Concepts




     Files are referenced through a new DATALINK type
     Database system has control over external files
     No need to store file contents in database system
     Access control and integrity mechanisms of DBMS can be
     extended to file system




                     Peter Eisentraut   SQL/MED and PostgreSQL
Example: Simple DATALINK Type


  CREATE TABLE persons (
     id      integer,
     name    text,
     picture DATALINK [NO LINK CONTROL]
  );

  INSERT INTO persons VALUES (
     1,
     ’Jon Doe’,
     DLVALUE(’file://some/where/1.jpg’)
  );

     This variant doesn’t do anything except store URLs.


                     Peter Eisentraut   SQL/MED and PostgreSQL
DATALINK Attributes


  Selection of additional possible attributes for DATALINK fields:
  FILE LINK CONTROL Datalink value must reference an
             existing file.
  INTEGRITY ALL Referenced files can only be renamed or
            deleted through SQL.
  INTEGRITY SELECTIVE Referenced files can be renamed or
            deleted through SQL or directly.
  READ PERMISSION DB Database system controls file read
           permission.
  RECOVERY YES PITR applies to referenced files.
  ON UNLINK DELETE File is deleted from file sytem when
            deleted from database.



                       Peter Eisentraut   SQL/MED and PostgreSQL
How to Implement Datalinks



  How to implement this?
      OS-dependent
      File-system dependent
      Application-dependent
      Lots of hocus pocus needed
      Possibilities: kernel modules, LD_PRELOAD, extended FS
      attributes
      Don’t hold your breath.




                      Peter Eisentraut   SQL/MED and PostgreSQL
Summary

 SQL/MED:
     Wrapper interface
     Datalinks
     Substantial support planned for PostgreSQL 8.5 and
     beyond
 References:
     http://wiki.postgresql.org/wiki/
     SqlMedConnectionManager (Martin Pihlak)
     http://www.sigmod.org/record/issues/0103/
     JM-Sta.pdf (Jim Melton et al.)
     http://www.sigmod.org/record/issues/0209/
     jimmelton.pdf (Jim Melton et al.)
     ISO/IEC 9075-9:2008 (“SQL/MED”)


                    Peter Eisentraut   SQL/MED and PostgreSQL

Weitere ähnliche Inhalte

Was ist angesagt?

Less18 moving data
Less18 moving dataLess18 moving data
Less18 moving data
Imran Ali
 
Harrison fisk masteringinnodb-diagnostics
Harrison fisk masteringinnodb-diagnosticsHarrison fisk masteringinnodb-diagnostics
Harrison fisk masteringinnodb-diagnostics
guest8212a5
 

Was ist angesagt? (20)

Sqlmap
SqlmapSqlmap
Sqlmap
 
TSQL in SQL Server 2012
TSQL in SQL Server 2012TSQL in SQL Server 2012
TSQL in SQL Server 2012
 
PostgreSQL Database Slides
PostgreSQL Database SlidesPostgreSQL Database Slides
PostgreSQL Database Slides
 
All Oracle-dba-interview-questions
All Oracle-dba-interview-questionsAll Oracle-dba-interview-questions
All Oracle-dba-interview-questions
 
Less18 moving data
Less18 moving dataLess18 moving data
Less18 moving data
 
Advanced SQL injection to operating system full control (slides)
Advanced SQL injection to operating system full control (slides)Advanced SQL injection to operating system full control (slides)
Advanced SQL injection to operating system full control (slides)
 
Oracle DBA interview_questions
Oracle DBA interview_questionsOracle DBA interview_questions
Oracle DBA interview_questions
 
576 oracle-dba-interview-questions
576 oracle-dba-interview-questions576 oracle-dba-interview-questions
576 oracle-dba-interview-questions
 
Building your own search engine with Apache Solr
Building your own search engine with Apache SolrBuilding your own search engine with Apache Solr
Building your own search engine with Apache Solr
 
Recent Additions to Lucene Arsenal
Recent Additions to Lucene ArsenalRecent Additions to Lucene Arsenal
Recent Additions to Lucene Arsenal
 
Impala SQL Support
Impala SQL SupportImpala SQL Support
Impala SQL Support
 
Oracle Database 11g Release 2 - XMLDB New Features
Oracle Database 11g Release 2 - XMLDB New FeaturesOracle Database 11g Release 2 - XMLDB New Features
Oracle Database 11g Release 2 - XMLDB New Features
 
Using Apache Solr
Using Apache SolrUsing Apache Solr
Using Apache Solr
 
Postgresql
PostgresqlPostgresql
Postgresql
 
XMLDB Building Blocks And Best Practices - Oracle Open World 2008 - Marco Gra...
XMLDB Building Blocks And Best Practices - Oracle Open World 2008 - Marco Gra...XMLDB Building Blocks And Best Practices - Oracle Open World 2008 - Marco Gra...
XMLDB Building Blocks And Best Practices - Oracle Open World 2008 - Marco Gra...
 
DBA 3 year Interview Questions
DBA 3 year Interview QuestionsDBA 3 year Interview Questions
DBA 3 year Interview Questions
 
Developers’ mDay 2021: Bogdan Kecman, Oracle – MySQL nekad i sad
Developers’ mDay 2021: Bogdan Kecman, Oracle – MySQL nekad i sadDevelopers’ mDay 2021: Bogdan Kecman, Oracle – MySQL nekad i sad
Developers’ mDay 2021: Bogdan Kecman, Oracle – MySQL nekad i sad
 
Harrison fisk masteringinnodb-diagnostics
Harrison fisk masteringinnodb-diagnosticsHarrison fisk masteringinnodb-diagnostics
Harrison fisk masteringinnodb-diagnostics
 
Oracle Introduction
Oracle Introduction Oracle Introduction
Oracle Introduction
 
New Stuff in the Oracle PL/SQL Language
New Stuff in the Oracle PL/SQL LanguageNew Stuff in the Oracle PL/SQL Language
New Stuff in the Oracle PL/SQL Language
 

Ähnlich wie SQL/MED and PostgreSQL

Dev Sql Beyond Relational
Dev Sql Beyond RelationalDev Sql Beyond Relational
Dev Sql Beyond Relational
rsnarayanan
 
Oracle 10g introduction
Oracle 10g introductionOracle 10g introduction
Oracle 10g introduction
sagaroceanic11
 

Ähnlich wie SQL/MED and PostgreSQL (20)

Federated Queries Across Both Different Storage Mediums and Different Data En...
Federated Queries Across Both Different Storage Mediums and Different Data En...Federated Queries Across Both Different Storage Mediums and Different Data En...
Federated Queries Across Both Different Storage Mediums and Different Data En...
 
Foreign Data Wrappers and You with Postgres
Foreign Data Wrappers and You with PostgresForeign Data Wrappers and You with Postgres
Foreign Data Wrappers and You with Postgres
 
SQL Complete Tutorial. All Topics Covered
SQL Complete Tutorial. All Topics CoveredSQL Complete Tutorial. All Topics Covered
SQL Complete Tutorial. All Topics Covered
 
Accessing external hadoop data sources using pivotal e xtension framework (px...
Accessing external hadoop data sources using pivotal e xtension framework (px...Accessing external hadoop data sources using pivotal e xtension framework (px...
Accessing external hadoop data sources using pivotal e xtension framework (px...
 
my sql
my sqlmy sql
my sql
 
PGConf.ASIA 2019 Bali - A step towards SQL/MED - DATALINK - Gilles Darold
PGConf.ASIA 2019 Bali - A step towards SQL/MED - DATALINK - Gilles DaroldPGConf.ASIA 2019 Bali - A step towards SQL/MED - DATALINK - Gilles Darold
PGConf.ASIA 2019 Bali - A step towards SQL/MED - DATALINK - Gilles Darold
 
Practical OData
Practical ODataPractical OData
Practical OData
 
Dev Sql Beyond Relational
Dev Sql Beyond RelationalDev Sql Beyond Relational
Dev Sql Beyond Relational
 
PostgreSQL 9.5 Foreign Data Wrappers
PostgreSQL 9.5 Foreign Data WrappersPostgreSQL 9.5 Foreign Data Wrappers
PostgreSQL 9.5 Foreign Data Wrappers
 
Tech Days09 Sqldev
Tech Days09 SqldevTech Days09 Sqldev
Tech Days09 Sqldev
 
SQL Server 2008 for Developers
SQL Server 2008 for DevelopersSQL Server 2008 for Developers
SQL Server 2008 for Developers
 
SQL Server 2008 for .NET Developers
SQL Server 2008 for .NET DevelopersSQL Server 2008 for .NET Developers
SQL Server 2008 for .NET Developers
 
Trivadis TechEvent 2017 PostgreSQL für die (Orakel) DBA by Ludovico Caldara
Trivadis TechEvent 2017 PostgreSQL für die (Orakel) DBA by Ludovico CaldaraTrivadis TechEvent 2017 PostgreSQL für die (Orakel) DBA by Ludovico Caldara
Trivadis TechEvent 2017 PostgreSQL für die (Orakel) DBA by Ludovico Caldara
 
Jason Olson - IBM i DB2 Modernization to SQL
Jason Olson - IBM i DB2 Modernization to SQLJason Olson - IBM i DB2 Modernization to SQL
Jason Olson - IBM i DB2 Modernization to SQL
 
Introduction to ado.net
Introduction to ado.netIntroduction to ado.net
Introduction to ado.net
 
Sqlite
SqliteSqlite
Sqlite
 
Virtuoso Universal Server Overview
Virtuoso Universal Server OverviewVirtuoso Universal Server Overview
Virtuoso Universal Server Overview
 
Database application developer's guide
Database application developer's guideDatabase application developer's guide
Database application developer's guide
 
Oracle 10g introduction
Oracle 10g introductionOracle 10g introduction
Oracle 10g introduction
 
Sql azure dec_2010 Lynn & Ike
Sql azure dec_2010 Lynn & IkeSql azure dec_2010 Lynn & Ike
Sql azure dec_2010 Lynn & Ike
 

Mehr von Peter Eisentraut

Replication Solutions for PostgreSQL
Replication Solutions for PostgreSQLReplication Solutions for PostgreSQL
Replication Solutions for PostgreSQL
Peter Eisentraut
 
The Common Debian Build System (CDBS)
The Common Debian Build System (CDBS)The Common Debian Build System (CDBS)
The Common Debian Build System (CDBS)
Peter Eisentraut
 

Mehr von Peter Eisentraut (20)

Programming with Python and PostgreSQL
Programming with Python and PostgreSQLProgramming with Python and PostgreSQL
Programming with Python and PostgreSQL
 
Getting Started with PL/Proxy
Getting Started with PL/ProxyGetting Started with PL/Proxy
Getting Started with PL/Proxy
 
Linux distribution for the cloud
Linux distribution for the cloudLinux distribution for the cloud
Linux distribution for the cloud
 
Porting Applications From Oracle To PostgreSQL
Porting Applications From Oracle To PostgreSQLPorting Applications From Oracle To PostgreSQL
Porting Applications From Oracle To PostgreSQL
 
Porting Oracle Applications to PostgreSQL
Porting Oracle Applications to PostgreSQLPorting Oracle Applications to PostgreSQL
Porting Oracle Applications to PostgreSQL
 
PostgreSQL and XML
PostgreSQL and XMLPostgreSQL and XML
PostgreSQL and XML
 
XML Support: Specifications and Development
XML Support: Specifications and DevelopmentXML Support: Specifications and Development
XML Support: Specifications and Development
 
PostgreSQL: Die Freie Datenbankalternative
PostgreSQL: Die Freie DatenbankalternativePostgreSQL: Die Freie Datenbankalternative
PostgreSQL: Die Freie Datenbankalternative
 
The Road to the XML Type: Current and Future Developments
The Road to the XML Type: Current and Future DevelopmentsThe Road to the XML Type: Current and Future Developments
The Road to the XML Type: Current and Future Developments
 
Access ohne Access: Freie Datenbank-Frontends
Access ohne Access: Freie Datenbank-FrontendsAccess ohne Access: Freie Datenbank-Frontends
Access ohne Access: Freie Datenbank-Frontends
 
PostgreSQL and PL/Java
PostgreSQL and PL/JavaPostgreSQL and PL/Java
PostgreSQL and PL/Java
 
Replication Solutions for PostgreSQL
Replication Solutions for PostgreSQLReplication Solutions for PostgreSQL
Replication Solutions for PostgreSQL
 
PostgreSQL News
PostgreSQL NewsPostgreSQL News
PostgreSQL News
 
PostgreSQL News
PostgreSQL NewsPostgreSQL News
PostgreSQL News
 
Access ohne Access: Freie Datenbank-Frontends
Access ohne Access: Freie Datenbank-FrontendsAccess ohne Access: Freie Datenbank-Frontends
Access ohne Access: Freie Datenbank-Frontends
 
Docbook: Textverarbeitung mit XML
Docbook: Textverarbeitung mit XMLDocbook: Textverarbeitung mit XML
Docbook: Textverarbeitung mit XML
 
Collateral Damage: Consequences of Spam and Virus Filtering for the E-Mail Sy...
Collateral Damage: Consequences of Spam and Virus Filtering for the E-Mail Sy...Collateral Damage: Consequences of Spam and Virus Filtering for the E-Mail Sy...
Collateral Damage: Consequences of Spam and Virus Filtering for the E-Mail Sy...
 
Collateral Damage: Consequences of Spam and Virus Filtering for the E-Mail S...
Collateral Damage:
Consequences of Spam and Virus Filtering for the E-Mail S...Collateral Damage:
Consequences of Spam and Virus Filtering for the E-Mail S...
Collateral Damage: Consequences of Spam and Virus Filtering for the E-Mail S...
 
Spaß mit PostgreSQL
Spaß mit PostgreSQLSpaß mit PostgreSQL
Spaß mit PostgreSQL
 
The Common Debian Build System (CDBS)
The Common Debian Build System (CDBS)The Common Debian Build System (CDBS)
The Common Debian Build System (CDBS)
 

Kürzlich hochgeladen

Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
vu2urc
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 

Kürzlich hochgeladen (20)

Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 

SQL/MED and PostgreSQL

  • 1. SQL/MED and PostgreSQL Peter Eisentraut FOSDEM 2009 Peter Eisentraut SQL/MED and PostgreSQL
  • 2. What is SQL/MED? MED = Management of External Data Methods to access non-SQL data in SQL SQL/MED is ISO/IEC 9075-9 Peter Eisentraut SQL/MED and PostgreSQL
  • 3. Applications and Use Cases Connect to other DBMS (like DBI-Link) Connect to other PostgreSQL instances (like dblink) Read non-SQL data (CSV, XML) Manage data stored in file system Images Video Engineering data Peter Eisentraut SQL/MED and PostgreSQL
  • 4. Why do we care? Powerful new functionality Unifies existing ad-hoc solutions. Implementation has begun in PostgreSQL 8.4. Several people have plans for PostgreSQL 8.5. See status report later in this presentation. Peter Eisentraut SQL/MED and PostgreSQL
  • 5. Advantages Schema integration Access control Standard API Centralized control through DBMS Peter Eisentraut SQL/MED and PostgreSQL
  • 6. Two Parts Wrapper interface Access other data sources, represent them as SQL tables Datalinks Manage files stored in file system, represent file references as column values Peter Eisentraut SQL/MED and PostgreSQL
  • 7. Wrapper Interface Concepts Define a foreign table . . . On a foreign server . . . Accessed through a foreign-data wrapper Peter Eisentraut SQL/MED and PostgreSQL
  • 8. Example: Foreign-Data Wrappers Foreign-data wrapper (FDW): a library that can communicate with external data sources CREATE FOREIGN DATA WRAPPER foosql LIBRARY ’foosql_fdw.so’ LANGUAGE C; PostgreSQL communicates with foosql_fdw.so using SQL/MED FDW API. foosql_fdw.so communicates with FooSQL server using their own protocol. In theory, FooSQL, Inc. would ship foosql_fdw.so with their product. In practice, this is not so wide-spread. Peter Eisentraut SQL/MED and PostgreSQL
  • 9. Example: Foreign Servers Foreign server: an instance of an external data source accessed through a FDW CREATE SERVER extradb FOREIGN DATA WRAPPER foosql OPTIONS (host ’foo.example.com’, port ’2345’); Options depend on FDW. Peter Eisentraut SQL/MED and PostgreSQL
  • 10. Example: User Mappings User mapping: additional user-specific options for a foreign server CREATE USER MAPPING FOR peter SERVER extradb OPTIONS (user ’peter’, password ’seKret’); Options depend on FDW. Putting connection options into server vs. user mapping is a matter of convention or convenience. Peter Eisentraut SQL/MED and PostgreSQL
  • 11. Example: Foreign Tables Foreign table: a table stored on a foreign server CREATE FOREIGN TABLE data SERVER extradb OPTIONS (tablename ’DATA123’); Now you can read and write the table as if it were local (depending on FDW features/implementation). Options specified for FDW, server, and user mapping are used as connection parameters (depending on FDW). Peter Eisentraut SQL/MED and PostgreSQL
  • 12. Another Wrapper Interface Example Possible setup for accessing HTML tables stored in a web site as SQL tables: CREATE FOREIGN DATA WRAPPER htmlfile LIBRARY ’html_fdw.so’ LANGUAGE C; CREATE SERVER intranetweb FOREIGN DATA WRAPPER htmlfile OPTIONS (baseurl ’http://intranet/data’); CREATE FOREIGN TABLE data SERVER intranetweb OPTIONS (path ’foo.html#//table[@id="table1"]’); Peter Eisentraut SQL/MED and PostgreSQL
  • 13. More Wrapper Interface Features GRANT and REVOKE IMPORT FOREIGN SCHEMA CREATE ROUTINE MAPPING Peter Eisentraut SQL/MED and PostgreSQL
  • 14. Status in PostgreSQL 8.4 PostgreSQL 8.4 has: CREATE FOREIGN DATA WRAPPER, but no library support CREATE SERVER CREATE USER MAPPING ACL support Used by dblink and PL/Proxy to store connection information Peter Eisentraut SQL/MED and PostgreSQL
  • 15. Status Worldwide IBM DB2 provides a full implementation MySQL and Farrago use some syntax elements No other known implementations Peter Eisentraut SQL/MED and PostgreSQL
  • 16. Plan & Issues Write wrapper library and foreign table support for PostgreSQL 8.5 Supply a few foreign-data wrapper libraries with PostgreSQL 8.5 Use standard wrapper interface API or design our own API? Peter Eisentraut SQL/MED and PostgreSQL
  • 17. Datalink Concepts Files are referenced through a new DATALINK type Database system has control over external files No need to store file contents in database system Access control and integrity mechanisms of DBMS can be extended to file system Peter Eisentraut SQL/MED and PostgreSQL
  • 18. Example: Simple DATALINK Type CREATE TABLE persons ( id integer, name text, picture DATALINK [NO LINK CONTROL] ); INSERT INTO persons VALUES ( 1, ’Jon Doe’, DLVALUE(’file://some/where/1.jpg’) ); This variant doesn’t do anything except store URLs. Peter Eisentraut SQL/MED and PostgreSQL
  • 19. DATALINK Attributes Selection of additional possible attributes for DATALINK fields: FILE LINK CONTROL Datalink value must reference an existing file. INTEGRITY ALL Referenced files can only be renamed or deleted through SQL. INTEGRITY SELECTIVE Referenced files can be renamed or deleted through SQL or directly. READ PERMISSION DB Database system controls file read permission. RECOVERY YES PITR applies to referenced files. ON UNLINK DELETE File is deleted from file sytem when deleted from database. Peter Eisentraut SQL/MED and PostgreSQL
  • 20. How to Implement Datalinks How to implement this? OS-dependent File-system dependent Application-dependent Lots of hocus pocus needed Possibilities: kernel modules, LD_PRELOAD, extended FS attributes Don’t hold your breath. Peter Eisentraut SQL/MED and PostgreSQL
  • 21. Summary SQL/MED: Wrapper interface Datalinks Substantial support planned for PostgreSQL 8.5 and beyond References: http://wiki.postgresql.org/wiki/ SqlMedConnectionManager (Martin Pihlak) http://www.sigmod.org/record/issues/0103/ JM-Sta.pdf (Jim Melton et al.) http://www.sigmod.org/record/issues/0209/ jimmelton.pdf (Jim Melton et al.) ISO/IEC 9075-9:2008 (“SQL/MED”) Peter Eisentraut SQL/MED and PostgreSQL