Definition at line 59 of file percentrepl.c.
60{
62
64
65 for (const char *sp = instr; *sp; sp++)
66 {
67 if (*sp == '%')
68 {
69 if (sp[1] == '%')
70 {
71
72 sp++;
74 }
75 else if (sp[1] == '\0')
76 {
77
78#ifdef FRONTEND
79 pg_log_error(
"invalid value for parameter \"%s\": \"%s\"", param_name, instr);
82#else
84 errcode(ERRCODE_INVALID_PARAMETER_VALUE),
85 errmsg(
"invalid value for parameter \"%s\": \"%s\"", param_name, instr),
86 errdetail(
"String ends unexpectedly after escape character \"%%\"."));
87#endif
88 }
89 else
90 {
91
92 bool found = false;
93 va_list ap;
94
95 sp++;
96
98 for (const char *lp = letters; *lp; lp++)
99 {
100 char *
val = va_arg(ap,
char *);
101
102 if (*sp == *lp)
103 {
105 {
107 found = true;
108 }
109
110 break;
111 }
112 }
114 if (!found)
115 {
116
117#ifdef FRONTEND
118 pg_log_error(
"invalid value for parameter \"%s\": \"%s\"", param_name, instr);
121#else
123 errcode(ERRCODE_INVALID_PARAMETER_VALUE),
124 errmsg(
"invalid value for parameter \"%s\": \"%s\"", param_name, instr),
125 errdetail(
"String contains unexpected placeholder \"%%%c\".", *sp));
126#endif
127 }
128 }
129 }
130 else
131 {
133 }
134 }
135
137}
int errdetail(const char *fmt,...)
int errcode(int sqlerrcode)
int errmsg(const char *fmt,...)
#define ereport(elevel,...)
#define pg_log_error(...)
#define pg_log_error_detail(...)
void appendStringInfoString(StringInfo str, const char *s)
void appendStringInfoChar(StringInfo str, char ch)
void initStringInfo(StringInfo str)
References appendStringInfoChar(), appendStringInfoString(), StringInfoData::data, ereport, errcode(), errdetail(), errmsg(), ERROR, exit(), initStringInfo(), pg_log_error, pg_log_error_detail, va_end(), va_start(), and val.
Referenced by BuildRestoreCommand(), ExecuteRecoveryCommand(), run_ssl_passphrase_command(), shell_archive_file(), and shell_construct_command().