Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
pike
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
pikelang
pike
Commits
2ae270ba
Commit
2ae270ba
authored
7 years ago
by
Stephen R. van den Berg
Browse files
Options
Downloads
Patches
Plain Diff
pgsql: Add optional communicationslog per filedescriptor for debugging.
parent
0da32f28
No related branches found
No related tags found
Loading
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
lib/modules/Sql.pmod/pgsql.h
+3
-0
3 additions, 0 deletions
lib/modules/Sql.pmod/pgsql.h
lib/modules/Sql.pmod/pgsql_util.pmod
+36
-1
36 additions, 1 deletion
lib/modules/Sql.pmod/pgsql_util.pmod
with
39 additions
and
1 deletion
lib/modules/Sql.pmod/pgsql.h
+
3
−
0
View file @
2ae270ba
...
@@ -10,6 +10,9 @@
...
@@ -10,6 +10,9 @@
//#define PG_DEBUGRACE 1
//#define PG_DEBUGRACE 1
//#define PG_STATS 1 // Collect extra usage statistics
//#define PG_STATS 1 // Collect extra usage statistics
#define PG_DEBUGHISTORY 0 // If >0, it is the number of records
// we keep history on the connection
// with the database
#define PG_DEADLOCK_SENTINEL 0 // If >0, defines the number seconds
#define PG_DEADLOCK_SENTINEL 0 // If >0, defines the number seconds
// a lock can be held before the deadlock
// a lock can be held before the deadlock
// report is being dumped to stderr
// report is being dumped to stderr
...
...
This diff is collapsed.
Click to expand it.
lib/modules/Sql.pmod/pgsql_util.pmod
+
36
−
1
View file @
2ae270ba
...
@@ -345,6 +345,22 @@ class conxiin {
...
@@ -345,6 +345,22 @@ class conxiin {
final int procmsg;
final int procmsg;
private int didreadcb;
private int didreadcb;
#if PG_DEBUGHISTORY > 0
final array history = ({});
final int(-1..) input_from(Stdio.Stream stm, void|int(0..) nbytes) {
int oldsize = sizeof(this);
int ret = i::input_from(stm, nbytes);
if (ret) {
Stdio.Buffer tb = Stdio.Buffer(this);
tb->consume(oldsize);
history += ({"<<"+tb->read(ret)});
history = history[<PG_DEBUGHISTORY - 1 ..];
}
return ret;
}
#endif
protected final bool range_error(int howmuch) {
protected final bool range_error(int howmuch) {
#ifdef PG_DEBUG
#ifdef PG_DEBUG
if (howmuch < 0) {
if (howmuch < 0) {
...
@@ -426,6 +442,18 @@ class conxion {
...
@@ -426,6 +442,18 @@ class conxion {
final int queueinidx = -1;
final int queueinidx = -1;
#endif
#endif
#if PG_DEBUGHISTORY > 0
final int(-1..) output_to(Stdio.Stream stm, void|int(0..) nbytes) {
Stdio.Buffer tb = Stdio.Buffer(this);
int ret = o::output_to(stm, nbytes);
if (ret) {
i->history += ({">>" + tb->read(ret)});
i->history = i->history[<PG_DEBUGHISTORY - 1 ..];
}
return ret;
}
#endif
private inline void queueup(sql_result portal) {
private inline void queueup(sql_result portal) {
qportals->write(portal); portal->_synctransact = synctransact;
qportals->write(portal); portal->_synctransact = synctransact;
PD("%d>%O %d %d Queue portal %d bytes\n", socket->query_fd(),
PD("%d>%O %d %d Queue portal %d bytes\n", socket->query_fd(),
...
@@ -769,10 +797,17 @@ class sql_result {
...
@@ -769,10 +797,17 @@ class sql_result {
catch(fd = c->socket->query_fd());
catch(fd = c->socket->query_fd());
res = sprintf("sql_result state: %d numrows: %d eof: %d inflight: %d\n"
res = sprintf("sql_result state: %d numrows: %d eof: %d inflight: %d\n"
"query: %O\n"
"query: %O\n"
#if PG_DEBUGHISTORY > 0
"history: %O\n"
#endif
"fd: %O portalname: %O datarows: %d"
"fd: %O portalname: %O datarows: %d"
" synctransact: %d laststatus: %s\n",
" synctransact: %d laststatus: %s\n",
_state, index, eoffound, inflight,
_state, index, eoffound, inflight,
qalreadyprinted == this ? "..." : _query, fd, _portalname,
qalreadyprinted == this ? "..." : _query,
#if PG_DEBUGHISTORY > 0
qalreadyprinted == this ? 0 : c && c->i->history,
#endif
fd, _portalname,
datarowtypes && sizeof(datarowtypes), _synctransact,
datarowtypes && sizeof(datarowtypes), _synctransact,
statuscmdcomplete
statuscmdcomplete
|| (_unnamedstatementkey ? "*parsing*" : ""));
|| (_unnamedstatementkey ? "*parsing*" : ""));
...
...
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