Abstract
Integrating a database query language into a programming language is becoming increasingly important in recently emerging high-level cloud computing and other applications, where efficient and sophisticated data manipulation is required during computation. This paper reports on seamless integration of SQL into SML# - an extension of Standard ML. In the integrated language, the type system always infers a principal type for any type consistent SQL expression. This makes SQL queries first-class citizens, which can be freely combined with any other language constructs definable in Standard ML. For a program involving SQL queries, the compiler separates SQL queries and delegates their evaluation to a database server, e.g. PostgreSQL or MySQL in the currently implemented version.
The type system of our language is largely based on Machiavelli, which demonstrates that ML with record polymorphism can represent type structure of SQL. In order to develop a practical language, however, a number of technical challenges have to be overcome, including static enforcement of server connection consistency, proper treatment of overloaded SQL primitives, query compilation, and runtime connection management. This paper describes the necessary extensions to the type system and compilation, and reports on the details of its implementation.
Supplemental Material
- M. Abadi, L. Cardelli, B. Pierce, and G. Plotkin. Dynamic typing in a statically-typed language. ACM Trans. Program. Lang. Syst., 13(2):207--268, 1991. Google Scholar
Digital Library
- A. Albano, G. Ghelli, and R. Orsini. Fibonacci: a programming language for object databases. The VLDB Journal, 4(3):403--444, 1995. Google Scholar
Digital Library
- J. Annevelink. Database programming languages: a functional approach. In Proceedings of the ACM SIGMOD International Conference on Management of Data, pages 318--327, 1991. Google Scholar
Digital Library
- M.P. Atkinson and O.P. Buneman. Types and persistence in database programming languages. ACM Computing Surveys, 1987. Google Scholar
Digital Library
- S. Blanas, J. M. Patel, V. Ercegovac, J. Rao, E. J. Shekita, and Y. Tian. A comparison of join algorithms for log processing in mapreduce. In Proceedings of the ACM SIGMOD International Conference on Management of Data, pages 975--986, 2010. ACM. Google Scholar
Digital Library
- P. Buneman, S. Naqvi, V. Tannen, and L. Wong. Principles of programming with complex objects and collection types. Theor. Comput. Sci., 149(1):3--48, 1995. Google Scholar
Digital Library
- A. Chlipala. Ur: statically-typed metaprogramming with type-level record computation. In Proceedings of the ACM SIGPLAN Conference on Programming Language Design and Implementation, pages 122--133, 2010. Google Scholar
Digital Library
- E. F. Codd. A relational model for large shared databank. Communications of the ACM, 13(6):377--387, 1970. Google Scholar
Digital Library
- E. Cooper. The script-writer's dream: How to write great SQL in your own language, and be sure it will succeed. In Proceedings of the International Symposium on Database Programming Languages, pages 36--51, Springer-Verlag, 2009. Google Scholar
Digital Library
- E. Cooper, S. Lindley, P. Wadler, and J. Yallop. Links: web programming without tiers. In Proceedings of the International Conference on Formal Methods for Components and Objects, pages 266--296, Springer-Verlag, 2007. Google Scholar
Digital Library
- G. Copeland and D. Maier. Making smalltalk a database system. In Proceedings of the ACM SIGMOD International Conferenceon Management of Data, pages 316--325, 1984. Google Scholar
Digital Library
- J. Dean and S. Ghemawat. Mapreduce: simplified data processing on large clusters. Commun. ACM, 51(1):107--113, 2008. Google Scholar
Digital Library
- A. Eisenberg and J. Melton. SQLJ part 0, now known as SQL/OLB (object-language bindings). SIGMOD Rec., 27(4):94--100, 1998. Google Scholar
Digital Library
- J. Gil and K. Lenz. Simple and safe SQL queries with C++ templates. Science of Computer Programming, 75(7):573--595, 2010. Google Scholar
Digital Library
- G. Giorgidze, T. Grust, T. Schreiber, and J. Weijers. Haskell boards the Ferry: Database-supported program execution for Haskell. In Proceedings of the 22nd international symposium on Implementation and Application of Functional Languages, to appear. Google Scholar
Digital Library
- T. Grust, M. Mayr, J. Rittinger, and T. Schreiber. FERRY: database-supported program execution. In Proceedings of the SIGMOD International Conference on Management of Data, pages 1063--1066, 2009. Google Scholar
Digital Library
- C. V. Hall, K. Hammond, S. L. Peyton Jones, and P. L. Wadler. Type classes in haskell. ACM Trans. Program. Lang. Syst., 18(2):109--138, 1996. Google Scholar
Digital Library
- P. Hudak. Building domain-specific embedded languages. ACM Comput. Surv., page 196, 1996. Google Scholar
Digital Library
- D. Leijen and E. Meijer. Domain specific embedded compilers. In Proceedings of the 2nd USENIX Conference on Domain Specific Languages, pages 109--122, 1999. Google Scholar
Digital Library
- Y. Leontiev, M. T. Özsu, and D. Szafron. On type systems for object-oriented database programming languages. ACM Comput. Surv., 34(4):409--449, 2002. Google Scholar
Digital Library
- D. Maier. Why database languages are a bad idea. In F. Bancilhon and P. Buneman, editors, Proceedings of the International Workshop on Database Programming Languages, Addison-Wesley, 1989.Google Scholar
- E. Meijer, B. Beckman, and G. Bierman. LINQ: Reconciling object, relations and XML in the .NET framework. In Proceedings of the ACM SIGMOD International Conference on Management of Data, pages 706--706, 2006. Google Scholar
Digital Library
- R. Milner, M. Tofte, R. Harper, and D. MacQueen. The Definition of Standard ML. The MIT Press, revised edition, 1997. Google Scholar
Cross Ref
- J.C. Mitchell and G.D. Plotkin. Abstract types have existential type. ACM Trans. Program. Lang. Syst., 10(3):470--502, 1988. Google Scholar
Digital Library
- R. Morrison, F. Brown, R. Connor, Q. Cutts, A. Dearle, G. Kirby, and D. Munro. Napier88 reference manual. Technical report, University of St. Andrews, 1996.Google Scholar
- H-D. Nguyen and A. Ohori. Compiling ml polymporphism with explicit layout bitmap. In Proceedings of the ACM Conference on Principles andPractice of Declarative Programming, pages 237--248, 2006. Google Scholar
Digital Library
- A. Ohori. A polymorphic record calculus and its compilation. ACM Trans. Program. Lang. Syst., 17(6):844--895, 1995. A preliminary summary appeared at ACM POPL, 1992 under the title "A compilation method for ML-style polymorphic record calculi". Google Scholar
Digital Library
- A. Ohori and P. Buneman. Type inference in a database programming language. In Proceedings of the ACM Conference on LISP and Functional Programming, pages 174--183, 1988. Google Scholar
Digital Library
- A. Ohori, P. Buneman, and V. Breazu-Tannen. Database programming in Machiavelli - a polymorphic language with static type inference. In Proceedings of the ACM SIGMOD International Conference on Management of Data, pages 46--57, 1989. Google Scholar
Digital Library
- D. Remy. Typechecking records and variants in a natural extension of ML. In Proceedings of the ACM Symposium on Principles of Programming Languages, pages 242--249, 1989. Google Scholar
Digital Library
- SML#. http://www.riec.tohoku.ac.jp/smlsharp/.Google Scholar
- J. Bussche, D. Van Gucht, and S. Vansummeren. A crash course on database queries. In Proceedings of the ACM SIGMOD-SIGACT-SIGART Symposiumon Principles of Database Systems, pages 143--154, 2007. Google Scholar
Digital Library
- Limsoon Wong. Kleisli, a functional query system. J. Funct. Program., 10(1):19--56, 2000. Google Scholar
Digital Library
- C. Lécluse and P. Richard. The O2 database programming language. In Proceedings of the International Conference on Very Large Data Bases, pages 423--432, Morgan Kaufmann Publishers Inc, 1989. Google Scholar
Digital Library
Index Terms
Making standard ML a practical database programming language
Recommendations
Making standard ML a practical database programming language
ICFP '11: Proceedings of the 16th ACM SIGPLAN international conference on Functional programmingIntegrating a database query language into a programming language is becoming increasingly important in recently emerging high-level cloud computing and other applications, where efficient and sophisticated data manipulation is required during ...
Practical pluggable types for java
ISSTA '08: Proceedings of the 2008 international symposium on Software testing and analysisThis paper introduces the Checker Framework, which supports adding pluggable type systems to the Java language in a backward-compatible way. A type system designer defines type qualifiers and their semantics, and a compiler plug-in enforces the ...
Making legacy Fortran code type safe through automated program transformation
AbstractFortran is still widely used in scientific computing, and a very large corpus of legacy as well as new code is written in FORTRAN 77. In general this code is not type safe, so that incorrect programs can compile without errors. In this paper, we ...







Comments