SlideShare a Scribd company logo
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

More Related Content

What's hot (20)

Sqlmap
Sqlmap
Institute of Information Security (IIS)
 
TSQL in SQL Server 2012
TSQL in SQL Server 2012
Eduardo Castro
 
PostgreSQL Database Slides
PostgreSQL Database Slides
metsarin
 
All Oracle-dba-interview-questions
All Oracle-dba-interview-questions
Naveen P
 
Less18 moving data
Less18 moving data
Imran Ali
 
Advanced SQL injection to operating system full control (slides)
Advanced SQL injection to operating system full control (slides)
Bernardo Damele A. G.
 
Oracle DBA interview_questions
Oracle DBA interview_questions
Naveen P
 
576 oracle-dba-interview-questions
576 oracle-dba-interview-questions
Naveen P
 
Building your own search engine with Apache Solr
Building your own search engine with Apache Solr
Biogeeks
 
Recent Additions to Lucene Arsenal
Recent Additions to Lucene Arsenal
lucenerevolution
 
Impala SQL Support
Impala SQL Support
Yue Chen
 
Oracle Database 11g Release 2 - XMLDB New Features
Oracle Database 11g Release 2 - XMLDB New Features
Marco Gralike
 
Using Apache Solr
Using Apache Solr
pittaya
 
Postgresql
Postgresql
NexThoughts Technologies
 
XMLDB Building Blocks And Best Practices - Oracle Open World 2008 - Marco Gra...
XMLDB Building Blocks And Best Practices - Oracle Open World 2008 - Marco Gra...
Marco Gralike
 
DBA 3 year Interview Questions
DBA 3 year Interview Questions
Naveen P
 
Developers’ mDay 2021: Bogdan Kecman, Oracle – MySQL nekad i sad
Developers’ mDay 2021: Bogdan Kecman, Oracle – MySQL nekad i sad
mCloud
 
Harrison fisk masteringinnodb-diagnostics
Harrison fisk masteringinnodb-diagnostics
guest8212a5
 
Oracle Introduction
Oracle Introduction
Mohana Rajendiran
 
New Stuff in the Oracle PL/SQL Language
New Stuff in the Oracle PL/SQL Language
Steven Feuerstein
 
TSQL in SQL Server 2012
TSQL in SQL Server 2012
Eduardo Castro
 
PostgreSQL Database Slides
PostgreSQL Database Slides
metsarin
 
All Oracle-dba-interview-questions
All Oracle-dba-interview-questions
Naveen P
 
Less18 moving data
Less18 moving data
Imran Ali
 
Advanced SQL injection to operating system full control (slides)
Advanced SQL injection to operating system full control (slides)
Bernardo Damele A. G.
 
Oracle DBA interview_questions
Oracle DBA interview_questions
Naveen P
 
576 oracle-dba-interview-questions
576 oracle-dba-interview-questions
Naveen P
 
Building your own search engine with Apache Solr
Building your own search engine with Apache Solr
Biogeeks
 
Recent Additions to Lucene Arsenal
Recent Additions to Lucene Arsenal
lucenerevolution
 
Impala SQL Support
Impala SQL Support
Yue Chen
 
Oracle Database 11g Release 2 - XMLDB New Features
Oracle Database 11g Release 2 - XMLDB New Features
Marco Gralike
 
Using Apache Solr
Using Apache Solr
pittaya
 
XMLDB Building Blocks And Best Practices - Oracle Open World 2008 - Marco Gra...
XMLDB Building Blocks And Best Practices - Oracle Open World 2008 - Marco Gra...
Marco Gralike
 
DBA 3 year Interview Questions
DBA 3 year Interview Questions
Naveen P
 
Developers’ mDay 2021: Bogdan Kecman, Oracle – MySQL nekad i sad
Developers’ mDay 2021: Bogdan Kecman, Oracle – MySQL nekad i sad
mCloud
 
Harrison fisk masteringinnodb-diagnostics
Harrison fisk masteringinnodb-diagnostics
guest8212a5
 
New Stuff in the Oracle PL/SQL Language
New Stuff in the Oracle PL/SQL Language
Steven Feuerstein
 

