Smalltalk
                             Programmer




Ing. Mariano MartĆ­nez Peck   marianopeck@gmail.com
SqueakDBX

  The complete and G
                IN to
            E T
open-source solution
         Kdatabase
    A  R
 relational
 M access
SqueakDBX team
Mariano                       GermƔn
                                         HernƔn
                                         Cassinelli
M. Peck   Esteban Lorenzano   Palacios
F.A.Q


 Who are we?

 How did it begin?

 What is actually SqueakDBX?
RDBMS VS. OODB




 Please, don't fight ;)
Anyway, we rather program in
objects and use RDBMS than
  using Java with RDBMS
              ;)
Survey                              1/2
How many times were you forced to use a
particular database?
Survey             2/2
Which databases?
Squeak's current situation
 Only MySQL and PostgreSQL native
 drivers.
 Limited ODBC driver
 Glorp in Squeak
only works with
PostgreSQL
We are in trouble...
 Direct SQL queries: 20%




 Using GLORP: 8.52%
Our goal
 Direct SQL queries: 100%




 Using GLORP: 100%
Our purpose
OpenDBX architecture
Oracle uses oci.h and and libmysqlclient_r.
MySQL uses mysql.h libclntsh.
It has N functions.
       M functions.                           Common API
                                            for all backends!!!
Examples: OCIHandleAlloc(), OCIServerAttach(),
            mysql_real_connect(), mysql_server_end(),
OCISessionEnd(), etc.
mysql_real_query(), etc.
Oracle       MySQL        PosgreSQL        Sqlite       SQLServer
client        client        client         client         client
library       library       library        library        library
Why OpenDBX?
It is fast
Simple to use
Flexible
Cross platform
Asynchronous queries
Specific RDBMS features
Good documentation
Deployment and infrastructure
     PC1              PC2

 Squeak image
                     Database

  OpenDBX


  Database
 Client Library
Smalltalk and C

      Squeak image



                                                   |

      OpenDBX
      #include <stdio.h>
      #include <stdio.h>
      static int mysql_odbx_get_option( odbx_t*)
      static int mysql_odbx_get_option( odbx_t*)
               switch( option )
               switch( option )
      .....
      .....
Smalltalk-C Connector
FFI (Foreign Function Interface)


 Main problem: Locks the entire VM
Squeak ODBC driver queries

                  VM locked
                  time
OpenDBX Connector
FFI (Foreign Function Interface)


 Main problem: Locks the entire VM
 Our solution:
  āœ”   Asynchronous queries
  āœ”   ā€œMiniā€ VM locks
  āœ”   Retry schema
  āœ”   DBXQuerySettings>>timeout:
SqueakDBX queries

            VM locked
            time
Database access in Smalltalk
SqueakDBX                       Smalltalk driver
āœ”   One for all databases   āœ—   One for each database
āœ”   Less time and effort    āœ—   More time and effort
āœ”   Good performace         āœ—   Performance issues?
āœ”   OSS and proprietary     āœ—   Only OSS
āœ—   Difficult to debug      āœ”   Easier to debug
āœ—   Platform dependent      āœ”   Platform independent
āœ—   FFI locks the VM        āœ”   Non-locking
SqueakDBX design


