Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jTRBM-0007i1-4m for pgsql-interfaces@arkaria.postgresql.org; Tue, 28 Apr 2020 14:25:56 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1jTRBK-0002ls-T1 for pgsql-interfaces@arkaria.postgresql.org; Tue, 28 Apr 2020 14:25:54 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jTRBK-0002ll-NP for pgsql-interfaces@lists.postgresql.org; Tue, 28 Apr 2020 14:25:54 +0000 Received: from forward5-smtp.messagingengine.com ([66.111.4.239]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jTRBH-0001cp-RF for pgsql-interfaces@lists.postgresql.org; Tue, 28 Apr 2020 14:25:53 +0000 Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailforward.nyi.internal (Postfix) with ESMTP id 4079119405F2; Tue, 28 Apr 2020 10:25:50 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute1.internal (MEProxy); Tue, 28 Apr 2020 10:25:50 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm2; bh=vtBueIPmVUyEx9gFXBmw1+tqTwBsFhikfyzmkT7/U CY=; b=jiyQgQfPScHA16r0HYL09Pq+RUx8wZBofmkw37BHMwc6RQ46Erv2/UNWc neDa926P062LRtgDtXQP8/ImiXF0ur+gOSzk0DWYKRxJYCnrh5PrXoW4X2At9aQi CrAQ5kWV3gWXiCDADruQLPfcBxTvIELnA63Jw9amNz0iq4hoKtzQEIe6NuBa/78e Oav1GK2u1gCWv4Cw2EtNNFC1Ojb3a+K37beixnTPiUmibVJOpC9Wx7XFRqTIjmOU Hv5k7pdqiI0s1ZmFunQKdAcdRRHToPzwHixA4W+m3mWDD5Nj6w10wAlj+Qef4dcr 5oIcfPO46SqTqd4x4HhvpqQf2dUqQ== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduhedriedugdejhecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecunecujfgurhepuffvfhfhohfkffgfgggjtgfgsehtke ertddtfeejnecuhfhrohhmpefrvghtvghrucfgihhsvghnthhrrghuthcuoehpvghtvghr rdgvihhsvghnthhrrghuthesvdhnughquhgrughrrghnthdrtghomheqnecuffhomhgrih hnpedvnhguqhhurggurhgrnhhtrdgtohhmnecukfhppeelfedrvdegfedriedrvdeguden ucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehpvghtvg hrrdgvihhsvghnthhrrghuthesvdhnughquhgrughrrghnthdrtghomh X-ME-Proxy: Received: from april.pezone.net (p5df306f1.dip0.t-ipconnect.de [93.243.6.241]) by mail.messagingengine.com (Postfix) with ESMTPA id 1CA303065E8B; Tue, 28 Apr 2020 10:25:48 -0400 (EDT) Subject: Re: How to insert default value with libpq? To: sanpi+postgersql@homecomputing.fr, pgsql-interfaces@lists.postgresql.org References: From: Peter Eisentraut Organization: 2ndQuadrant Message-ID: <4aad674b-64c1-61d4-42f1-0adb292ee989@2ndquadrant.com> Date: Tue, 28 Apr 2020 16:25:48 +0200 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 2020-04-27 15:02, sanpi+postgersql@homecomputing.fr wrote: > I would like to insert the default value for a field with libpq, but > inserting null or "default" doesn’t work. You cannot represent that using query parameters (PQexecParams). Query parameters always mean, use this rather than the default value. To do what you want either write DEFAULT or leave off the column altogether, for example INSERT INTO test (id) VALUES (DEFAULT) but this needs to be pasted into the query string, not passed as a parameter. -- Peter Eisentraut http://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services