good morning!!!!
Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
pggat
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Harbor Registry
Model registry
Operate
Environments
Terraform modules
Analyze
Contributor analytics
CI/CD analytics
Repository analytics
Insights
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
gfx
pggat
Commits
b5646107
Commit
b5646107
authored
2 years ago
by
Garet Halliday
Browse files
Options
Downloads
Patches
Plain Diff
run prepared statement on server chosen by query contents
parent
a9ed6083
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
lib/gat/gatling/conn_pool/worker.go
+26
-4
26 additions, 4 deletions
lib/gat/gatling/conn_pool/worker.go
with
26 additions
and
4 deletions
lib/gat/gatling/conn_pool/worker.go
+
26
−
4
View file @
b5646107
...
...
@@ -4,6 +4,7 @@ import (
"context"
"fmt"
"gfx.cafe/gfx/pggat/lib/config"
"gfx.cafe/gfx/pggat/lib/gat/protocol/pg_error"
"log"
"gfx.cafe/gfx/pggat/lib/gat"
...
...
@@ -150,10 +151,31 @@ func (w *worker) z_actually_do_execute(ctx context.Context, client gat.Client, p
return
fmt
.
Errorf
(
"describe('%+v') fail: no server"
,
payload
)
}
defer
srv
.
mu
.
Unlock
()
// execute the query
// for now, use primary
// TODO read the query of the underlying prepared statement and choose server accordingly
target
:=
srv
.
primary
// get the query text
portal
:=
client
.
GetPortal
(
payload
.
Fields
.
Name
)
if
portal
==
nil
{
return
&
pg_error
.
Error
{
Severity
:
pg_error
.
Err
,
Code
:
pg_error
.
ProtocolViolation
,
Message
:
fmt
.
Sprintf
(
"portal '%s' not found"
,
payload
.
Fields
.
Name
),
}
}
ps
:=
client
.
GetPreparedStatement
(
portal
.
Fields
.
PreparedStatement
)
if
ps
==
nil
{
return
&
pg_error
.
Error
{
Severity
:
pg_error
.
Err
,
Code
:
pg_error
.
ProtocolViolation
,
Message
:
fmt
.
Sprintf
(
"prepared statement '%s' not found"
,
ps
.
Fields
.
PreparedStatement
),
}
}
which
,
err
:=
c
.
pool
.
GetRouter
()
.
InferRole
(
ps
.
Fields
.
Query
)
if
err
!=
nil
{
return
err
}
target
:=
srv
.
choose
(
which
)
if
target
==
nil
{
return
fmt
.
Errorf
(
"describe('%+v') fail: no server"
,
payload
)
}
...
...
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