From d44cb9f3367427837f5f5ac43b4801d0d5ef72f9 Mon Sep 17 00:00:00 2001 From: Ole Tange Date: Sat, 21 Mar 2020 19:07:16 +0100 Subject: [PATCH] parallel: CSV uses special DBI->connect() options for subdirs. --- NEWS | 16 +++++++++++----- doc/release_new_version | 2 ++ src/parallel | 10 ++++++++-- testsuite/tests-to-run/parallel-local-1s.sh | 10 ++++++++++ testsuite/tests-to-run/parallel-local-3s.sh | 5 +++-- testsuite/wanted-results/parallel-local-1s | 5 +++++ 6 files changed, 39 insertions(+), 9 deletions(-) diff --git a/NEWS b/NEWS index d323f65b..ccdc9e4c 100644 --- a/NEWS +++ b/NEWS @@ -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 diff --git a/doc/release_new_version b/doc/release_new_version index d459074a..63a77b58 100644 --- a/doc/release_new_version +++ b/doc/release_new_version @@ -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: diff --git a/src/parallel b/src/parallel index 32faac34..80624a33 100755 --- a/src/parallel +++ b/src/parallel @@ -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; diff --git a/testsuite/tests-to-run/parallel-local-1s.sh b/testsuite/tests-to-run/parallel-local-1s.sh index 2fe866a9..384087ea 100644 --- a/testsuite/tests-to-run/parallel-local-1s.sh +++ b/testsuite/tests-to-run/parallel-local-1s.sh @@ -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' diff --git a/testsuite/tests-to-run/parallel-local-3s.sh b/testsuite/tests-to-run/parallel-local-3s.sh index eb4442da..a72aa510 100644 --- a/testsuite/tests-to-run/parallel-local-3s.sh +++ b/testsuite/tests-to-run/parallel-local-3s.sh @@ -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() { diff --git a/testsuite/wanted-results/parallel-local-1s b/testsuite/wanted-results/parallel-local-1s index c481ff77..0e8d9ba0 100644 --- a/testsuite/wanted-results/parallel-local-1s +++ b/testsuite/wanted-results/parallel-local-1s @@ -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/