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 1gYJKS-0003zV-4F for pgsql-general@arkaria.postgresql.org; Sat, 15 Dec 2018 23:26:40 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gYJKO-0006a1-PL for pgsql-general@arkaria.postgresql.org; Sat, 15 Dec 2018 23:26:36 +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 1gYJKM-0006TJ-NP for pgsql-general@lists.postgresql.org; Sat, 15 Dec 2018 23:26:36 +0000 Received: from wout2-smtp.messagingengine.com ([64.147.123.25]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gYJKE-0005IF-Ou for pgsql-general@lists.postgresql.org; Sat, 15 Dec 2018 23:26:33 +0000 Received: from compute2.internal (compute2.nyi.internal [10.202.2.42]) by mailout.west.internal (Postfix) with ESMTP id E544FCC4 for ; Sat, 15 Dec 2018 18:26:24 -0500 (EST) Received: from web4 ([10.202.2.214]) by compute2.internal (MEProxy); Sat, 15 Dec 2018 18:26:25 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fastmail.com; h= message-id:from:to:mime-version:content-transfer-encoding :content-type:date:subject; s=fm1; bh=Oed0sZh3/Q9yoipSb5//Xxs3OM rhgNJm4o3O4wEZC5Y=; b=cw6BlyG1N16jS6nkGmsbpi4ihGwRT0OMkyWUOGeqyH 4oVCEFF5qKGawYqKXoEV2zxlc+8iUCKtniDjkecDua56TLUV2cZx0X9rQaWvToCM TqH4BurgSDNaB537VOHAL1B2LrtBZnjPIgIY85PnAAoML4vXq3chzpsKGVw3S2bs y0dAtullFXeP+GcIUnE6IqM+Lwn/QT7Qdy0Vcso6MF3oHTS5EprAEGrTVUKpg65R U+mfSjTp5E3oEEaMH4qS6NJj4336s31nKE7U8svMwOk6LFSSNbZ/nEKuScWA5tve walq+oELVEm+UQe+ra1e+PrnYLLTWWQjH6oNcpSskFPw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding:content-type :date:from:message-id:mime-version:subject:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm1; bh=Oed0sZ h3/Q9yoipSb5//Xxs3OMrhgNJm4o3O4wEZC5Y=; b=c4wztBb8V4Iz4I9veHiOne 977nLUUzyrEkLeJ1UjBxGQCLnPnYhuAFvPZnDwR8FDRcUXIWnvhNHfhqqJVt9GIy vYrEqJSbkLpVV4Uc29p2AXxudOYKyuyuFKW9aExVm46qYTnfiazKQaEdyzDzWNez C8bGYEpykZ0sHPUACatVlo8RabS56T7ZTlxgaP43y22oP2sAoqcsoy9j8taSy8sp ftq1qDnShWX1onCZOZGsoiZB0rBGQf84PUVYzE65NPVdshP97Ph7j1wTutMTQ6tI MCDLHj2YwUc8BKUKeBwJbDUTS+aIrbkWdYFPQGaFfA2FYk2nbhvpBdyQrah93V8w == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedtkedrudehjedgudejgecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfhuthenuceurghilhhouhhtmecu fedttdenucenucfjughrpefkhffvggfgtgfofffusegrjeerreertdejnecuhfhrohhmpe ftrghvihcumfhrihhshhhnrgcuoehsrhhkrhhishhhnhgrsehfrghsthhmrghilhdrtgho mheqnecurfgrrhgrmhepmhgrihhlfhhrohhmpehsrhhkrhhishhhnhgrsehfrghsthhmrg hilhdrtghomhenucevlhhushhtvghrufhiiigvpedt X-ME-Proxy: Received: by mailuser.nyi.internal (Postfix, from userid 99) id 208B5BA782; Sat, 15 Dec 2018 18:26:24 -0500 (EST) Message-Id: <1544916384.3079614.1610261080.7F8C1B97@webmail.messagingengine.com> From: Ravi Krishna To: "pgsql-general" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: multipart/alternative; boundary="_----------=_154491638430796140" X-Mailer: MessagingEngine.com Webmail Interface - ajax-2f590f9a Date: Sat, 15 Dec 2018 18:26:24 -0500 Subject: date_trunc not immutable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk This is a multi-part message in MIME format. --_----------=_154491638430796140 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Version: PG 10.6 on AWS Linux. I am trying to create an index on function date_trunc('month',timestamp) PG is complaining that the function must be marked as IMMUTABLE. So I assume that date_trunc is not marked as immutable. Definition of immutable from PG documentation =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D All functions and operators used in an index definition must be "immutable", that is, their results must depend only on their arguments and never on any outside influence (such as the contents of another table or the current time). This restriction ensures that the behavior of the index is well-defined. To use a user-defined function in an index expression or WHERE clause, remember to mark the function immutable when you create it.=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D What am I missing?=C2=A0 date_trunc will always return the same value for a given value. Not sure how I can mark a PG function as immutable. --_----------=_154491638430796140 Content-Transfer-Encoding: 7bit Content-Type: text/html; charset="utf-8"
Version: PG 10.6 on AWS Linux.

I am trying to create an index on function date_trunc('month',timestamp)

PG is complaining that the function must be marked as IMMUTABLE.  So I assume that date_trunc is not marked as immutable.

Definition of immutable from PG documentation
====================================

All functions and operators used in an index definition must be "immutable", that is, their results must depend only on their arguments and never on any outside influence (such as the contents of another table or the current time). This restriction ensures that the behavior of the index is well-defined. To use a user-defined function in an index expression or WHERE clause, remember to mark the function immutable when you create it.
===================================
What am I missing?  date_trunc will always return the same value for a given value. Not sure how I can mark a PG function as immutable.  
--_----------=_154491638430796140--