From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Delivered-To: caml-list@yquem.inria.fr Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by yquem.inria.fr (Postfix) with ESMTP id C5E0EBCAE for ; Tue, 19 Jul 2005 14:12:06 +0200 (CEST) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id j6JCC5uU007895 for ; Tue, 19 Jul 2005 14:12:06 +0200 Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id OAA13739 for ; Tue, 19 Jul 2005 14:12:05 +0200 (MET DST) Received: from ciao.gmane.org (main.gmane.org [80.91.229.2]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id j6JCC4oY007892 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NO) for ; Tue, 19 Jul 2005 14:12:05 +0200 Received: from root by ciao.gmane.org with local (Exim 4.43) id 1DuqvH-0000sr-U0 for caml-list@inria.fr; Tue, 19 Jul 2005 14:11:37 +0200 Received: from 194.103.215.249 ([194.103.215.249]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 19 Jul 2005 14:10:07 +0200 Received: from caml.4.jean.claude.bourut by 194.103.215.249 with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 19 Jul 2005 14:10:07 +0200 X-Injected-Via-Gmane: http://gmane.org/ To: caml-list@inria.fr From: jean-claude Subject: Re: Idea for another type safe PostgreSQL interface Date: Tue, 19 Jul 2005 11:55:26 +0000 (UTC) Message-ID: References: <20050718210518.GA10051@furbychan.cocan.org> <42DC9D16.1080607@barettadeit.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Complaints-To: usenet@sea.gmane.org X-Gmane-NNTP-Posting-Host: main.gmane.org User-Agent: Loom/3.14 (http://gmane.org/) X-Loom-IP: 194.103.215.249 (Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.9) Gecko/20050711 Firefox/1.0.5) Sender: news X-Miltered: at concorde with ID 42DCEE15.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Miltered: at concorde with ID 42DCEE14.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; baretta:01 subset:01 ocaml:01 abstraction:01 inference:01 compiler:01 compilation:01 ocaml:01 ...:98 informix:98 sybase:98 mssql:98 wrote:01 writes:01 compile:01 X-Spam-Checker-Version: SpamAssassin 3.0.2 (2004-11-16) on yquem.inria.fr X-Spam-Status: No, score=1.6 required=5.0 tests=RCVD_BY_IP,RCVD_NUMERIC_HELO autolearn=disabled version=3.0.2 X-Spam-Level: * Alex Baretta barettadeit.com> writes: > > 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. > Back in the pre-internet era, Dec implemented a DBMS (Rdb I think), a C++ compiler and a "compile time" coherency check between C++ and Rdb. Their implementation had the following features -1) C++ compilation would read Rdb schema, -2) There was a strong coupling between database schema and C++ program. -3) Moving from test environment to production lead us to rebuild the code, (That’s silly but I could not find a way around it). We just gave up using it. > 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 > Nb: I have never worked with PostgreSQL, BUT, with Oracle, Informix, DB2, sybase, mssql, the full name of a table ( databasename.login.table ) only binds to an entry inside a system catalog. If your application uses several logins, then, checking program structures against database schema can not really occur before login time. If the goal is only a sanity check, then using any reference definition can help, but I don't think it will replase the run time check. Regards,