Skip to content

Commit a3be020

Browse files
Merge branch 'main' into 470
2 parents 527a551 + 6e37779 commit a3be020

40 files changed

+769
-106
lines changed

.github/workflows/build.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1461,6 +1461,8 @@ jobs:
14611461

14621462

14631463
dockertest:
1464+
env:
1465+
IS_DOCKER: 'true'
14641466
name: Docker Test
14651467
needs:
14661468
- dockerbuild

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ ENV PATH="${APP_DIR}:${PATH}"
162162
COPY --from=integration ${TEST_ROOT_DIR}/build/stackql ${APP_DIR}/
163163

164164
RUN apt-get update \
165-
&& apt-get install -y ca-certificates openssl \
165+
&& apt-get install -y ca-certificates openssl netcat-traditional \
166166
&& update-ca-certificates
167167

168168
EXPOSE ${STACKQL_PG_PORT}/tcp
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,3 +111,11 @@ Please **watch this space** on all items which are **TBD**-inclusive.
111111
- List active Txns.
112112
- Halt / Allow new Txns.
113113
- Cancel Txns (filtered / unfiltered).
114+
115+
## ACID
116+
117+
118+
### When RDBMS ACID fails
119+
120+
Despite all efforts to enforce ACID, there are times when it can fail and require admin intervention, even for local disk backed RDBMs, [per `postgres` corruption documentation](https://wiki.postgresql.org/wiki/Corruption).
121+

docs/developer_guide.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,3 +268,13 @@ time ./stackql exec --cpuprofile=./select-disks-improved-05.profile --auth='{ "g
268268
## AWS HTTP request signing
269269

270270
https://docs.aws.amazon.com/sdk-for-go/api/aws/signer/v4/
271+
272+
## Selection from non-select DML
273+
274+
`INSERT RETURNING` can function in two mechanisms:
275+
276+
- Synchronous responses, such as [`google.storage.buckets`](https://cloud.google.com/storage/docs/json_api/v1/buckets/insert). The returning clause is a projection on the immediately available reponse body.
277+
- Asynchronous responses, such as [`google.compute.instances`](https://cloud.google.com/compute/docs/reference/rest/v1/instances/insert) and [`google.compute.networks`](https://cloud.google.com/compute/docs/reference/rest/v1/networks/insert). The returning clause is a projection on the reponse body **after** the await flow has concluded.
278+
279+
Future use cases for `UPDATE RETURNING`, `REPLACE RETURNING` and `DELETE RETURNING` will function the same observable fashion.
280+

go.mod

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,17 @@ require (
1212
github.com/jackc/pgx/v5 v5.0.4
1313
github.com/lib/pq v1.10.4
1414
github.com/magiconair/properties v1.8.6
15-
github.com/mattn/go-sqlite3 v1.0.3-stackql
15+
github.com/mattn/go-sqlite3 v1.0.4-stackql
1616
github.com/olekukonko/tablewriter v0.0.0-20180130162743-b8a9be070da4
1717
github.com/sirupsen/logrus v1.9.0
1818
github.com/snowflakedb/gosnowflake v1.6.16
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.4-alpha01
22+
github.com/stackql/any-sdk v0.1.4-alpha06
2323
github.com/stackql/go-suffix-map v0.0.1-alpha01
2424
github.com/stackql/psql-wire v0.1.1-beta23
25-
github.com/stackql/stackql-parser v0.0.14-alpha05
25+
github.com/stackql/stackql-parser v0.0.15-alpha06
2626
github.com/stretchr/testify v1.10.0
2727
golang.org/x/sync v0.10.0
2828
gonum.org/v1/gonum v0.11.0
@@ -131,4 +131,4 @@ require (
131131

132132
replace github.com/chzyer/readline => github.com/stackql/readline v0.0.2-alpha05
133133

134-
replace github.com/mattn/go-sqlite3 => github.com/stackql/stackql-go-sqlite3 v1.0.3-stackql
134+
replace github.com/mattn/go-sqlite3 => github.com/stackql/stackql-go-sqlite3 v1.0.4-stackql

go.sum

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -484,18 +484,18 @@ github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
484484
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
485485
github.com/spf13/viper v1.10.1 h1:nuJZuYpG7gTj/XqiUwg8bA0cp1+M2mC3J4g5luUYBKk=
486486
github.com/spf13/viper v1.10.1/go.mod h1:IGlFPqhNAPKRxohIzWpI5QEy4kuI7tcl5WvR+8qy1rU=
487-
github.com/stackql/any-sdk v0.1.4-alpha01 h1:GQmsDcqCgnjPBq8IUcGSIFb8xlVyb9zlMayjH1SdaWQ=
488-
github.com/stackql/any-sdk v0.1.4-alpha01/go.mod h1:AKS/g28y7m4SWL/YW8veE9MCNy8XJgaicVibemVE9e8=
487+
github.com/stackql/any-sdk v0.1.4-alpha06 h1:QJPf3ehPrRqmYZR+TmD897AsmsaOamHErLhaE5B9v/w=
488+
github.com/stackql/any-sdk v0.1.4-alpha06/go.mod h1:AKS/g28y7m4SWL/YW8veE9MCNy8XJgaicVibemVE9e8=
489489
github.com/stackql/go-suffix-map v0.0.1-alpha01 h1:TDUDS8bySu41Oo9p0eniUeCm43mnRM6zFEd6j6VUaz8=
490490
github.com/stackql/go-suffix-map v0.0.1-alpha01/go.mod h1:QAi+SKukOyf4dBtWy8UMy+hsXXV+yyEE4vmBkji2V7g=
491491
github.com/stackql/psql-wire v0.1.1-beta23 h1:1ayYMjZArfDcIMyEOKnm+Bp1zRCISw8pguvTFuUhhVQ=
492492
github.com/stackql/psql-wire v0.1.1-beta23/go.mod h1:a44Wd8kDC3irFLpGutarKDBqhJ/aqXlj1aMzO5bVJYg=
493493
github.com/stackql/readline v0.0.2-alpha05 h1:ID4QzGdplFBsrSnTuz8pvKzWw96JbrJg8fsLry2UriU=
494494
github.com/stackql/readline v0.0.2-alpha05/go.mod h1:OFAYOdXk/X4+5GYiDXFfaGrk+bCN6Qv0SYY5HNzD2E0=
495-
github.com/stackql/stackql-go-sqlite3 v1.0.3-stackql h1:j0yt6T5thZuz5+HIr81PXz2AClAtCko0vzr5tm8C1g8=
496-
github.com/stackql/stackql-go-sqlite3 v1.0.3-stackql/go.mod h1:HemqCrcMK2xyhMMMt6oZ7ERDtoSmyyDsw5LBBcTZ+Rk=
497-
github.com/stackql/stackql-parser v0.0.14-alpha05 h1:DLcsaeTypH5p1T+g/9NqaGYdC9uIQ+7pZetnkjHi0G0=
498-
github.com/stackql/stackql-parser v0.0.14-alpha05/go.mod h1:iyB47SvRS+Fvpn7joF7mHAkeiWSq83TbUhglRmLzPLQ=
495+
github.com/stackql/stackql-go-sqlite3 v1.0.4-stackql h1:fp70Vdw+PCVEoPrAhkyqPuAlrIiHT79mght/0rlR4oY=
496+
github.com/stackql/stackql-go-sqlite3 v1.0.4-stackql/go.mod h1:HemqCrcMK2xyhMMMt6oZ7ERDtoSmyyDsw5LBBcTZ+Rk=
497+
github.com/stackql/stackql-parser v0.0.15-alpha06 h1:bdaudybbEmrR9m88CO1HpX/eKda2+gjiy4Kf6ZjwPoQ=
498+
github.com/stackql/stackql-parser v0.0.15-alpha06/go.mod h1:iyB47SvRS+Fvpn7joF7mHAkeiWSq83TbUhglRmLzPLQ=
499499
github.com/stackql/stackql-provider-registry v0.0.1-rc06 h1:MgroWOr0bSqjSTDGnXB0UoZGFXpW3SRtN0EFkzB8Rpo=
500500
github.com/stackql/stackql-provider-registry v0.0.1-rc06/go.mod h1:87rVxnS2aRASK20lBQgoYA0o7FSJTZBGGRaWFR7IDm4=
501501
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=

internal/stackql/primitivebuilder/async_compose.go renamed to internal/stackql/asynccompose/async_compose.go

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,26 @@
1-
package primitivebuilder
1+
package asynccompose
22

33
import (
44
"github.com/stackql/any-sdk/anysdk"
55
"github.com/stackql/stackql-parser/go/vt/sqlparser"
6+
"github.com/stackql/stackql/internal/stackql/drm"
67
"github.com/stackql/stackql/internal/stackql/handler"
78
"github.com/stackql/stackql/internal/stackql/internal_data_transfer/internaldto"
89
"github.com/stackql/stackql/internal/stackql/primitive"
910
"github.com/stackql/stackql/internal/stackql/provider"
1011
)
1112

12-
func composeAsyncMonitor(
13+
func ComposeAsyncMonitor(
1314
handlerCtx handler.HandlerContext,
1415
precursor primitive.IPrimitive,
1516
prov provider.IProvider,
1617
method anysdk.OperationStore,
1718
commentDirectives sqlparser.CommentDirectives,
19+
isReturning bool,
20+
insertCtx drm.PreparedStatementCtx,
21+
drmCfg drm.Config,
1822
) (primitive.IPrimitive, error) {
19-
asm, err := NewAsyncMonitor(handlerCtx, prov, method)
23+
asm, err := NewAsyncMonitor(handlerCtx, prov, method, isReturning)
2024
if err != nil {
2125
return nil, err
2226
}
@@ -31,7 +35,8 @@ func composeAsyncMonitor(
3135
handlerCtx.GetOutfile(),
3236
handlerCtx.GetOutErrFile(),
3337
)
34-
primitive, err := asm.GetMonitorPrimitive(prov, method, precursor, pl, commentDirectives)
38+
primitive, err := asm.GetMonitorPrimitive(
39+
prov, method, precursor, pl, commentDirectives, isReturning, insertCtx, drmCfg)
3540
if err != nil {
3641
return nil, err
3742
}

internal/stackql/primitivebuilder/asyncmonitor.go renamed to internal/stackql/asynccompose/asyncmonitor.go

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
package primitivebuilder
1+
package asynccompose
22

33
import (
44
"fmt"
55
"strings"
66

77
"github.com/stackql/any-sdk/anysdk"
88
"github.com/stackql/stackql/internal/stackql/acid/binlog"
9+
"github.com/stackql/stackql/internal/stackql/drm"
910
"github.com/stackql/stackql/internal/stackql/execution"
1011
"github.com/stackql/stackql/internal/stackql/handler"
1112
"github.com/stackql/stackql/internal/stackql/internal_data_transfer/internaldto"
@@ -22,6 +23,9 @@ type IAsyncMonitor interface {
2223
precursor primitive.IPrimitive,
2324
initialCtx primitive.IPrimitiveCtx,
2425
comments sqlparser.CommentDirectives,
26+
isReturning bool,
27+
insertCtx drm.PreparedStatementCtx,
28+
drmCfg drm.Config,
2529
) (primitive.IPrimitive, error)
2630
}
2731

@@ -120,11 +124,12 @@ func NewAsyncMonitor(
120124
handlerCtx handler.HandlerContext,
121125
prov provider.IProvider,
122126
op anysdk.OperationStore,
127+
isReturning bool,
123128
) (IAsyncMonitor, error) {
124129
//nolint:gocritic //TODO: refactor
125130
switch prov.GetProviderString() {
126131
case "google":
127-
return newGoogleAsyncMonitor(handlerCtx, prov, op, prov.GetVersion())
132+
return newGoogleAsyncMonitor(handlerCtx, prov, op, prov.GetVersion(), isReturning)
128133
}
129134
return nil, fmt.Errorf(
130135
"async operation monitor for provider = '%s', api version = '%s' currently not supported",
@@ -136,6 +141,7 @@ func newGoogleAsyncMonitor(
136141
prov provider.IProvider,
137142
op anysdk.OperationStore,
138143
version string, //nolint:unparam // TODO: refactor
144+
isReturning bool, //nolint:unparam,revive // TODO: refactor
139145
) (IAsyncMonitor, error) {
140146
//nolint:gocritic //TODO: refactor
141147
switch version {
@@ -160,11 +166,14 @@ func (gm *DefaultGoogleAsyncMonitor) GetMonitorPrimitive(
160166
precursor primitive.IPrimitive,
161167
initialCtx primitive.IPrimitiveCtx,
162168
comments sqlparser.CommentDirectives,
169+
isReturning bool,
170+
insertCtx drm.PreparedStatementCtx,
171+
drmCfg drm.Config,
163172
) (primitive.IPrimitive, error) {
164173
//nolint:gocritic,staticcheck //TODO: refactor
165174
switch strings.ToLower(prov.GetVersion()) {
166175
default:
167-
return gm.getV1Monitor(prov, op, precursor, initialCtx, comments)
176+
return gm.getV1Monitor(prov, op, precursor, initialCtx, comments, isReturning, insertCtx, drmCfg)
168177
}
169178
}
170179

@@ -174,6 +183,9 @@ func (gm *DefaultGoogleAsyncMonitor) getV1Monitor(
174183
precursor primitive.IPrimitive,
175184
initialCtx primitive.IPrimitiveCtx,
176185
comments sqlparser.CommentDirectives,
186+
isReturning bool,
187+
insertCtx drm.PreparedStatementCtx,
188+
drmCfg drm.Config,
177189
) (primitive.IPrimitive, error) {
178190
provider, providerErr := prov.GetProvider()
179191
if providerErr != nil {
@@ -186,6 +198,9 @@ func (gm *DefaultGoogleAsyncMonitor) getV1Monitor(
186198
precursor,
187199
initialCtx,
188200
comments,
201+
isReturning,
202+
insertCtx,
203+
drmCfg,
189204
)
190205
if exPrepErr != nil {
191206
return nil, exPrepErr

internal/stackql/dependencyplanner/dependencyplanner.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -485,6 +485,7 @@ func (dp *standardDependencyPlanner) orchestrate(
485485
insPsc,
486486
nil,
487487
outStream,
488+
false, // returning hardcoded to false for now
488489
)
489490
}
490491
dp.execSlice = append(dp.execSlice, builder)

internal/stackql/driver/dependent_simple_integration_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ func TestSimpleInsertDependentGoogleComputeDiskAsync(t *testing.T) {
3838
if err != nil {
3939
t.Fatalf("Test failed: %v", err)
4040
}
41-
handlerCtx, err := entryutil.BuildHandlerContext(*runtimeCtx, rdr, lrucache.NewLRUCache(int64(runtimeCtx.QueryCacheSize)), inputBundle.WithStdOut(outFile), true)
41+
handlerCtx, err := entryutil.BuildHandlerContext(*runtimeCtx, rdr, lrucache.NewLRUCache(int64(runtimeCtx.QueryCacheSize)), inputBundle.WithStdErr(outFile), true)
4242
if err != nil {
4343
t.Fatalf("Test failed: %v", err)
4444
}
@@ -76,7 +76,7 @@ func TestSimpleInsertDependentGoogleComputeDiskAsyncReversed(t *testing.T) {
7676
if err != nil {
7777
t.Fatalf("Test failed: %v", err)
7878
}
79-
handlerCtx, err := entryutil.BuildHandlerContext(*runtimeCtx, rdr, lrucache.NewLRUCache(int64(runtimeCtx.QueryCacheSize)), inputBundle.WithStdOut(outFile), true)
79+
handlerCtx, err := entryutil.BuildHandlerContext(*runtimeCtx, rdr, lrucache.NewLRUCache(int64(runtimeCtx.QueryCacheSize)), inputBundle.WithStdErr(outFile), true)
8080
if err != nil {
8181
t.Fatalf("Test failed: %v", err)
8282
}

0 commit comments

Comments
 (0)