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 1kMjoQ-0000Ej-TT for pgsql-general@arkaria.postgresql.org; Mon, 28 Sep 2020 03:26:50 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1kMjoP-0001dE-HC for pgsql-general@arkaria.postgresql.org; Mon, 28 Sep 2020 03:26:49 +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 1kMjoO-0001d6-Nw for pgsql-general@lists.postgresql.org; Mon, 28 Sep 2020 03:26:48 +0000 Received: from mail-pf1-x441.google.com ([2607:f8b0:4864:20::441]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1kMjoM-0001Ip-54 for pgsql-general@lists.postgresql.org; Mon, 28 Sep 2020 03:26:47 +0000 Received: by mail-pf1-x441.google.com with SMTP id w7so8081078pfi.4 for ; Sun, 27 Sep 2020 20:26:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ardentperf-com.20150623.gappssmtp.com; s=20150623; h=subject:from:to:references:message-id:date:user-agent:mime-version :in-reply-to:content-language:content-transfer-encoding; bh=kEAs+b6+svN0xiURRrhtdX6mnyMGgLZteS7l3AOIDtE=; b=P8b716qB2l+dPddlqMNEbJEC6qMTok1e2qs5TpMpORHEEeb1DUl28wByjXNWJ0VeJH 7UqXvkVRB9CjTnKsPUl/E6TQdojVlxFKUHKkYxIwEN34/KEc+QJ4K6jNhBQ7KBmAafFq 6ASytVDS6322MzHqgpQemX6UdN98QCGcL8UVb5OZ08XZe+zWNHd7GV00ztBM4axgVhHi SN6XELw2WUFLE3Z6iSNEmNS3FZmh7gICFT42j8iCYTb/CiRuAQt7pXCraqhYOEa1lqRY pMG/dG0KdMeyol2TvouGaKy5MiMi+Y0VcdXIpyw5rGl0NP9ESVVGZD3X7Y4RCEslQbmY mHhA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:from:to:references:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=kEAs+b6+svN0xiURRrhtdX6mnyMGgLZteS7l3AOIDtE=; b=DCFxqbfIiXMQ8Q1puKyb6juhVcFoGZwY+wE6Vgij+ozQVwO0O6Jrm8L3Re11IUo/or nX0ciW5VmBY+Kg4DO/wHT+FxWbPHUA6fXgWvjVUyQpWW+O1Kr9f3ZPB+ZamEHspkJLsd Fxd2R2iN9Bmv0YLbbALx2jVFpyDUkF7rjxiKBhWNPQxvPQ3UWJmNp84qTuNuehK5DP23 QaJsAZkWc7zGOmVo5aAvwqZh+l3lHLqJ/sA8CRMi1xWbKqpQf97+Q4Ti+i+/c8YmpGss pGKjfHCOEn+bedyKi2yLTcAKX5lH3JCQsn0vgdmGZZwmmatTwLYbx1/pCBL+15H1XvfO sJ9A== X-Gm-Message-State: AOAM533eTRDickJFIk6Ki67x1qDKKTGjAWDCCRaR/Eq3e1bKcJXlBji4 UDJwx3hnLkX8Z0iwEpIt0l84SX/2G52VvA== X-Google-Smtp-Source: ABdhPJx/+KpuHg3TfhwYN5SlAn94AjEdJPG4afem5wPPR8/ZXb/JPSWykE5ZNtpXIsWZTs3yUdAOYw== X-Received: by 2002:a17:902:a618:b029:d2:6379:ac0c with SMTP id u24-20020a170902a618b02900d26379ac0cmr9585516plq.82.1601263603687; Sun, 27 Sep 2020 20:26:43 -0700 (PDT) Received: from 186590ce269b.ant.amazon.com ([205.251.233.51]) by smtp.gmail.com with ESMTPSA id l2sm5336452pjy.3.2020.09.27.20.26.42 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 27 Sep 2020 20:26:42 -0700 (PDT) Subject: Re: Returning timestamp with timezone at specified timezone irrespective of client timezone From: Jeremy Schneider To: Ron , pgsql-general@lists.postgresql.org References: <3af9fdd2-b622-426a-8e1e-aeab1bee8493@www.fastmail.com> <6b269cb9-5572-acaa-de9c-fe1c705fed11@gmail.com> <4199d0ba-564d-c8a1-5d34-17cf06e022bc@ardentperf.com> Message-ID: Date: Sun, 27 Sep 2020 20:26:42 -0700 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:68.0) Gecko/20100101 Thunderbird/68.12.0 MIME-Version: 1.0 In-Reply-To: <4199d0ba-564d-c8a1-5d34-17cf06e022bc@ardentperf.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 9/27/20 20:13, Jeremy Schneider wrote: > create or replace function to_char( > v_tstz timestamp with time zone > ,v_format text > ,v_tz text > ) returns text language plpgsql > immutable parallel safe > as $$ > begin > perform set_config('timezone',v_tz,true); > return to_char(v_tstz,v_format); > end; > $$ > ; Just occurred to me, I don't know if this is actually parallel safe. I'm not sure how transaction-level session configuration is handled inside parallel workers. Might be best to leave off the "parallel safe" flag from the function for now. -J -- http://about.me/jeremy_schneider