Skip to content

Commit 53fcdf7

Browse files
- Rapid devlopment enabled.
1 parent 788bc5a commit 53fcdf7

File tree

6 files changed

+36
-10
lines changed

6 files changed

+36
-10
lines changed

.vscode/launch.json

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -355,6 +355,16 @@
355355
"true",
356356
"false"
357357
]
358+
},
359+
{
360+
"type": "pickString",
361+
"id": "serverDebugPublish",
362+
"description": "postgres server publish debug messages",
363+
"default": "true",
364+
"options": [
365+
"true",
366+
"false"
367+
]
358368
}
359369
],
360370
"configurations": [
@@ -436,7 +446,8 @@
436446
"--namespaces=${input:namespaceString}",
437447
"--sqlBackend=${input:sqlBackendString}",
438448
"--dbInternal=${input:dbInternalString}",
439-
"--export.alias=${input:exportAliasString}"
449+
"--export.alias=${input:exportAliasString}",
450+
"--pgsrv.debug.enable=${input:serverDebugPublish}",
440451
],
441452
},
442453
{
@@ -456,7 +467,8 @@
456467
"--sqlBackend=${input:sqlBackendString}",
457468
"--dbInternal=${input:dbInternalString}",
458469
"--pgsrv.tls=${input:pgsrvTlsString}",
459-
"--export.alias=${input:exportAliasString}"
470+
"--export.alias=${input:exportAliasString}",
471+
"--pgsrv.debug.enable=${input:serverDebugPublish}",
460472
],
461473
},
462474
{

go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ require (
1919
github.com/spf13/cobra v1.4.0
2020
github.com/spf13/pflag v1.0.5
2121
github.com/spf13/viper v1.10.1
22-
github.com/stackql/any-sdk v0.1.2-alpha37
22+
github.com/stackql/any-sdk v0.1.2-beta01
2323
github.com/stackql/go-suffix-map v0.0.1-alpha01
24-
github.com/stackql/psql-wire v0.1.1-beta20
24+
github.com/stackql/psql-wire v0.1.1-beta22
2525
github.com/stackql/stackql-parser v0.0.14-alpha05
2626
github.com/stretchr/testify v1.10.0
2727
golang.org/x/sync v0.10.0

go.sum

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -482,12 +482,12 @@ github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
482482
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
483483
github.com/spf13/viper v1.10.1 h1:nuJZuYpG7gTj/XqiUwg8bA0cp1+M2mC3J4g5luUYBKk=
484484
github.com/spf13/viper v1.10.1/go.mod h1:IGlFPqhNAPKRxohIzWpI5QEy4kuI7tcl5WvR+8qy1rU=
485-
github.com/stackql/any-sdk v0.1.2-alpha37 h1:bvU576YCwqtjztMD4wSpgj//StNH8qGoBRBnN6uOH1I=
486-
github.com/stackql/any-sdk v0.1.2-alpha37/go.mod h1:4jYKpPoX2GWEK+qBnlGLvr8SUfndiYwHMIkg1dn9tFM=
485+
github.com/stackql/any-sdk v0.1.2-beta01 h1:fmvsPGmjrcRRdgNsXJrp6TL7nDzPub0LmkIhPsW0tnc=
486+
github.com/stackql/any-sdk v0.1.2-beta01/go.mod h1:4jYKpPoX2GWEK+qBnlGLvr8SUfndiYwHMIkg1dn9tFM=
487487
github.com/stackql/go-suffix-map v0.0.1-alpha01 h1:TDUDS8bySu41Oo9p0eniUeCm43mnRM6zFEd6j6VUaz8=
488488
github.com/stackql/go-suffix-map v0.0.1-alpha01/go.mod h1:QAi+SKukOyf4dBtWy8UMy+hsXXV+yyEE4vmBkji2V7g=
489-
github.com/stackql/psql-wire v0.1.1-beta20 h1:ppLGNaaZGt0LncXJ4ElSHyJz6cQCAYFNwYQjIgSFJho=
490-
github.com/stackql/psql-wire v0.1.1-beta20/go.mod h1:a44Wd8kDC3irFLpGutarKDBqhJ/aqXlj1aMzO5bVJYg=
489+
github.com/stackql/psql-wire v0.1.1-beta22 h1:rt/2223xh8Uv5xoEnRi1CwcdRYqAUHCdF0DF7vNuwFk=
490+
github.com/stackql/psql-wire v0.1.1-beta22/go.mod h1:a44Wd8kDC3irFLpGutarKDBqhJ/aqXlj1aMzO5bVJYg=
491491
github.com/stackql/readline v0.0.2-alpha05 h1:ID4QzGdplFBsrSnTuz8pvKzWw96JbrJg8fsLry2UriU=
492492
github.com/stackql/readline v0.0.2-alpha05/go.mod h1:OFAYOdXk/X4+5GYiDXFfaGrk+bCN6Qv0SYY5HNzD2E0=
493493
github.com/stackql/stackql-go-sqlite3 v1.0.3-stackql h1:j0yt6T5thZuz5+HIr81PXz2AClAtCko0vzr5tm8C1g8=

internal/stackql/cmd/root.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@ func init() {
156156
rootCmd.PersistentFlags().StringVar(&runtimeCtx.HTTPProxyUser, dto.HTTPProxyUserKey, "", "http proxy user")
157157
rootCmd.PersistentFlags().StringVar(&runtimeCtx.ProviderStr, dto.ProviderStrKey, "", "stackql provider")
158158
rootCmd.PersistentFlags().StringVar(&runtimeCtx.ExportAlias, dto.ExportAliasKey, "", "export alias prefix (namespace or schema)")
159+
rootCmd.PersistentFlags().BoolVar(&runtimeCtx.PGSrvIsDebugNoticesEnabled, dto.PgSrvIsDebugNoticesEnabledKey, false, "Publish debug notices to clients, for server mode only")
159160
rootCmd.PersistentFlags().BoolVar(&runtimeCtx.WorkOffline, dto.WorkOfflineKey, false, "Work offline, using cached data")
160161
rootCmd.PersistentFlags().BoolVarP(&runtimeCtx.VerboseFlag, dto.VerboseFlagKey, "v", false, "Verbose flag")
161162
rootCmd.PersistentFlags().BoolVar(&runtimeCtx.DryRunFlag, dto.DryRunFlagKey, false, "dryrun flag; preprocessor only will run and output returned")
@@ -176,6 +177,7 @@ func init() {
176177
rootCmd.PersistentFlags().StringVar(&runtimeCtx.PGSrvAddress, dto.PgSrvAddressKey, "0.0.0.0", "server address, for server mode only")
177178
rootCmd.PersistentFlags().StringVar(&runtimeCtx.PGSrvLogLevel, dto.PgSrvLogLevelKey, "WARN", "Log level, for server mode only")
178179
rootCmd.PersistentFlags().StringVar(&runtimeCtx.PGSrvRawTLSCfg, dto.PgSrvRawTLSCfgKey, "", "tls config for server, for server mode only")
180+
rootCmd.PersistentFlags().StringVar(&runtimeCtx.PGSrvRawSrvCfg, dto.PgSrvRawSrvCfgKey, "{}", "miscellaneous config for server, for server mode only")
179181
rootCmd.PersistentFlags().IntVar(&runtimeCtx.PGSrvPort, dto.PgSrvPortKey, 5466, "TCP server port, for server mode only") //nolint:mnd // TODO: investigate
180182

181183
rootCmd.PersistentFlags().StringSliceVar(&runtimeCtx.VarList, dto.VarListKey, []string{}, "list of variables to be used in queries")

internal/stackql/cmd/srv.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ var srvCmd = &cobra.Command{
4545
iqlerror.PrintErrorAndExitOneIfError(err)
4646
handlerCtx, err := entryutil.BuildHandlerContext(runtimeCtx, nil, queryCache, inputBundle, false)
4747
iqlerror.PrintErrorAndExitOneIfError(err)
48-
sbe := driver.NewStackQLDriverFactory(handlerCtx, true)
48+
sbe := driver.NewStackQLDriverFactory(handlerCtx, runtimeCtx.PGSrvIsDebugNoticesEnabled)
4949
server, err := psqlwire.MakeWireServer(sbe, runtimeCtx)
5050
iqlerror.PrintErrorAndExitOneIfError(err)
5151
server.Serve() //nolint:errcheck // TODO: investigate

internal/stackql/psqlwire/server.go

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010
"github.com/sirupsen/logrus"
1111
"github.com/stackql/any-sdk/pkg/dto"
1212
"github.com/stackql/any-sdk/pkg/logging"
13+
"gopkg.in/yaml.v2"
1314

1415
"github.com/stackql/psql-wire/pkg/sqlbackend"
1516

@@ -35,6 +36,13 @@ func MakeWireServer(sbe sqlbackend.SQLBackendFactory, cfg dto.RuntimeCtx) (IWire
3536
var server *wire.Server
3637

3738
var err error
39+
pgSrvMiscConfig := make(map[string]interface{})
40+
if cfg.PGSrvRawSrvCfg != "" {
41+
var err = yaml.Unmarshal([]byte(cfg.PGSrvRawSrvCfg), &pgSrvMiscConfig)
42+
if err != nil {
43+
return nil, err
44+
}
45+
}
3846
if cfg.PGSrvRawTLSCfg != "" {
3947
err = json.Unmarshal([]byte(cfg.PGSrvRawTLSCfg), &tlsCfg)
4048
if err != nil {
@@ -73,7 +81,11 @@ func MakeWireServer(sbe sqlbackend.SQLBackendFactory, cfg dto.RuntimeCtx) (IWire
7381
return nil, err
7482
}
7583
} else {
76-
server, err = wire.NewServer(wire.SQLBackendFactory(sbe))
84+
server, err = wire.NewServer(
85+
wire.SQLBackendFactory(sbe),
86+
wire.SundryConfig(pgSrvMiscConfig),
87+
wire.IsCaptureDebug(cfg.PGSrvIsDebugNoticesEnabled),
88+
)
7789
if err != nil {
7890
return nil, err
7991
}

0 commit comments

Comments
 (0)