Similar to SQL/MED and PostgreSQL (20)

Foreign Data Wrappers and You with Postgres
Foreign Data Wrappers and You with Postgres
EDB
 
PGConf.ASIA 2019 Bali - A step towards SQL/MED - DATALINK - Gilles Darold
PGConf.ASIA 2019 Bali - A step towards SQL/MED - DATALINK - Gilles Darold
Equnix Business Solutions
 
PGDay.Amsterdam 2018 - Stefanie Stoelting - PostgreSQL As Data Integration Tool
PGDay.Amsterdam 2018 - Stefanie Stoelting - PostgreSQL As Data Integration Tool
PGDay.Amsterdam
 
PostgreSQL As Data Integration Tool
PostgreSQL As Data Integration Tool
Stefanie Janine Stölting
 
Universal data access_with_sql_med
Universal data access_with_sql_med
David Fetter
 
Federation with foreign_data_wrappers_pg_conf_eu_20131031
Federation with foreign_data_wrappers_pg_conf_eu_20131031
David Fetter
 
Chjkkkkkkkkkkkkkkkkkjjjjjjjjjjjjjjjjjjjjjjjjjj01_The Basics.pptx
Chjkkkkkkkkkkkkkkkkkjjjjjjjjjjjjjjjjjjjjjjjjjj01_The Basics.pptx
MhmdMk10
 
Postgres for the Future
Postgres for the Future
EDB
 
Introduction to PostgreSQL
Introduction to PostgreSQL
Jim Mlodgenski
 
Intergalactic data speak_highload++_20131028
Intergalactic data speak_highload++_20131028
David Fetter
 
Reducing Database Pain & Costs with Postgres
Reducing Database Pain & Costs with Postgres
EDB
 
PostgreSQL Server Programming Second Edition Usama Dar Hannu Krosing Jim Mlod...
PostgreSQL Server Programming Second Edition Usama Dar Hannu Krosing Jim Mlod...
servanjervy
 
Doing More with Postgres - Yesterday's Vision Becomes Today's Reality
Doing More with Postgres - Yesterday's Vision Becomes Today's Reality
EDB
 
0292-introduction-postgresql.pdf
0292-introduction-postgresql.pdf
Mustafa Keskin
 
Dbms & prog lang
Dbms & prog lang
Tech_MX
 
PostgreSQL 9.5 Foreign Data Wrappers
PostgreSQL 9.5 Foreign Data Wrappers
Nicholas Kiraly
 
Postgres.foreign.data.wrappers.2015
Postgres.foreign.data.wrappers.2015
EDB
 
PostgreSQL Server Programming Second Edition Usama Dar Hannu Krosing Jim Mlod...
PostgreSQL Server Programming Second Edition Usama Dar Hannu Krosing Jim Mlod...
trddarvai
 
PostgreSQL - Case Study
PostgreSQL - Case Study
S.Shayan Daneshvar
 
Object Relational Database Management System
Object Relational Database Management System
Amar Myana
 
Foreign Data Wrappers and You with Postgres
Foreign Data Wrappers and You with Postgres
EDB
 
PGConf.ASIA 2019 Bali - A step towards SQL/MED - DATALINK - Gilles Darold
PGConf.ASIA 2019 Bali - A step towards SQL/MED - DATALINK - Gilles Darold
Equnix Business Solutions
 
PGDay.Amsterdam 2018 - Stefanie Stoelting - PostgreSQL As Data Integration Tool
PGDay.Amsterdam 2018 - Stefanie Stoelting - PostgreSQL As Data Integration Tool
PGDay.Amsterdam
 
Universal data access_with_sql_med
Universal data access_with_sql_med
David Fetter
 
Federation with foreign_data_wrappers_pg_conf_eu_20131031
Federation with foreign_data_wrappers_pg_conf_eu_20131031
David Fetter
 
Chjkkkkkkkkkkkkkkkkkjjjjjjjjjjjjjjjjjjjjjjjjjj01_The Basics.pptx
Chjkkkkkkkkkkkkkkkkkjjjjjjjjjjjjjjjjjjjjjjjjjj01_The Basics.pptx
MhmdMk10
 
