On 1/19/22 21:18, Andres Freund wrote: > Hi, > > On 2022-01-19 09:42:31 -0800, Andres Freund wrote: >> Both ours have this. Unfortunately on windows cp doesn't natively >> exist. Although git does provide it. I tried a few things that appear to be >> natively available (time is best of three executions): >> >> gnu cp from git, cp -a tmp_install\initdb_template t\ >> 670ms >> >> xcopy.exe /E /Q tmp_install\initdb_template t\ >> 638ms > This errors out if there's any forward slashes in paths, thinking it's a > flag. Seems out. > > >> robocopy /e /NFL /NDL tmp_install\initdb_template t\ >> 575ms >> >> So I guess we could use robocopy? That's shipped as part of windows starting >> in >> windows 10... xcopy has been there for longer, so I might just default to >> that. > It's part of of the OS back to at least windows 2016. I've found some random > links on the webs saying that it's included "This command is available in > Vista and Windows 7 by default. For Windows XP and Server 2003 this tool can > be downloaded as part of Server 2003 Windows Resource Kit tools. ". > > Given that our oldest supported msvc version only runs on Windows 7 upwards > [2], I think we should be good? > > > Alternatively we could lift copydir() to src/common? But that seems like a bit > more work than I want to put in. > > > For a second I was thinking that using something like copy --reflink=auto > could make a lot of sense for machines like florican, removing most of the IO > from a "templated initdb". But it looks like freebsd doesn't have that, and > it'd be a pain to figure out whether cp has --reflink.
FYI, the buildfarm code has this. It doesn't need backslashed paths, you just need to quote the paths, which you should probably do anyway: sub copydir { my ($from, $to, $logfile) = @_; my ($cp, $rd); if ($PGBuild::conf{using_msvc}) { $cp = "robocopy /nfl /ndl /np /e /sec "; $rd = qq{/LOG+:"$logfile" >nul}; } else { $cp = "cp -r"; $rd = qq{> "$logfile"}; } system(qq{$cp "$from" "$to" $rd 2>&1}); ## no critic (RequireLocalizedPunctuationVars) $? = 0 if ($cp =~ /robocopy/ && $? >> 8 == 1); return; } cheers andrew -- Andrew Dunstan EDB: https://www.enterprisedb.com