pltcl tests fail with FreeBSD 13.2

From: Andres Freund <andres(at)anarazel(dot)de>
To: pgsql-hackers(at)postgresql(dot)org
Cc: Nazir Bilal Yavuz <byavuz81(at)gmail(dot)com>, Thomas Munro <thomas(dot)munro(at)gmail(dot)com>
Subject: pltcl tests fail with FreeBSD 13.2
Date: 2023-07-31 19:15:10
Message-ID: 20230731191510.pebqeiuo2sbmlcfh@awork3.anarazel.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

I saw that CI image builds for freebsd were failing, because 13.1, used until
now, is EOL. Update to 13.2, no problem, I thought. Ran a CI run against 13.2
- unfortunately that failed. In pltcl of all places.

https://api.cirrus-ci.com/v1/artifact/task/5275616266682368/testrun/build/testrun/pltcl/regress/regression.diffs

Notably both 13.1 and 13.2 are using tcl 8.6.13.

The code for the relevant function is this:

create function tcl_date_week(int4,int4,int4) returns text as $$
return [clock format [clock scan "$2/$3/$1"] -format "%U"]
$$ language pltcl immutable;

select tcl_date_week(2010,1,26);

It doesn't surprise me that there are problems with above clock scan, it uses
the MM/DD/YYYY format without making that explicit. But why that doesn't work
on freebsd 13.2, I can't explain. It looks like tcl specifies the MM/DD/YYYY
bit for "free format scans":
https://www.tcl.tk/man/tcl8.6/TclCmd/clock.html#M80

It sure looks like freebsd 13.2 tcl is just busted. Notably it can't even
parse what it generates:

echo 'puts [clock scan [clock format [clock seconds] -format "%Y/%m/%d"] -format "%Y/%m/%d"]'|tclsh8.6

Which works on 13.1 (and other operating systems), without a problem.

I used truss as a very basic way to see differences between 13.1 and 13.2 -
the big difference was .2 failing just after
access("/etc/localtime",F_OK) ERR#2 'No such file or directory'
open("/etc/localtime",O_RDONLY,077) ERR#2 'No such file or directory'

whereas 13.1 also saw that, but then continued to

issetugid() = 0 (0x0)
open("/usr/share/zoneinfo/UTC",O_RDONLY,00) = 3 (0x3)
fstat(3,{ mode=-r--r--r-- ,inode=351417,size=118,blksize=32768 }) = 0 (0x0)
...

which made me test specifying the timezone explicitly:
echo 'puts [clock scan [clock format [clock seconds] -format "%Y/%m/%d" -timezone "UTC"] -format "%Y/%m/%d" -timezone "UTC"]'|tclsh8.6

Which, surprise, works.

So does specifying the timezone via the TZ='UTC' environment variable.

I guess there could be a libc behaviour change or such around timezones? I do
see
https://www.freebsd.org/releases/13.2R/relnotes/
"tzcode has been upgraded to version 2022g with improved timezone change detection and reliability fixes."

Greetings,

Andres Freund

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Andrew Dunstan 2023-07-31 19:35:09 Re: [feature]COPY FROM enable FORCE_NULL/FORCE_NOT_NULL on all columns
Previous Message José Neves 2023-07-31 18:41:31 RE: CDC/ETL system on top of logical replication with pgoutput, custom client