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 1nqziD-0005Bh-2u for pgsql-general@arkaria.postgresql.org; Tue, 17 May 2022 16:06:17 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1nqziB-0007ku-Pz for pgsql-general@arkaria.postgresql.org; Tue, 17 May 2022 16:06:15 +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 1nqziB-0007k4-FX for pgsql-general@lists.postgresql.org; Tue, 17 May 2022 16:06:15 +0000 Received: from wout3-smtp.messagingengine.com ([64.147.123.19]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nqzi8-0003QL-Qx for pgsql-general@lists.postgresql.org; Tue, 17 May 2022 16:06:14 +0000 Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.west.internal (Postfix) with ESMTP id 8CE24320098F; Tue, 17 May 2022 12:06:11 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute3.internal (MEProxy); Tue, 17 May 2022 12:06:11 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aklaver.com; h= cc:content-transfer-encoding:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to; s=fm3; t=1652803571; x= 1652889971; bh=XChNY7Vow8JoTOnixM/ExecAMlWYlZnoanA++XzD6Ug=; b=T RZYq0aiVbOv0xk72rDcQ7fQB2nvDM4B1dWx98lSktdv9iQ07I58jziBBhftf0Z45 Vrmq3nAg/Syu0PYJM5mX3+vyg/FV51TQ6Q83Ik/P70hkHVcfhR1HfIf41UFIJ/+s ylD4K0Pu0+2IiA0yfPkM9m8mwS6OsE8VujlghYUihalM8Lv98rpXqzW3hV4W1rTO LzmmksALA7p0DK8R+DHNijamttzRWgRUAYmLmGbVnTRRR4CFRI4Oof8CSnPaeJ8e +5HcHRV9FpEI0p+ouu7n2m0vj0dItpYVap7zGcQKcdRnUNOKHTQre+15LCXap0cR HROMxiJqSHqa3NxeFSUXA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:date:feedback-id:feedback-id:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:sender :subject:subject:to:to:x-me-proxy:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm1; t=1652803571; x=1652889971; bh=X ChNY7Vow8JoTOnixM/ExecAMlWYlZnoanA++XzD6Ug=; b=JWLtsb4Vma8SUHn8g hHc0JIzoUrKxzJMb6KVr2AHMAKSgITAkP1D5K1dcrDJ4BZfdlJxFvWzC4pMZQiAN 6yjyNGet+EQm5Xld4cph49yUmOHmv4ZwopnaZPWFqesVA7rFUDSvWRGIcsCzKbKI Z+TshIVj+Hg8poiJKHnamgnvvbv/dE3BnyIvvdbYAO0VbAQQlBjKYe/5umJpgqxE gIW7w9czj5nPFIgxzROQpn5D1eUMswC/lTUl2l9VPCzr7mqEI61As/nT94s4TnLB LnHIsbJ29StyP34A2lojGPanbDZh61+kMka7t/a3UuQkyqTjES7bapYzhgk7NRsm 12nJA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrheejgdelfecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecunecujfgurhepkfffgggfuffvfhfhjggtgfesthekre dttdefjeenucfhrhhomheptegurhhirghnucfmlhgrvhgvrhcuoegrughrihgrnhdrkhhl rghvvghrsegrkhhlrghvvghrrdgtohhmqeenucggtffrrghtthgvrhhnpeelkeegjefhke etheefudevteehiedvudehkeduleetfedvffeuhedtvdegtdeffeenucffohhmrghinhep phhoshhtghhrvghsqhhlrdhorhhgnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrg hmpehmrghilhhfrhhomheprggurhhirghnrdhklhgrvhgvrhesrghklhgrvhgvrhdrtgho mh X-ME-Proxy: Feedback-ID: i76984098:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 17 May 2022 12:06:10 -0400 (EDT) Message-ID: <6a038286-e53c-13e8-d57a-a6b9183d23aa@aklaver.com> Date: Tue, 17 May 2022 09:06:09 -0700 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.9.0 Subject: Re: TO_DATE function between PostgreSQL 8.2 and 9.4 Content-Language: en-US To: gzh , pgsql-general@lists.postgresql.org References: <35162944.7eee.180d2badd7c.Coremail.gzhcoder@126.com> From: Adrian Klaver In-Reply-To: <35162944.7eee.180d2badd7c.Coremail.gzhcoder@126.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 5/17/22 08:55, gzh wrote: > Hi, > > I have had a Perl Website working for 7 years and have had no problems > > until at the weekend I replace my database server with a newer one. > > Database server (old): PostgreSQL 8.2 32bit > > Database server (new): PostgreSQL 9.4 64bit You do know 9.4 is 2 years past EOL. > > Of course, the most reliable way to deal with it is to > > rewrite the application or SQL to handle types strictly, > > but the application is large and rewrite is a terrible job. > > > Is there any easy way to maintain compatibility? Not really this jump went through the 8.3 type casting changes: https://www.postgresql.org/docs/8.3/release-8-3.html In particular: " Non-character data types are no longer automatically cast to TEXT (Peter, Tom) Previously, if a non-character value was supplied to an operator or function that requires text input, it was automatically cast to text, for most (though not all) built-in data types. This no longer happens: an explicit cast to text is now required for all non-character-string types. For example, these expressions formerly worked: substr(current_date, 1, 4) 23 LIKE '2%' but will now draw "function does not exist" and "operator does not exist" errors respectively. Use an explicit cast instead: substr(current_date::text, 1, 4) 23::text LIKE '2%' (Of course, you can use the more verbose CAST() syntax too.) The reason for the change is that these automatic casts too often caused surprising behavior. An example is that in previous releases, this expression was accepted but did not do what was expected: current_date < 2017-11-17 This is actually comparing a date to an integer, which should be (and now is) rejected — but in the presence of automatic casts both sides were cast to text and a textual comparison was done, because the text < text operator was able to match the expression when no other < operator could. Types char(n) and varchar(n) still cast to text automatically. Also, automatic casting to text still works for inputs to the concatenation (||) operator, so long as least one input is a character-string type. " > > Regards, > > -- > > gzh > > > > -- Adrian Klaver adrian.klaver@aklaver.com