Skip to content

Commit

Permalink
Merge pull request #33 from uptimejp/fix/pt-config
Browse files Browse the repository at this point in the history
Fix pt-config to parse quoted values correctly.
  • Loading branch information
snaga committed Aug 8, 2015
2 parents 54820ce + e81ac68 commit a089893
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
5 changes: 4 additions & 1 deletion bin/pt-config
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,10 @@ class PostgressqlConf():
return False

def parse(self, line):
m = re.search("(.*=[ ]*')([^']+)('.*)", line)
# quoted value accepts a zero-length string.
m = re.search("(.*=[ ]*')([^']*)('.*)", line)

# non-quoted value
if m is None:
m = re.search("(.*=[ ]*)([^ \t]+)(.*)", line)

Expand Down
22 changes: 22 additions & 0 deletions bin/t/test-pt-config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -233,4 +233,26 @@ function testConfig011()
assertTrue $?
}

# test for quoted string
function testConfig012()
{
OUT=${_SHUNIT_TEST_}.out

pt-config -D $PGDATA --apply set shared_preload_libraries "pg_stat_statements,autoexplain" > $OUT 2>&1
grep ^shared_preload_libraries $PGDATA/postgresql.conf >> $OUT 2>&1

contains "shared_preload_libraries = 'pg_stat_statements'" $OUT
assertTrue $?
contains "shared_preload_libraries = pg_stat_statements" $OUT
assertFalse $?

pt-config -D $PGDATA --apply set log_line_prefix "[%t] %p: %u/%d: " >> $OUT 2>&1
grep ^log_line_prefix $PGDATA/postgresql.conf >> $OUT 2>&1

contains "log_line_prefix = '\[%t\] %p: %u/%d: '" $OUT
assertTrue $?
contains "log_line_prefix = \[%t\] %p: %u/%d: " $OUT
assertFalse $?
}

. shunit2

0 comments on commit a089893

Please sign in to comment.