|
76 | 76 | #include"common/restricted_token.h" |
77 | 77 | #include"common/string.h" |
78 | 78 | #include"common/username.h" |
| 79 | +#include"fe_utils/option_utils.h" |
79 | 80 | #include"fe_utils/string_utils.h" |
80 | 81 | #include"getopt_long.h" |
81 | 82 | #include"mb/pg_wchar.h" |
@@ -163,8 +164,7 @@ static bool sync_only = false; |
163 | 164 | staticboolshow_setting= false; |
164 | 165 | staticbooldata_checksums= false; |
165 | 166 | staticchar*xlog_dir=NULL; |
166 | | -staticchar*str_wal_segment_size_mb=NULL; |
167 | | -staticintwal_segment_size_mb; |
| 167 | +staticintwal_segment_size_mb= (DEFAULT_XLOG_SEG_SIZE) / (1024*1024); |
168 | 168 |
|
169 | 169 |
|
170 | 170 | /* internal vars */ |
@@ -3258,7 +3258,8 @@ main(int argc, char *argv[]) |
3258 | 3258 | xlog_dir=pg_strdup(optarg); |
3259 | 3259 | break; |
3260 | 3260 | case12: |
3261 | | -str_wal_segment_size_mb=pg_strdup(optarg); |
| 3261 | +if (!option_parse_int(optarg,"--wal-segsize",1,1024,&wal_segment_size_mb)) |
| 3262 | +exit(1); |
3262 | 3263 | break; |
3263 | 3264 | case13: |
3264 | 3265 | noinstructions= true; |
@@ -3348,22 +3349,8 @@ main(int argc, char *argv[]) |
3348 | 3349 |
|
3349 | 3350 | check_need_password(authmethodlocal,authmethodhost); |
3350 | 3351 |
|
3351 | | -/* set wal segment size */ |
3352 | | -if (str_wal_segment_size_mb==NULL) |
3353 | | -wal_segment_size_mb= (DEFAULT_XLOG_SEG_SIZE) / (1024*1024); |
3354 | | -else |
3355 | | -{ |
3356 | | -char*endptr; |
3357 | | - |
3358 | | -/* check that the argument is a number */ |
3359 | | -wal_segment_size_mb=strtol(str_wal_segment_size_mb,&endptr,10); |
3360 | | - |
3361 | | -/* verify that wal segment size is valid */ |
3362 | | -if (endptr==str_wal_segment_size_mb||*endptr!='\0') |
3363 | | -pg_fatal("argument of --wal-segsize must be a number"); |
3364 | | -if (!IsValidWalSegSize(wal_segment_size_mb*1024*1024)) |
3365 | | -pg_fatal("argument of --wal-segsize must be a power of 2 between 1 and 1024"); |
3366 | | -} |
| 3352 | +if (!IsValidWalSegSize(wal_segment_size_mb*1024*1024)) |
| 3353 | +pg_fatal("argument of %s must be a power of 2 between 1 and 1024","--wal-segsize"); |
3367 | 3354 |
|
3368 | 3355 | get_restricted_token(); |
3369 | 3356 |
|
|