Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
postgres-lambda-diff
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
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
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
Jakob Huber
postgres-lambda-diff
Commits
a1ce88a5
Commit
a1ce88a5
authored
20 years ago
by
Bruce Momjian
Browse files
Options
Downloads
Patches
Plain Diff
Have log_duration only output when log_statement has printed the query.
This handles the new multiple log_statement values. Ed L.
parent
c96c02c7
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
doc/src/sgml/runtime.sgml
+9
-8
9 additions, 8 deletions
doc/src/sgml/runtime.sgml
src/backend/tcop/postgres.c
+12
-2
12 additions, 2 deletions
src/backend/tcop/postgres.c
with
21 additions
and
10 deletions
doc/src/sgml/runtime.sgml
+
9
−
8
View file @
a1ce88a5
<!--
<!--
$PostgreSQL: pgsql/doc/src/sgml/runtime.sgml,v 1.28
7
2004/10/
09 23:12:53 tgl
Exp $
$PostgreSQL: pgsql/doc/src/sgml/runtime.sgml,v 1.28
8
2004/10/
15 16:50:29 momjian
Exp $
-->
-->
<Chapter Id="runtime">
<Chapter Id="runtime">
...
@@ -2355,13 +2355,14 @@ archive_command = 'copy "%p" /mnt/server/archivedir/"%f"' # Win32
...
@@ -2355,13 +2355,14 @@ archive_command = 'copy "%p" /mnt/server/archivedir/"%f"' # Win32
<term><varname>log_duration</varname> (<type>boolean</type>)</term>
<term><varname>log_duration</varname> (<type>boolean</type>)</term>
<listitem>
<listitem>
<para>
<para>
Causes the duration of every completed statement to be logged.
Causes the duration of every completed statement which satisfies
To use this option, it is recommended that you also enable
<varname>log_statement</> to be logged. When using this option,
<varname>log_statement</> and if not using <application>syslog</>
if you are not using <application>syslog</>, it is recommended
log the PID using <varname>log_line_prefix</> so that you
that you log the PID or session ID using <varname>log_line_prefix</>
can link the statement to the duration using the process
or log the session ID so that you can link the statement to the
ID. The default is off. Only superusers can turn off this
duration using the process ID or session ID. The default is off.
option if it is enabled by the administrator.
Only superusers can turn off this option if it is enabled by the
administrator.
</para>
</para>
</listitem>
</listitem>
</varlistentry>
</varlistentry>
...
...
This diff is collapsed.
Click to expand it.
src/backend/tcop/postgres.c
+
12
−
2
View file @
a1ce88a5
...
@@ -8,7 +8,7 @@
...
@@ -8,7 +8,7 @@
*
*
*
*
* IDENTIFICATION
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/tcop/postgres.c,v 1.43
5
2004/10/1
2 21:54:40 petere
Exp $
* $PostgreSQL: pgsql/src/backend/tcop/postgres.c,v 1.43
6
2004/10/1
5 16:50:31 momjian
Exp $
*
*
* NOTES
* NOTES
* this is the "main" module of the postgres backend and
* this is the "main" module of the postgres backend and
...
@@ -81,6 +81,9 @@ bool Log_disconnections = false;
...
@@ -81,6 +81,9 @@ bool Log_disconnections = false;
LogStmtLevel
log_statement
=
LOGSTMT_NONE
;
LogStmtLevel
log_statement
=
LOGSTMT_NONE
;
/* flag indicating if the statement satisfies log_statement */
bool
statement_logged
;
/* GUC variable for maximum stack depth (measured in kilobytes) */
/* GUC variable for maximum stack depth (measured in kilobytes) */
int
max_stack_depth
=
2048
;
int
max_stack_depth
=
2048
;
...
@@ -463,9 +466,13 @@ pg_parse_query(const char *query_string)
...
@@ -463,9 +466,13 @@ pg_parse_query(const char *query_string)
List
*
raw_parsetree_list
;
List
*
raw_parsetree_list
;
ListCell
*
parsetree_item
;
ListCell
*
parsetree_item
;
statement_logged
=
false
;
if
(
log_statement
==
LOGSTMT_ALL
)
if
(
log_statement
==
LOGSTMT_ALL
)
{
ereport
(
LOG
,
ereport
(
LOG
,
(
errmsg
(
"statement: %s"
,
query_string
)));
(
errmsg
(
"statement: %s"
,
query_string
)));
statement_logged
=
true
;
}
if
(
log_parser_stats
)
if
(
log_parser_stats
)
ResetUsage
();
ResetUsage
();
...
@@ -501,6 +508,7 @@ pg_parse_query(const char *query_string)
...
@@ -501,6 +508,7 @@ pg_parse_query(const char *query_string)
{
{
ereport
(
LOG
,
ereport
(
LOG
,
(
errmsg
(
"statement: %s"
,
query_string
)));
(
errmsg
(
"statement: %s"
,
query_string
)));
statement_logged
=
true
;
break
;
break
;
}
}
commandTag
=
CreateCommandTag
(
parsetree
);
commandTag
=
CreateCommandTag
(
parsetree
);
...
@@ -512,6 +520,7 @@ pg_parse_query(const char *query_string)
...
@@ -512,6 +520,7 @@ pg_parse_query(const char *query_string)
{
{
ereport
(
LOG
,
ereport
(
LOG
,
(
errmsg
(
"statement: %s"
,
query_string
)));
(
errmsg
(
"statement: %s"
,
query_string
)));
statement_logged
=
true
;
break
;
break
;
}
}
}
}
...
@@ -1003,7 +1012,8 @@ exec_simple_query(const char *query_string)
...
@@ -1003,7 +1012,8 @@ exec_simple_query(const char *query_string)
}
}
usecs
=
(
long
)
(
stop_t
.
tv_sec
-
start_t
.
tv_sec
)
*
1000000
+
(
long
)
(
stop_t
.
tv_usec
-
start_t
.
tv_usec
);
usecs
=
(
long
)
(
stop_t
.
tv_sec
-
start_t
.
tv_sec
)
*
1000000
+
(
long
)
(
stop_t
.
tv_usec
-
start_t
.
tv_usec
);
if
(
save_log_duration
)
/* Only print duration if we previously printed the statement. */
if
(
statement_logged
&&
save_log_duration
)
ereport
(
LOG
,
ereport
(
LOG
,
(
errmsg
(
"duration: %ld.%03ld ms"
,
(
errmsg
(
"duration: %ld.%03ld ms"
,
(
long
)
((
stop_t
.
tv_sec
-
start_t
.
tv_sec
)
*
1000
+
(
long
)
((
stop_t
.
tv_sec
-
start_t
.
tv_sec
)
*
1000
+
...
...
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