Postgres for the Future
Postgres for the Future
EDB
 
Introduction to PostgreSQL
Introduction to PostgreSQL
Jim Mlodgenski
 
Intergalactic data speak_highload++_20131028
Intergalactic data speak_highload++_20131028
David Fetter
 
Reducing Database Pain & Costs with Postgres
Reducing Database Pain & Costs with Postgres
EDB
 
PostgreSQL Server Programming Second Edition Usama Dar Hannu Krosing Jim Mlod...
PostgreSQL Server Programming Second Edition Usama Dar Hannu Krosing Jim Mlod...
servanjervy
 
Doing More with Postgres - Yesterday's Vision Becomes Today's Reality
Doing More with Postgres - Yesterday's Vision Becomes Today's Reality
EDB
 
0292-introduction-postgresql.pdf
0292-introduction-postgresql.pdf
Mustafa Keskin
 
Dbms & prog lang
Dbms & prog lang
Tech_MX
 
PostgreSQL 9.5 Foreign Data Wrappers
PostgreSQL 9.5 Foreign Data Wrappers
Nicholas Kiraly
 
Postgres.foreign.data.wrappers.2015
Postgres.foreign.data.wrappers.2015
EDB
 
PostgreSQL Server Programming Second Edition Usama Dar Hannu Krosing Jim Mlod...
PostgreSQL Server Programming Second Edition Usama Dar Hannu Krosing Jim Mlod...
trddarvai
 
Object Relational Database Management System
Object Relational Database Management System
Amar Myana
 
Ad

More from Peter Eisentraut (20)

Programming with Python and PostgreSQL
Programming with Python and PostgreSQL
Peter Eisentraut
 
Getting Started with PL/Proxy
Getting Started with PL/Proxy
Peter Eisentraut
 
Linux distribution for the cloud
Linux distribution for the cloud
Peter Eisentraut
 
Porting Applications From Oracle To PostgreSQL
Porting Applications From Oracle To PostgreSQL
Peter Eisentraut
 
Porting Oracle Applications to PostgreSQL
Porting Oracle Applications to PostgreSQL
Peter Eisentraut
 
PostgreSQL and XML
PostgreSQL and XML
Peter Eisentraut
 
XML Support: Specifications and Development
XML Support: Specifications and Development
Peter Eisentraut
 
PostgreSQL: Die Freie Datenbankalternative
PostgreSQL: Die Freie Datenbankalternative
Peter Eisentraut
 
The Road to the XML Type: Current and Future Developments
The Road to the XML Type: Current and Future Developments
Peter Eisentraut
 
Access ohne Access: Freie Datenbank-Frontends
Access ohne Access: Freie Datenbank-Frontends
Peter Eisentraut
 
PostgreSQL and PL/Java
PostgreSQL and PL/Java
Peter Eisentraut
 
Replication Solutions for PostgreSQL
Replication Solutions for PostgreSQL
Peter Eisentraut
 
PostgreSQL News
PostgreSQL News
Peter Eisentraut
 
PostgreSQL News
PostgreSQL News
Peter Eisentraut
 
Access ohne Access: Freie Datenbank-Frontends
Access ohne Access: Freie Datenbank-Frontends
Peter Eisentraut
 
Docbook: Textverarbeitung mit XML
Docbook: Textverarbeitung mit XML
Peter Eisentraut
 
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...
Peter Eisentraut
 
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...
Peter Eisentraut
 
Spaß mit PostgreSQL
Spaß mit PostgreSQL
Peter Eisentraut
 
The Common Debian Build System (CDBS)
The Common Debian Build System (CDBS)
Peter Eisentraut
 
Programming with Python and PostgreSQL
Programming with Python and PostgreSQL
Peter Eisentraut
 
Getting Started with PL/Proxy
Getting Started with PL/Proxy
Peter Eisentraut
 
Linux distribution for the cloud
Linux distribution for the cloud
Peter Eisentraut
 
Porting Applications From Oracle To PostgreSQL
Porting Applications From Oracle To PostgreSQL
Peter Eisentraut
 
Porting Oracle Applications to PostgreSQL
Porting Oracle Applications to PostgreSQL
Peter Eisentraut
 
XML Support: Specifications and Development
XML Support: Specifications and Development
Peter Eisentraut
 
PostgreSQL: Die Freie Datenbankalternative
PostgreSQL: Die Freie Datenbankalternative
Peter Eisentraut
 
The Road to the XML Type: Current and Future Developments
The Road to the XML Type: Current and Future Developments
Peter Eisentraut
 
Access ohne Access: Freie Datenbank-Frontends
Access ohne Access: Freie Datenbank-Frontends
Peter Eisentraut
 
Replication Solutions for PostgreSQL
Replication Solutions for PostgreSQL
Peter Eisentraut
 
Access ohne Access: Freie Datenbank-Frontends
Access ohne Access: Freie Datenbank-Frontends
Peter Eisentraut
 
Docbook: Textverarbeitung mit XML
Docbook: Textverarbeitung mit XML
Peter Eisentraut
 
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...
Peter Eisentraut
 
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...
Peter Eisentraut
 
The Common Debian Build System (CDBS)
The Common Debian Build System (CDBS)
Peter Eisentraut
 
Ad

Recently uploaded (20)

TrustArc Webinar - 2025 Global Privacy Survey
TrustArc Webinar - 2025 Global Privacy Survey
TrustArc
 
Viral>Wondershare Filmora 14.5.18.12900 Crack Free Download
Viral>Wondershare Filmora 14.5.18.12900 Crack Free Download
Puppy jhon
 
Enabling BIM / GIS integrations with Other Systems with FME
Enabling BIM / GIS integrations with Other Systems with FME
Safe Software
 
High Availability On-Premises FME Flow.pdf
High Availability On-Premises FME Flow.pdf
Safe Software
 
Bridging the divide: A conversation on tariffs today in the book industry - T...
Bridging the divide: A conversation on tariffs today in the book industry - T...
BookNet Canada
 
ENERGY CONSUMPTION CALCULATION IN ENERGY-EFFICIENT AIR CONDITIONER.pdf
ENERGY CONSUMPTION CALCULATION IN ENERGY-EFFICIENT AIR CONDITIONER.pdf
Muhammad Rizwan Akram
 
No-Code Workflows for CAD & 3D Data: Scaling AI-Driven Infrastructure
No-Code Workflows for CAD & 3D Data: Scaling AI-Driven Infrastructure
Safe Software
 
Integration of Utility Data into 3D BIM Models Using a 3D Solids Modeling Wor...
Integration of Utility Data into 3D BIM Models Using a 3D Solids Modeling Wor...
Safe Software
 
Scaling GenAI Inference From Prototype to Production: Real-World Lessons in S...
Scaling GenAI Inference From Prototype to Production: Real-World Lessons in S...
Anish Kumar
 
MuleSoft for AgentForce : Topic Center and API Catalog
MuleSoft for AgentForce : Topic Center and API Catalog
shyamraj55
 
cnc-drilling-dowel-inserting-machine-drillteq-d-510-english.pdf
cnc-drilling-dowel-inserting-machine-drillteq-d-510-english.pdf
AmirStern2
 
AudGram Review: Build Visually Appealing, AI-Enhanced Audiograms to Engage Yo...
AudGram Review: Build Visually Appealing, AI-Enhanced Audiograms to Engage Yo...
SOFTTECHHUB
 
FIDO Seminar: New Data: Passkey Adoption in the Workforce.pptx
FIDO Seminar: New Data: Passkey Adoption in the Workforce.pptx
FIDO Alliance
 
Providing an OGC API Processes REST Interface for FME Flow
Providing an OGC API Processes REST Interface for FME Flow
Safe Software
 
Oracle Cloud Infrastructure AI Foundations
Oracle Cloud Infrastructure AI Foundations
VICTOR MAESTRE RAMIREZ
 
The State of Web3 Industry- Industry Report
The State of Web3 Industry- Industry Report
Liveplex
 
Your startup on AWS - How to architect and maintain a Lean and Mean account J...
Your startup on AWS - How to architect and maintain a Lean and Mean account J...
angelo60207
 
FIDO Seminar: Perspectives on Passkeys & Consumer Adoption.pptx
FIDO Seminar: Perspectives on Passkeys & Consumer Adoption.pptx
FIDO Alliance
 
FME for Distribution & Transmission Integrity Management Program (DIMP & TIMP)
FME for Distribution & Transmission Integrity Management Program (DIMP & TIMP)
Safe Software
 
National Fuels Treatments Initiative: Building a Seamless Map of Hazardous Fu...
National Fuels Treatments Initiative: Building a Seamless Map of Hazardous Fu...
Safe Software
 
TrustArc Webinar - 2025 Global Privacy Survey
TrustArc Webinar - 2025 Global Privacy Survey
TrustArc
 
Viral>Wondershare Filmora 14.5.18.12900 Crack Free Download
Viral>Wondershare Filmora 14.5.18.12900 Crack Free Download
Puppy jhon
 
Enabling BIM / GIS integrations with Other Systems with FME
Enabling BIM / GIS integrations with Other Systems with FME
Safe Software
 
High Availability On-Premises FME Flow.pdf
High Availability On-Premises FME Flow.pdf
Safe Software
 
Bridging the divide: A conversation on tariffs today in the book industry - T...
Bridging the divide: A conversation on tariffs today in the book industry - T...
BookNet Canada
 
ENERGY CONSUMPTION CALCULATION IN ENERGY-EFFICIENT AIR CONDITIONER.pdf
ENERGY CONSUMPTION CALCULATION IN ENERGY-EFFICIENT AIR CONDITIONER.pdf
Muhammad Rizwan Akram
 
No-Code Workflows for CAD & 3D Data: Scaling AI-Driven Infrastructure
No-Code Workflows for CAD & 3D Data: Scaling AI-Driven Infrastructure
Safe Software
 
Integration of Utility Data into 3D BIM Models Using a 3D Solids Modeling Wor...
Integration of Utility Data into 3D BIM Models Using a 3D Solids Modeling Wor...
Safe Software
 
Scaling GenAI Inference From Prototype to Production: Real-World Lessons in S...
Scaling GenAI Inference From Prototype to Production: Real-World Lessons in S...
Anish Kumar
 
MuleSoft for AgentForce : Topic Center and API Catalog
MuleSoft for AgentForce : Topic Center and API Catalog
shyamraj55
 
cnc-drilling-dowel-inserting-machine-drillteq-d-510-english.pdf
cnc-drilling-dowel-inserting-machine-drillteq-d-510-english.pdf
AmirStern2
 
AudGram Review: Build Visually Appealing, AI-Enhanced Audiograms to Engage Yo...
AudGram Review: Build Visually Appealing, AI-Enhanced Audiograms to Engage Yo...
SOFTTECHHUB
 
FIDO Seminar: New Data: Passkey Adoption in the Workforce.pptx
FIDO Seminar: New Data: Passkey Adoption in the Workforce.pptx
FIDO Alliance
 
Providing an OGC API Processes REST Interface for FME Flow
Providing an OGC API Processes REST Interface for FME Flow
Safe Software
 
Oracle Cloud Infrastructure AI Foundations
Oracle Cloud Infrastructure AI Foundations
VICTOR MAESTRE RAMIREZ
 
The State of Web3 Industry- Industry Report
The State of Web3 Industry- Industry Report
Liveplex
 
Your startup on AWS - How to architect and maintain a Lean and Mean account J...
Your startup on AWS - How to architect and maintain a Lean and Mean account J...
angelo60207
 
FIDO Seminar: Perspectives on Passkeys & Consumer Adoption.pptx
FIDO Seminar: Perspectives on Passkeys & Consumer Adoption.pptx
FIDO Alliance
 
FME for Distribution & Transmission Integrity Management Program (DIMP & TIMP)
FME for Distribution & Transmission Integrity Management Program (DIMP & TIMP)
Safe Software
 
National Fuels Treatments Initiative: Building a Seamless Map of Hazardous Fu...
National Fuels Treatments Initiative: Building a Seamless Map of Hazardous Fu...
Safe Software
 

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