X-Original-To: pgsql-jdbc-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.225.181]) by svr1.postgresql.org (Postfix) with ESMTP id BA3A0CCDE6 for ; Fri, 18 Jul 2003 20:26:21 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (svr5.postgresql.org [64.117.225.181]) (amavisd-new, port 10024) with ESMTP id 81395-04 for ; Fri, 18 Jul 2003 20:26:41 +0000 (GMT) Received: from phoenix.ritterdosreis.br (unknown [200.198.106.115]) by svr1.postgresql.org (Postfix) with ESMTP id 5D07CCBA17 for ; Fri, 18 Jul 2003 17:26:09 -0300 (ADT) Received: from desenv1.ritterdosreis.br (cardinal.ritterdosreis.br [192.168.1.3]) by phoenix.ritterdosreis.br (Postfix) with SMTP id 95B9039C526; Fri, 18 Jul 2003 17:20:28 -0300 (BRT) Date: Fri, 18 Jul 2003 17:22:34 -0300 From: Felipe Schnack To: Darin Ohashi Cc: Darin Ohashi , pgsql-jdbc-list Subject: Re: Prepared Statements Message-Id: <20030718172234.1bf24683.felipes@ritterdosreis.br> In-Reply-To: References: Organization: Ritter dos Reis X-Mailer: Sylpheed version 0.9.3claws2 (GTK+ 1.2.10; i686-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200307/157 X-Sequence-Number: 7541 I believe the main problem is that we would simply break existing code. T= his is a serious issue! If this patch do get applied, I'm a lucky person to= read this list, because I can protect myself from problems in my system kn= owing about this... but lots of people probably will have serious problems = using this new driver versions... On Fri, 18 Jul 2003 16:22:39 -0400 Darin Ohashi wrote: > > I think yes. > > Depends on your definiton of "in general", of course, > > Where I come from, at least "in general", the=20 > > PreparedStatement should=20 > > be able to handle *everything* you can do with sql. >=20 > Well, what I meant by "in general", is more along the lines of "is this > behaviour covered by the spec". Does the JDBC spec explicitly deny this = kind of > behaviour. >=20 > My understanding, which might be wrong, is that "?" is a placeholder for = a data > value and not a placeholder for SQL syntax, so, for example I would never= expect > a PS would be able to do something like this: >=20 > ps :=3D c.prepareStatement( "??" ); > ps.setString( 1, "SELECT * " ); > ps.setString( 2, "FROM table" ); > ps.execute(); >=20 > The final SQL statement produced by a PS should be any valid SQL string, = but a > PS should not have to deal with being able to put that string together fr= om > arbitrary pieces of data. I would be surprised if there was not a docume= nt > somewhere that specified what is and is not valid to pass via a "?". >=20 > Looking at this particular example, it looks to me (of course, I have a l= imited > amount of SQL experience) that "(1,2,3,4)" contains syntax. Using (?,?,?= ,?) the > "?" replace data and that should work. As "(1,2,3,4)" contains syntax, I= don't > think it is a valid thing to substitute in. >=20 > > Depends on the implementation... > > If the backend doesn't support it, the driver should take care of=20 > > working around that > > (e.g. by switching to 'non-precompiled' version in this case)=20 > > until the=20 > > backend is able to support it (I don't see any reason why it=20 > > just cannot=20 > > be done theoretically). >=20 > Well, if you allow syntax to be substituted in to the PS, then the backen= d can't > precompile because it does not have a syntatically complete statement. W= hat you > substitute in could completely change the query optimization.=20 >=20 > >=20 > > > Do other JDBC drivers support this kind of substitution? > > > > > Yes. They do (at least, the ones I worked with do). >=20 > Do they use actual precompiled statements or just with string concats? >=20 > >> I am not going to lose it :-) > > Thanks to the driver being opensource I have control over what I am=20 > > going to lose :-) >=20 > Lose it from the official driver. You can, of course, do what ever you l= ike > with your personal version of the driver. >=20 > >=20 > > > > > >Instead of creating your own driver, why not just subclass=20 > > Statement into > > >something that looks like a PreparedStatement but just glues=20 > > strings together? > > > > > Ummm... because it already exists? That's what postgres=20 > > PreparedStatement does (by default in 7.3, and always in previous=20 > > versions)... >=20 > That is what it currently does, I don't think that is what it will do in = the > future when (if) it actually represents a precompiled statement. >=20 > > No, that's not what I want... > > What I want is an abstraction of the implementation-specific details,= =20 > > that lets me effectively execute sql queries. > > If it can precompile my query, I want it to precompile it. If=20 > > it cannot,=20 > > I can live with that (for a while). > > I just don't want to *know* what it is doing. >=20 > I accept that, but then you have to be willing to live by the rules of th= e spec, > and I suspect this behaviour violates the spec. >=20 > Darin >=20 > ---------------------------(end of broadcast)--------------------------- > TIP 4: Don't 'kill -9' the postmaster --=20 /~\ The ASCII Felipe Schnack (felipes@ritterdosreis.br) \ / Ribbon Campaign Analista de Sistemas X Against HTML Cel.: 51-91287530 / \ Email! Linux Counter #281893 Centro Universit=E1rio Ritter dos Reis http://www.ritterdosreis.br ritter@ritterdosreis.br Fone: 51-32303341