Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
postgresql-common
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
PostgreSQL
postgresql-common
Commits
e1a8e15d
Commit
e1a8e15d
authored
8 years ago
by
Christoph Berg
📡
Browse files
Options
Downloads
Patches
Plain Diff
pg_conftool: Fix operation when no cluster exists yet.
parent
7f4e0df0
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
debian/changelog
+1
-0
1 addition, 0 deletions
debian/changelog
pg_conftool
+17
-11
17 additions, 11 deletions
pg_conftool
t/007_pg_conftool.t
+13
-6
13 additions, 6 deletions
t/007_pg_conftool.t
with
31 additions
and
17 deletions
debian/changelog
+
1
−
0
View file @
e1a8e15d
...
...
@@ -34,6 +34,7 @@ postgresql-common (183) UNRELEASED; urgency=medium
config snippets.
* t/051_inconsistent_encoding_upgrade.t: Remove, only relevant for <= 8.2.
* logrotate config: Ship as static conffile again and remove ucf handling.
* pg_conftool: Fix operation when no cluster exists yet.
* pg_conftool: --boolean normalizes boolean variable in output; use this in
debian/maintscripts-functions.
* debian/maintscripts-functions: Unconditionally call invoke-rc.d, and drop
...
...
This diff is collapsed.
Click to expand it.
pg_conftool
+
17
−
11
View file @
e1a8e15d
...
...
@@ -68,22 +68,28 @@ for (my $i = 0; $i < @ARGV; $i++) {
help
(
1
,
'
No command given
')
unless
(
defined
$cmdidx
);
my
(
$version
,
$cluster
,
$conffile
);
if
(
$cmdidx
==
0
)
{
if
(
$cmdidx
==
0
)
{
# operate on postgresql.conf in default cluster
(
$version
,
$cluster
)
=
user_cluster_map
();
error
"
No default cluster found
"
unless
(
$cluster
);
$conffile
=
'
postgresql.conf
';
}
elsif
(
$cmdidx
==
1
)
{
(
$version
,
$cluster
)
=
user_cluster_map
();
}
elsif
(
$cmdidx
==
1
)
{
# operate on given file; default cluster must exist if file is relative
$conffile
=
$ARGV
[
0
];
}
elsif
(
$cmdidx
==
2
)
{
unless
(
$conffile
=~
m!^/!
)
{
(
$version
,
$cluster
)
=
user_cluster_map
();
error
"
No default cluster found
"
unless
(
$cluster
);
}
}
elsif
(
$cmdidx
==
2
)
{
# version cluster, postgresql.conf
(
$version
,
$cluster
,
$conffile
)
=
(
$ARGV
[
0
],
$ARGV
[
1
],
'
postgresql.conf
');
}
elsif
(
$cmdidx
==
3
)
{
}
elsif
(
$cmdidx
==
3
)
{
# version cluster conffile
(
$version
,
$cluster
,
$conffile
)
=
(
$ARGV
[
0
],
$ARGV
[
1
],
$ARGV
[
2
]);
}
else
{
help
(
1
,
'
Too many arguments before command
');
}
error
"
Cluster
$version
$cluster
does not exist
"
unless
(
cluster_exists
$version
,
$cluster
);
if
(
$cluster
)
{
# the cluster needs to exist unless an absolute conffile was given
error
"
Cluster
$version
$cluster
does not exist
"
unless
(
cluster_exists
$version
,
$cluster
);
}
splice
@ARGV
,
0
,
$cmdidx
;
# remove everything before the command
$ARGV
[
0
]
=
'
show
'
if
(
$ARGV
[
0
]
eq
'
get
');
# accept alternative variants of some commands
...
...
@@ -106,7 +112,7 @@ if ($ARGV[0] =~ /^(edit)$/) {
if
(
$cmd
eq
'
show
')
{
my
%conf
;
if
(
$conffile
=~
m!/!
)
{
if
(
$conffile
=~
m!
^
/!
)
{
%conf
=
read_conf_file
(
$conffile
);
}
else
{
%conf
=
read_cluster_conf_file
(
$version
,
$cluster
,
$conffile
);
...
...
@@ -129,14 +135,14 @@ if ($cmd eq 'show') {
}
}
elsif
(
$cmd
eq
'
set
')
{
if
(
$conffile
=~
m!/!
)
{
if
(
$conffile
=~
m!
^
/!
)
{
set_conffile_value
(
$conffile
,
$key
,
$value
);
}
else
{
set_conf_value
(
$version
,
$cluster
,
$conffile
,
$key
,
$value
);
}
}
elsif
(
$cmd
eq
'
remove
')
{
if
(
$conffile
=~
m!/!
)
{
if
(
$conffile
=~
m!
^
/!
)
{
disable_conffile_value
(
$conffile
,
$key
);
}
else
{
disable_conf_value
(
$version
,
$cluster
,
$conffile
,
$key
);
...
...
@@ -147,7 +153,7 @@ if ($cmd eq 'show') {
if
(
$ENV
{
EDITOR
})
{
(
$editor
)
=
$ENV
{
EDITOR
}
=~
/(.*)/
;
# untaint
}
if
(
$conffile
=~
m!/!
)
{
if
(
$conffile
=~
m!
^
/!
)
{
system
$editor
,
$conffile
;
}
else
{
system
$editor
,
"
$PgCommon
::confroot/
$version
/
$cluster
/
$conffile
";
...
...
This diff is collapsed.
Click to expand it.
t/007_pg_conftool.t
+
13
−
6
View file @
e1a8e15d
...
...
@@ -3,7 +3,7 @@
use
strict
;
use
warnings
;
use
Test::
More
tests
=>
33
;
use
Test::
More
tests
=>
41
;
use
File::
Temp
qw/tempdir/
;
use
lib
'
.
';
use
PgCommon
;
...
...
@@ -13,7 +13,19 @@ use TestLib;
my
$tdir
=
tempdir
(
CLEANUP
=>
1
);
$ENV
{'
PG_CLUSTER_CONF_ROOT
'}
=
$tdir
;
open
F
,
"
>
$tdir
/different.conf
";
print
F
"
a = '5'
\n
";
print
F
"
#b = '6'
\n
";
close
F
;
note
'
test without cluster
';
is_program_out
0
,
"
pg_conftool show all
",
1
,
"
Error: No default cluster found
\n
";
is_program_out
0
,
"
pg_conftool foo.conf show all
",
1
,
"
Error: No default cluster found
\n
";
is_program_out
0
,
"
pg_conftool
$tdir
/different.conf show all
",
0
,
"
a = 5
\n
";
is_program_out
0
,
"
pg_conftool 9.7 main show all
",
1
,
"
Error: Cluster 9.7 main does not exist
\n
";
my
$version
=
$MAJORS
[
-
1
];
die
"
Tests past this point need PostgreSQL installed
"
unless
(
$version
);
mkdir
"
$tdir
/
$version
";
mkdir
"
$tdir
/
$version
/main
";
...
...
@@ -27,11 +39,6 @@ print F "a = '3'\n";
print
F
"
#b = '4'
\n
";
close
F
;
open
F
,
"
>
$tdir
/different.conf
";
print
F
"
a = '5'
\n
";
print
F
"
#b = '6'
\n
";
close
F
;
sub
pgconf
{
undef
$/
;
open
F
,
"
$tdir
/
$version
/main/postgresql.conf
";
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment