Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gXmHI-0000S9-6M for pgsql-general@arkaria.postgresql.org; Fri, 14 Dec 2018 12:09:12 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gXmHG-0002WI-Rr for pgsql-general@arkaria.postgresql.org; Fri, 14 Dec 2018 12:09:10 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gXmHG-0002T1-Db for pgsql-general@lists.postgresql.org; Fri, 14 Dec 2018 12:09:10 +0000 Received: from forward101p.mail.yandex.net ([2a02:6b8:0:1472:2741:0:8b7:101]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gXmHB-0001Lc-ON for pgsql-general@lists.postgresql.org; Fri, 14 Dec 2018 12:09:09 +0000 Received: from mxback15o.mail.yandex.net (mxback15o.mail.yandex.net [IPv6:2a02:6b8:0:1a2d::66]) by forward101p.mail.yandex.net (Yandex) with ESMTP id ABE033282AB5; Fri, 14 Dec 2018 15:09:01 +0300 (MSK) Received: from smtp2o.mail.yandex.net (smtp2o.mail.yandex.net [2a02:6b8:0:1a2d::26]) by mxback15o.mail.yandex.net (nwsmtp/Yandex) with ESMTP id 0yud6SiniF-91EOBTiL; Fri, 14 Dec 2018 15:09:01 +0300 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex.ru; s=mail; t=1544789341; bh=SHngDcUg0ugCMIQDd9zuZShiuS5Z6ieds86k+da9HlU=; h=Date:From:To:Cc:Subject:Message-ID:Reply-To:References: In-Reply-To; b=wfqcGPZqS9sgDAdTV91uWtW155uHl5i3phNyUtUdbQpy0dnl68ws5wlF6onqaUcu+ 3EcJT9VW0tq6sfJ+HtiQk76sM+vDFVEuhYolX9knERNK+1Mwb8OM77JXGuuJ81Vy8u poSRu4A1GNBIHzT3TX9gyRWktdZOSVBsLJN5cjBk= Received: by smtp2o.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id GyB4mJ1KaX-90vWnS4r; Fri, 14 Dec 2018 15:09:00 +0300 (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client certificate not present) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex.ru; s=mail; t=1544789341; bh=SHngDcUg0ugCMIQDd9zuZShiuS5Z6ieds86k+da9HlU=; h=Date:From:To:Cc:Subject:Message-ID:Reply-To:References: In-Reply-To; b=wfqcGPZqS9sgDAdTV91uWtW155uHl5i3phNyUtUdbQpy0dnl68ws5wlF6onqaUcu+ 3EcJT9VW0tq6sfJ+HtiQk76sM+vDFVEuhYolX9knERNK+1Mwb8OM77JXGuuJ81Vy8u poSRu4A1GNBIHzT3TX9gyRWktdZOSVBsLJN5cjBk= Authentication-Results: smtp2o.mail.yandex.net; dkim=pass header.i=@yandex.ru Date: Fri, 14 Dec 2018 15:09:19 +0300 From: Oleg To: Dmitry Igrishin Cc: pgsql-general@lists.postgresql.org Subject: Re: libpq PQexecParams & value placeholders Message-ID: <20181214120919.GB4644@legohost> Reply-To: Oleg References: <20181214113338.GA4644@legohost> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.11.1 (2018-12-01) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On Fri, Dec 14, 2018 at 02:47:12PM +0300, Dmitry Igrishin wrote: > пт, 14 дек. 2018 г. в 14:33, Oleg : > > > > Hi, all. > > > > Do we really need a numeric value placeholders like $1 in command string? > It's a syntax defined at the backend side. > (https://www.postgresql.org/docs/current/sql-prepare.html) I know this, but i can't understand why this approach is used. > > Construction of such string for complex non-static queries is very annoying. > That's why there are libraries like Pgfe > (https://github.com/dmitigr/pgfe) or libpqtypes This is C++ :-(. > (http://libpqtypes.esilo.com/) This is great! PQexecf() is what i need. Why this api is not the part of libpq? Thank you for the link! > > Why do we can't simply use $$ placeholder, which take the next value from an > > array of values? > Because $$ means a dollar-quoted opening tag > (https://www.postgresql.org/docs/current/sql-syntax-lexical.html#SQL-SYNTAX-DOLLAR-QUOTING) Ok. We can use any other placeholder string for such purpose. But not numeric placeholders - these are not convenient. -- Олег Неманов (Oleg Nemanov)