From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Delivered-To: caml-list@yquem.inria.fr Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by yquem.inria.fr (Postfix) with ESMTP id EB249BCAE for ; Tue, 19 Jul 2005 10:58:30 +0200 (CEST) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id j6J8wUnf025886 for ; Tue, 19 Jul 2005 10:58:30 +0200 Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id KAA10974 for ; Tue, 19 Jul 2005 10:58:29 +0200 (MET DST) Received: from alex.barettalocal.com (h213-255-109-130.albacom.net [213.255.109.130] (may be forged)) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id j6J8wTHx025883 for ; Tue, 19 Jul 2005 10:58:29 +0200 Received: from [127.0.0.1] (localhost.localdomain [127.0.0.1]) by alex.barettalocal.com (Postfix) with ESMTP id DE34F2BAA98; Tue, 19 Jul 2005 08:26:31 +0200 (CEST) Message-ID: <42DC9D16.1080607@barettadeit.com> Date: Tue, 19 Jul 2005 08:26:30 +0200 From: Alex Baretta User-Agent: Debian Thunderbird 1.0.2 (X11/20050331) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Richard Jones , Ocaml Subject: Re: [Caml-list] Idea for another type safe PostgreSQL interface References: <20050718210518.GA10051@furbychan.cocan.org> In-Reply-To: <20050718210518.GA10051@furbychan.cocan.org> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Miltered: at nez-perce with ID 42DCC0B6.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Miltered: at nez-perce with ID 42DCC0B5.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; baretta:01 caml-list:01 subset:01 ocaml:01 abstraction:01 inference:01 ocaml:01 baretta:01 ...:98 wrote:01 compile:01 expression:01 define:01 logical:01 fragments:01 X-Spam-Checker-Version: SpamAssassin 3.0.2 (2004-11-16) on yquem.inria.fr X-Spam-Status: No, score=0.1 required=5.0 tests=FORGED_RCVD_HELO autolearn=disabled version=3.0.2 X-Spam-Level: Richard Jones wrote: > [I just throwing this idea out there to see if people find it > interesting, or want to shoot it down ... There're only fragments of > working code at the moment] > > I'm thinking about a type safe interface to PostgreSQL. One such > interface at the moment is in Xcaml, but it only supports a very small > subset of SQL, and I like to use complex SQL. It seems that there is > a way to support the whole of PostgreSQL's language from within OCaml > programs, in a type safe way. Every once in a while we extend the Embedded SQL with a new feature, but we never planned to support all of PostgreSQL. In fact, what we want to have is abstraction over the actual DB implementation. > The general plan would be to have a camlp4 extension which would use > Postgres's new "PREPARE" feature to actually prepare the statements, > and Postgres's other new feature, "Describe Statement", to pull out > the parameter types and result types from the prepared statement. > This allows the camlp4 extension to replace the statement string with > a type safe expression, and allow type inference to find mismatches. > How a typical program would look is shown at the end of this message. I really think XDBS is the the way to go. You define the schema in a high level language (OO-Entity-Relationship modeling), supporting lower level refinements (logical, physical and virtual schema refinements) and compiling to Ocaml and SQL-DDL. This way, the type safety can be established at compile time without need for a database connection. Also, the type safety does not depend on a specific implementation of SQL, which is usually desireable. Alex -- ********************************************************************* http://www.barettadeit.com/ Baretta DE&IT A division of Baretta SRL tel. +39 02 370 111 55 fax. +39 02 370 111 54 Our technology: The Application System/Xcaml (AS/Xcaml) The FreerP Project