mirror of
https://github.com/levinsv/pgadmin3.git
synced 2026-05-15 14:15:49 -06:00
Replace bind parameters in Log view
При установленном параметре log_parameter_max_length_on_error есть возможность подставлять в запросы вместо $N значения параметров. В Log View так и происходит. Значения параметров выбираются из поля context.
This commit is contained in:
parent
10333043b8
commit
799b2a70c8
2 changed files with 58 additions and 1 deletions
|
|
@ -544,7 +544,64 @@ Line Storage::getLineParse(const wxString& str, bool csv) {
|
|||
logHint = logDebug;
|
||||
if (!logContext.IsEmpty() && logDetail.IsEmpty())
|
||||
logDetail = logContext;
|
||||
|
||||
if (!logContext.IsEmpty()&& (logContext.BeforeFirst('=').AfterFirst(':')==" $1 ")) {
|
||||
// bind parameter parse
|
||||
int idx = logContext.Find(':');
|
||||
// unnamed portal with parameters: $1 = '15558430', $2 = '70469'
|
||||
#define FIND_DOLLS 1
|
||||
#define FIND_QUOTES 2
|
||||
#define FIND_OUTQUOTES 3
|
||||
#define NUM_PARAMETER 4
|
||||
int mode = FIND_DOLLS;
|
||||
wxString nstr;
|
||||
int n = 0;
|
||||
wxArrayString arS;
|
||||
for (int j = idx+1; j < logContext.Len(); j++) {
|
||||
wxChar c = logContext[j];
|
||||
if (mode == FIND_DOLLS ) {
|
||||
if (c == '$') mode = NUM_PARAMETER;
|
||||
|
||||
continue;
|
||||
}
|
||||
if (mode == NUM_PARAMETER) {
|
||||
if (c != '=') continue;
|
||||
j = j + 2;
|
||||
nstr = "";
|
||||
n++;
|
||||
if (logContext[j]=='\'') mode = FIND_OUTQUOTES;
|
||||
else
|
||||
{
|
||||
// NULL
|
||||
arS.Add("NULL");
|
||||
mode = FIND_DOLLS;
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
if (mode == FIND_OUTQUOTES) {
|
||||
|
||||
if (c != '\'') {
|
||||
nstr.Append(c);
|
||||
continue;
|
||||
}
|
||||
if (((j + 1) < logContext.Len()) && logContext[j + 1] == '\'') {
|
||||
j++;
|
||||
nstr.Append(c);
|
||||
nstr.Append(c);
|
||||
continue;
|
||||
}
|
||||
mode = FIND_DOLLS;
|
||||
arS.Add("'"+nstr+"'");
|
||||
continue;
|
||||
}
|
||||
}
|
||||
// replace $N in query
|
||||
int c = 0;
|
||||
for (int k = arS.GetCount() - 1; k >= 0; k--) {
|
||||
c=c+logDebug.Replace(wxString::Format("$%d",k+1), arS[k]);
|
||||
}
|
||||
if (c>0) logHint = logDebug;
|
||||
}
|
||||
st.logDetail = { static_cast<unsigned short int>(t.Len()),static_cast<unsigned short int>(logDetail.Len()) };
|
||||
t += logDetail;
|
||||
|
||||
|
|
|
|||
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue