mirror of
https://git.savannah.gnu.org/git/parallel.git
synced 2024-11-22 22:17:54 +00:00
sql: renamed .dburl.aliases to .sql/aliases and /etc/sql/aliases.
Fixed bug if DBURL is NULL.
This commit is contained in:
parent
6383459ddb
commit
0a5434c071
|
@ -1,7 +1,8 @@
|
||||||
== SQL ==
|
== SQL ==
|
||||||
|
|
||||||
/etc/sql/aliases
|
Unittest:
|
||||||
~/.sql/aliases
|
dburl = :
|
||||||
|
dburl = null
|
||||||
|
|
||||||
sqlite2 sqlite3 support
|
sqlite2 sqlite3 support
|
||||||
|
|
||||||
|
|
38
src/sql
38
src/sql
|
@ -162,11 +162,11 @@ mysqlssl), Oracle (oracle, ora), PostgreSQL (postgresql, pg, pgsql,
|
||||||
postgres), PostgreSQL with SSL (postgresqlssl, pgs, pgsqlssl,
|
postgres), PostgreSQL with SSL (postgresqlssl, pgs, pgsqlssl,
|
||||||
postgresssl, pgssl, postgresqls, pgsqls, postgress)
|
postgresssl, pgssl, postgresqls, pgsqls, postgress)
|
||||||
|
|
||||||
Aliases must start with ':' and is read from
|
Aliases must start with ':' and are read from
|
||||||
dburl.aliases.dist, dburl.aliases and ~/.dburl.aliases. The user's own
|
/etc/sql/aliases and ~/.sql/aliases. The user's own
|
||||||
~/.dburl.aliases should only be readable by the user.
|
~/.sql/aliases should only be readable by the user.
|
||||||
|
|
||||||
Example of dburl.aliases:
|
Example of aliases:
|
||||||
|
|
||||||
:myalias1 pg://user:pa55w0rd@pg.example.com/db
|
:myalias1 pg://user:pa55w0rd@pg.example.com/db
|
||||||
:myalias2 ora://scott:tiger@ora1.example.com/xe
|
:myalias2 ora://scott:tiger@ora1.example.com/xe
|
||||||
|
@ -334,11 +334,9 @@ installed, GNU B<sql> will have a command history for Oracle.
|
||||||
|
|
||||||
=head1 FILES
|
=head1 FILES
|
||||||
|
|
||||||
~/.dburl.aliases - user's own aliases with DBURLs
|
~/.sql/aliases - user's own aliases with DBURLs
|
||||||
|
|
||||||
dburl.aliases - user's own aliases with DBURLs
|
/etc/sql/aliases - common aliases with DBURLs
|
||||||
|
|
||||||
dburl.aliases.dist - common aliases with DBURLs
|
|
||||||
|
|
||||||
|
|
||||||
=head1 SEE ALSO
|
=head1 SEE ALSO
|
||||||
|
@ -353,8 +351,12 @@ use strict;
|
||||||
parse_options();
|
parse_options();
|
||||||
|
|
||||||
my $pass_through_options = (defined $::opt_p) ? join(" ",@{$::opt_p}) : "";
|
my $pass_through_options = (defined $::opt_p) ? join(" ",@{$::opt_p}) : "";
|
||||||
|
my $dburl_or_alias = shift;
|
||||||
my %dburl = parse_dburl(get_alias(shift));
|
if (not defined $dburl_or_alias) {
|
||||||
|
Usage("No DBURL given");
|
||||||
|
exit -1;
|
||||||
|
}
|
||||||
|
my %dburl = parse_dburl(get_alias($dburl_or_alias));
|
||||||
|
|
||||||
my $interactive_command;
|
my $interactive_command;
|
||||||
my $batch_command;
|
my $batch_command;
|
||||||
|
@ -676,10 +678,20 @@ sub get_alias {
|
||||||
} else {
|
} else {
|
||||||
($path) = $0 =~ m|^(.*)/|;
|
($path) = $0 =~ m|^(.*)/|;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
my @deprecated = ("$ENV{HOME}/.dburl.aliases",
|
||||||
|
"$path/dburl.aliases", "$path/dburl.aliases.dist");
|
||||||
|
for (@deprecated) {
|
||||||
|
if(-r $_) {
|
||||||
|
print STDERR "$_ is deprecated. Use .sql/aliases instead (read man sql)\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
my @urlalias=();
|
my @urlalias=();
|
||||||
|
check_permissions("$ENV{HOME}/.sql/aliases");
|
||||||
check_permissions("$ENV{HOME}/.dburl.aliases");
|
check_permissions("$ENV{HOME}/.dburl.aliases");
|
||||||
my @search=("$ENV{HOME}/.dburl.aliases", "$path/dburl.aliases",
|
my @search = ("$ENV{HOME}/.sql/aliases",
|
||||||
"$path/dburl.aliases.dist");
|
"$ENV{HOME}/.dburl.aliases", "/etc/sql/aliases",
|
||||||
|
"$path/dburl.aliases", "$path/dburl.aliases.dist");
|
||||||
for my $alias_file (@search) {
|
for my $alias_file (@search) {
|
||||||
if(-r $alias_file) {
|
if(-r $alias_file) {
|
||||||
push @urlalias, `cat "$alias_file"`;
|
push @urlalias, `cat "$alias_file"`;
|
||||||
|
@ -749,7 +761,7 @@ sub parse_dburl {
|
||||||
$options{database} = undef_if_empty($6);
|
$options{database} = undef_if_empty($6);
|
||||||
$options{job} = undef_if_empty($7);
|
$options{job} = undef_if_empty($7);
|
||||||
} else {
|
} else {
|
||||||
Usage("$url is not a valid DB-URL");
|
Usage("$url is not a valid DBURL");
|
||||||
exit -1;
|
exit -1;
|
||||||
}
|
}
|
||||||
return %options;
|
return %options;
|
||||||
|
|
Loading…
Reference in a new issue