X-Original-To: pgsql-interfaces-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 066F2D1B192 for ; Thu, 10 Jun 2004 11:56:35 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 58920-10 for ; Thu, 10 Jun 2004 14:56:36 +0000 (GMT) Received: from smtp-out1.xs4all.nl (smtp-out1.xs4all.nl [194.109.24.11]) by svr1.postgresql.org (Postfix) with ESMTP id 2C094D1B17B for ; Thu, 10 Jun 2004 11:56:31 -0300 (ADT) Received: from xs1.xs4all.nl (xs1.xs4all.nl [194.109.21.2]) by smtp-out1.xs4all.nl (8.12.10/8.12.10) with ESMTP id i5AEuZL6016165; Thu, 10 Jun 2004 16:56:35 +0200 (CEST) Received: from xs1.xs4all.nl (jtv@localhost.xs4all.nl [127.0.0.1]) by xs1.xs4all.nl (8.12.10/8.12.10) with ESMTP id i5AEuYfr012116; Thu, 10 Jun 2004 16:56:34 +0200 (CEST) (envelope-from jtv@xs4all.nl) Received: (from jtv@localhost) by xs1.xs4all.nl (8.12.10/8.12.9/Submit) id i5AEuTSH012096; Thu, 10 Jun 2004 16:56:29 +0200 (CEST) (envelope-from jtv) Date: Thu, 10 Jun 2004 16:56:29 +0200 From: "Jeroen T. Vermeulen" To: Tom Lane Cc: David Stanaway , pgsql-interfaces@postgresql.org Subject: Re: Problem with PQexecPrepared Message-ID: <20040610145629.GC27490@xs4all.nl> Mail-Followup-To: Tom Lane , David Stanaway , pgsql-interfaces@postgresql.org References: <1086817452.10544.5.camel@dmxnocws13.dialmex.net> <20040609222114.GI91662@xs4all.nl> <1086820694.10544.14.camel@dmxnocws13.dialmex.net> <20133.1086845652@sss.pgh.pa.us> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20133.1086845652@sss.pgh.pa.us> User-Agent: Mutt/1.4.1i X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200406/27 X-Sequence-Number: 4955 On Thu, Jun 10, 2004 at 01:34:12AM -0400, Tom Lane wrote: > David Stanaway writes: > > If the prototype had been for const char** I would not have needed to > > change anything, the API author I guess is being thorough. > > The author was me, and I didn't think I was creating any problems by > const-ifying the declaration :-(. Jerome, are you sure this isn't > a compiler glitch? I really have a problem with the notion that a > library routine can over-constify its input declarations... I don't think this is a compiler glitch. The way the C type system works (well, in its current form anyway) was thought out pretty well and I wouldn't bet on gcc getting it wrong. You can't hoist const qualifiers across pointers, because the constness of a pointer is a very different thing from the constness of whatever it points to. The former can be converted implicitly in this case, but the latter cannot because it's at least as fundamental a property of the pointer's type as the "char" is. It's hidden away a level too deep to meddle with, if you will. This particular usage (converting "TYPE **" to "const TYPE *const *") might probably have been allowed as a special case, but such exceptions make for convoluted type systems and perhaps even paradoxes. Compilers used to be full of such ad-hockery IIRC, and the standardization process got rid of it so that all compilers could implement a single, consistent language. And as the poem goes, there was dancing in the dock; and a day of celebration was commanded in Bangkok. I wouldn't say that the library routine over-constified the parameter either. Think about it: what other type could you possibly give it? It's a char const *const * by nature, and there's no point in denying it. Whether this problem turns up in practice probably depends a lot on one's programming style: const char **array = malloc(strings * sizeof(*array)); for (n=0; n