parallel: CSV uses special DBI->connect() options for subdirs.

This commit is contained in:
Ole Tange 2020-03-21 19:07:16 +01:00
parent b34b30b566
commit d44cb9f336
6 changed files with 39 additions and 9 deletions

16
NEWS
View file

@ -5,19 +5,25 @@
20200122
* --blocktimeout dur - Time out for reading block when using --pipe. If it takes longer than dur to read a full block, use the partial block read so far.
* --blocktimeout dur - Time out for reading block when using
--pipe. If it takes longer than dur to read a full block, use the
partial block read so far.
* Bug fixes and man page updates.
News about GNU Parallel:
* GNU Parallel course in Copenhagen https://www.prosa.dk/nc/arrangementer/arrangement/gnu-parallel-med-ole-tange/
* GNU Parallel course in Copenhagen
https://www.prosa.dk/nc/arrangementer/arrangement/gnu-parallel-med-ole-tange/
* GNU Parallel course in Århus https://www.prosa.dk/nc/arrangementer/arrangement/gnu-parallel-og-parallelisering-i-unix-shellen/
* GNU Parallel course in Århus
https://www.prosa.dk/nc/arrangementer/arrangement/gnu-parallel-og-parallelisering-i-unix-shellen/
* GNU Parallel pour accélérer vos process sous Linux https://www.yvonh.com/gnu-parallel-pour-accelerer-vos-process-sous-linux/
* GNU Parallel pour accélérer vos process sous Linux
https://www.yvonh.com/gnu-parallel-pour-accelerer-vos-process-sous-linux/
* How to copy a file to multiple directories in Linux https://net2.com/how-to-copy-a-file-to-multiple-directories-in-linux/
* How to copy a file to multiple directories in Linux
https://net2.com/how-to-copy-a-file-to-multiple-directories-in-linux/
* Running linux commands in parallel https://dev.to/voyeg3r/runing-linux-commands-in-parallel-4ff8

View file

@ -227,6 +227,8 @@ Quote of the month:
New in this release:
https://dev.to/saveriomiroddi/running-shell-commands-in-parallel-via-gnu-parallel-3a72
* Bug fixes and man page updates.
News about GNU Parallel:

View file

@ -12246,10 +12246,16 @@ sub new($) {
::error("$driver not supported. Are you missing a perl DBD::$driver module?");
::wait_and_exit(255);
}
my $dbh = DBI->connect($dsn, $userid, $password,
my $dbh;
if($driver eq "CSV") {
# CSV does not use normal dsn
$dbh = DBI->connect("dbi:CSV:", "", "", { f_dir => "$database", })
or die $DBI::errstr;
} else {
$dbh = DBI->connect($dsn, $userid, $password,
{ RaiseError => 1, AutoInactiveDestroy => 1 })
or die $DBI::errstr;
}
$dbh->{'PrintWarn'} = $Global::debug || 0;
$dbh->{'PrintError'} = $Global::debug || 0;
$dbh->{'RaiseError'} = 1;

View file

@ -3971,6 +3971,16 @@ par_sql_colsep() {
::: 'a A' 'b B' 'c C' ::: '1 11' '2 22' '3 33' '4 44' '5 55' '6 66'
}
par_sql_CSV() {
echo '### CSV write to the right place'
rm -rf /tmp/parallel-CSV
mkdir /tmp/parallel-CSV
parallel --sqlandworker csv:///%2Ftmp%2Fparallel-CSV/OK echo ::: 'ran OK'
ls /tmp/parallel-CSV
stdout parallel --sqlandworker csv:///%2Fmust%2Ffail/fail echo ::: 1 |
perl -pe 's/\d/0/g'
}
export -f $(compgen -A function | grep par_)
compgen -A function | grep par_ | LC_ALL=C sort |
parallel --timeout 1000% -j6 --tag -k --joblog /tmp/jl-`basename $0` '{} 2>&1'

View file

@ -286,10 +286,11 @@ par_sqlworker_hostname() {
par_sqlandworker_uninstalled_dbd() {
echo 'bug #56096: dbi-csv no such column'
mkdir -p /tmp/parallel-bug-56096
sudo mv /usr/share/perl5/DBD/CSV.pm /usr/share/perl5/DBD/CSV.pm.gone
parallel --sqlandworker csv:////%2Ftmp%2Flog.csv echo ::: must fail
parallel --sqlandworker csv:///%2Ftmp%2Fparallel-bug-56096/mytable echo ::: must_fail
sudo cp /usr/share/perl5/DBD/CSV.pm.gone /usr/share/perl5/DBD/CSV.pm
parallel --sqlandworker csv:////%2Ftmp%2Flog.csv echo ::: works
parallel --sqlandworker csv:///%2Ftmp%2Fparallel-bug-56096/mytable echo ::: works
}
par_commandline_with_newline() {

View file

@ -573,6 +573,11 @@ par_seqreplace_long_line ### Test --seqreplace and line too long
par_seqreplace_long_line 9 1 1 101
par_seqreplace_long_line 90 1 1 201
par_seqreplace_long_line 1 parallel: Error: Command line too long (309 >= 210) at input 0: 100
par_sql_CSV ### CSV write to the right place
par_sql_CSV ran OK
par_sql_CSV ok
par_sql_CSV DBI connect('','',...) failed: No such directory '/must/fail at /usr/local/bin/parallel line 00000.
par_sql_CSV No such directory '/must/fail at /usr/local/bin/parallel line 00000.
par_sql_colsep ### SQL should add Vn columns for --colsep
par_sql_colsep /a/A/1/11/
par_sql_colsep /a/A/2/22/