SqueakDBX Structure (API)
SqueakDBX Structure (API)

  SqueakDBX Platform
  SqueakDBX Platform

  OpenDBX Connector
  OpenDBX Connector
                            {
                            {
                               DBXConnection
                               DBXConnectionSettings
                               DBXResultSet
                               DBXPlatform
                               DBXResult
                               DBXSpecialOptions
                               DBXRow
                               DBXErrorSeverity
                               ...
                               DBXTimeSpec
                               ...

    FFI
    FFI      SqueakDBXPlugin
             SqueakDBXPlugin


          OpenDBX
Showtime
Who can use SqueakDBX?

 An application
 Glorp
 Magritte-RDB
 SqueakSave
 Moe
Current backends and OS
Benchmark for PostgreSQL
      1800

      1600

      1400

      1200

      1000
 ms




      800                                                 SqueakDBX
                                                          Native
      600

      400

      200

        0
                    Converted Insert         Select1000
             Insert                Select100
                              tests
Benchmark for MySQL
      700

      600

      500

      400
 ms




      300                                                SqueakDBX
                                                         Native
      200

      100

       0
                   Converted Insert         Select1000
            Insert                Select100
                             tests
Features
 Mini VM locks
 SqueakDBXPlugin
 Automatic fields conversion
 Configurable logging/trace
 Special RDBMS features
 Multistatements
 Automatic release of resources
What do we have?
 Enough unit tests
 Acceptable test coverage
 SmallLint runs
 Good enough design
 GLORP integration
Documentation
Website
Documented code
Mailing list
Benchmarks
What will come
 Complete Glorp refactor and integration
 More backends in more OS
 Large objects support
 Better SPs and functions support
 Continue with SqueakDBXPlugin
 Try Alien FFI
 Port to Smalltalk/X ?
Glorp progress
 Port from Squeak to Pharo
 First refactor to SqueakDatabaseAccesor
 Driver for native driver
 Driver for SqueakDBX (PostgreSQL)
Glorp before SqueakDBX
Glorp after SqueakDBX
Special thanks to...

                  Norbert Sendetzky



     GLORP             Alan Knight



                  StƩphane Ducasse
aConnection execute: 'select * from questions
   where has_answer = true'




Ing. Mariano MartĆ­nez Peck      marianopeck@gmail.com
Thank you
very much
Squeak DBX

Squeak DBX

  • 1.
    Smalltalk Programmer Ing. Mariano MartĆ­nez Peck marianopeck@gmail.com
  • 2.
    SqueakDBX Thecomplete and G IN to E T open-source solution Kdatabase A R relational M access
  • 3.
    SqueakDBX team Mariano GermƔn HernƔn Cassinelli M. Peck Esteban Lorenzano Palacios
  • 4.
    F.A.Q Who arewe? How did it begin? What is actually SqueakDBX?
  • 5.
    RDBMS VS. OODB Please, don't fight ;)
  • 6.
    Anyway, we ratherprogram in objects and use RDBMS than using Java with RDBMS ;)
  • 7.
    Survey 1/2 How many times were you forced to use a particular database?
  • 8.
    Survey 2/2 Which databases?
  • 9.
    Squeak's current situation Only MySQL and PostgreSQL native drivers. Limited ODBC driver Glorp in Squeak only works with PostgreSQL
  • 10.
    We are introuble... Direct SQL queries: 20% Using GLORP: 8.52%
  • 11.
    Our goal DirectSQL queries: 100% Using GLORP: 100%
  • 12.
  • 13.
    OpenDBX architecture Oracle usesoci.h and and libmysqlclient_r. MySQL uses mysql.h libclntsh. It has N functions. M functions. Common API for all backends!!! Examples: OCIHandleAlloc(), OCIServerAttach(), mysql_real_connect(), mysql_server_end(), OCISessionEnd(), etc. mysql_real_query(), etc. Oracle MySQL PosgreSQL Sqlite SQLServer client client client client client library library library library library
  • 14.
    Why OpenDBX? It isfast Simple to use Flexible Cross platform Asynchronous queries Specific RDBMS features Good documentation
  • 15.
    Deployment and infrastructure PC1 PC2 Squeak image Database OpenDBX Database Client Library
  • 16.
    Smalltalk and C Squeak image | OpenDBX #include <stdio.h> #include <stdio.h> static int mysql_odbx_get_option( odbx_t*) static int mysql_odbx_get_option( odbx_t*) switch( option ) switch( option ) ..... .....
  • 17.
    Smalltalk-C Connector FFI (ForeignFunction Interface) Main problem: Locks the entire VM
  • 18.
    Squeak ODBC driverqueries VM locked time
  • 19.
    OpenDBX Connector FFI (ForeignFunction Interface) Main problem: Locks the entire VM Our solution: āœ” Asynchronous queries āœ” ā€œMiniā€ VM locks āœ” Retry schema āœ” DBXQuerySettings>>timeout:
  • 20.
    SqueakDBX queries VM locked time
  • 21.
    Database access inSmalltalk SqueakDBX Smalltalk driver āœ” One for all databases āœ— One for each database āœ” Less time and effort āœ— More time and effort āœ” Good performace āœ— Performance issues? āœ” OSS and proprietary āœ— Only OSS āœ— Difficult to debug āœ” Easier to debug āœ— Platform dependent āœ” Platform independent āœ— FFI locks the VM āœ” Non-locking
  • 22.
    SqueakDBX design SqueakDBX Structure(API) SqueakDBX Structure (API) SqueakDBX Platform SqueakDBX Platform OpenDBX Connector OpenDBX Connector { { DBXConnection DBXConnectionSettings DBXResultSet DBXPlatform DBXResult DBXSpecialOptions DBXRow DBXErrorSeverity ... DBXTimeSpec ... FFI FFI SqueakDBXPlugin SqueakDBXPlugin OpenDBX
  • 23.
  • 24.
    Who can useSqueakDBX? An application Glorp Magritte-RDB SqueakSave Moe
  • 25.
  • 26.
    Benchmark for PostgreSQL 1800 1600 1400 1200 1000 ms 800 SqueakDBX Native 600 400 200 0 Converted Insert Select1000 Insert Select100 tests
  • 27.
    Benchmark for MySQL 700 600 500 400 ms 300 SqueakDBX Native 200 100 0 Converted Insert Select1000 Insert Select100 tests
  • 28.
    Features Mini VMlocks SqueakDBXPlugin Automatic fields conversion Configurable logging/trace Special RDBMS features Multistatements Automatic release of resources
  • 29.
    What do wehave? Enough unit tests Acceptable test coverage SmallLint runs Good enough design GLORP integration
  • 30.
  • 31.
    What will come Complete Glorp refactor and integration More backends in more OS Large objects support Better SPs and functions support Continue with SqueakDBXPlugin Try Alien FFI Port to Smalltalk/X ?
  • 32.
    Glorp progress Portfrom Squeak to Pharo First refactor to SqueakDatabaseAccesor Driver for native driver Driver for SqueakDBX (PostgreSQL)
  • 33.
  • 34.
  • 35.
    Special thanks to... Norbert Sendetzky GLORP Alan Knight StƩphane Ducasse
  • 36.
    aConnection execute: 'select* from questions where has_answer = true' Ing. Mariano MartĆ­nez Peck marianopeck@gmail.com
  • 37.