@effect/sql-pg 4.0.0-rc.116 → 4.0.0-rc.117
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ai-docs/package.json +3 -3
- package/dist/PgClient.d.ts.map +1 -1
- package/dist/PgClient.js +1 -0
- package/dist/PgClient.js.map +1 -1
- package/dist/PgConnection.d.ts +17 -5
- package/dist/PgConnection.d.ts.map +1 -1
- package/dist/PgConnection.js +47 -28
- package/dist/PgConnection.js.map +1 -1
- package/dist/PgPool.d.ts.map +1 -1
- package/dist/PgPool.js +4 -7
- package/dist/PgPool.js.map +1 -1
- package/dist/PgTypes.d.ts +2 -0
- package/dist/PgTypes.d.ts.map +1 -1
- package/dist/PgTypes.js +16 -13
- package/dist/PgTypes.js.map +1 -1
- package/package.json +4 -4
- package/src/PgClient.ts +1 -0
- package/src/PgConnection.ts +75 -45
- package/src/PgPool.ts +4 -7
- package/src/PgTypes.ts +22 -19
- package/src/internal/connection.ts +2 -2
package/src/PgPool.ts
CHANGED
|
@@ -140,7 +140,7 @@ export const make = Effect.fnUntraced(function*(options: Config): Effect.fn.Retu
|
|
|
140
140
|
Effect.sync(() => {
|
|
141
141
|
createdAt.set(connection, clock.currentTimeMillisUnsafe())
|
|
142
142
|
const internals = connectionInternals(connection)
|
|
143
|
-
internals.
|
|
143
|
+
internals.retireHooks.add(() => {
|
|
144
144
|
deadConnections.add(connection)
|
|
145
145
|
// `deadConnections` is only read by the next checkout, and a checkout
|
|
146
146
|
// already waiting for this connection would never get that far. Tell
|
|
@@ -204,12 +204,9 @@ export const make = Effect.fnUntraced(function*(options: Config): Effect.fn.Retu
|
|
|
204
204
|
// `pin` reserves the pool item itself, so this needs no help.
|
|
205
205
|
const reserve = Effect.flatMap(get, (connection) => connection.pin)
|
|
206
206
|
|
|
207
|
-
// `Pool.use` cannot check
|
|
208
|
-
//
|
|
209
|
-
//
|
|
210
|
-
// checkout does its replacement pass first. Checking inside the callback
|
|
211
|
-
// instead would hold one lease while acquiring another, which deadlocks a
|
|
212
|
-
// pool of one.
|
|
207
|
+
// `Pool.use` cannot pre-check a session. Use it only when no TTL applies and
|
|
208
|
+
// no connection awaits retirement. Checking inside its callback can deadlock
|
|
209
|
+
// a size-one pool while acquiring a replacement.
|
|
213
210
|
const use = <A, E, R>(
|
|
214
211
|
f: (connection: PgConnection.PgConnection) => Effect.Effect<A, E, R>
|
|
215
212
|
): Effect.Effect<A, E | SqlError, R> =>
|
package/src/PgTypes.ts
CHANGED
|
@@ -313,6 +313,7 @@ export const OID = {
|
|
|
313
313
|
timestamptz: 1184,
|
|
314
314
|
timetz: 1266,
|
|
315
315
|
numeric: 1700,
|
|
316
|
+
regclass: 2205,
|
|
316
317
|
uuid: 2950,
|
|
317
318
|
jsonb: 3802,
|
|
318
319
|
boolArray: 1000,
|
|
@@ -336,6 +337,7 @@ export const OID = {
|
|
|
336
337
|
timestamptzArray: 1185,
|
|
337
338
|
timetzArray: 1270,
|
|
338
339
|
numericArray: 1231,
|
|
340
|
+
regclassArray: 2210,
|
|
339
341
|
uuidArray: 2951,
|
|
340
342
|
jsonbArray: 3807
|
|
341
343
|
} as const
|
|
@@ -362,6 +364,7 @@ const arrayToElement = new Map<number, number>([
|
|
|
362
364
|
[OID.timestamptzArray, OID.timestamptz],
|
|
363
365
|
[OID.timetzArray, OID.timetz],
|
|
364
366
|
[OID.numericArray, OID.numeric],
|
|
367
|
+
[OID.regclassArray, OID.regclass],
|
|
365
368
|
[OID.uuidArray, OID.uuid],
|
|
366
369
|
[OID.jsonbArray, OID.jsonb]
|
|
367
370
|
])
|
|
@@ -1160,6 +1163,23 @@ const jsonbCodec: UnsafeCodec<any> = codecOf(
|
|
|
1160
1163
|
}
|
|
1161
1164
|
)
|
|
1162
1165
|
|
|
1166
|
+
const oidCodec: UnsafeCodec<any> = codecOf(
|
|
1167
|
+
(bytes, offset, size) => {
|
|
1168
|
+
requireSize(size, 4, "oid")
|
|
1169
|
+
return readUint32(bytes, offset)
|
|
1170
|
+
},
|
|
1171
|
+
(value) => {
|
|
1172
|
+
const num = requireInteger(value, "oid", 0, 4294967295)
|
|
1173
|
+
const bytes = new Uint8Array(4)
|
|
1174
|
+
bytes[0] = num >>> 24
|
|
1175
|
+
bytes[1] = num >>> 16
|
|
1176
|
+
bytes[2] = num >>> 8
|
|
1177
|
+
bytes[3] = num
|
|
1178
|
+
return bytes
|
|
1179
|
+
},
|
|
1180
|
+
(sink, value) => sink.int32(requireInteger(value, "oid", 0, 4294967295))
|
|
1181
|
+
)
|
|
1182
|
+
|
|
1163
1183
|
const builtinScalars = new Map<number, UnsafeCodec<any>>([
|
|
1164
1184
|
[
|
|
1165
1185
|
OID.bool,
|
|
@@ -1224,25 +1244,8 @@ const builtinScalars = new Map<number, UnsafeCodec<any>>([
|
|
|
1224
1244
|
(sink, value) => sink.int32(requireInteger(value, "int4", INT32_MIN, INT32_MAX))
|
|
1225
1245
|
)
|
|
1226
1246
|
],
|
|
1227
|
-
[
|
|
1228
|
-
|
|
1229
|
-
codecOf(
|
|
1230
|
-
(bytes, offset, size) => {
|
|
1231
|
-
requireSize(size, 4, "oid")
|
|
1232
|
-
return readUint32(bytes, offset)
|
|
1233
|
-
},
|
|
1234
|
-
(value) => {
|
|
1235
|
-
const num = requireInteger(value, "oid", 0, 4294967295)
|
|
1236
|
-
const bytes = new Uint8Array(4)
|
|
1237
|
-
bytes[0] = num >>> 24
|
|
1238
|
-
bytes[1] = num >>> 16
|
|
1239
|
-
bytes[2] = num >>> 8
|
|
1240
|
-
bytes[3] = num
|
|
1241
|
-
return bytes
|
|
1242
|
-
},
|
|
1243
|
-
(sink, value) => sink.int32(requireInteger(value, "oid", 0, 4294967295))
|
|
1244
|
-
)
|
|
1245
|
-
],
|
|
1247
|
+
[OID.oid, oidCodec],
|
|
1248
|
+
[OID.regclass, oidCodec],
|
|
1246
1249
|
[
|
|
1247
1250
|
OID.int8,
|
|
1248
1251
|
codecOf(
|
|
@@ -10,8 +10,8 @@ export interface ConnectionInternals {
|
|
|
10
10
|
/** The pool item identity: the unpinned base connection. */
|
|
11
11
|
readonly base: object
|
|
12
12
|
readonly deadError: () => SqlError | undefined
|
|
13
|
-
/** Fired
|
|
14
|
-
readonly
|
|
13
|
+
/** Fired when a pool must stop reusing the connection. */
|
|
14
|
+
readonly retireHooks: Set<() => void>
|
|
15
15
|
/**
|
|
16
16
|
* Installed by a multiplexed pool so that pinning the session also takes it
|
|
17
17
|
* out of shared circulation for as long as the pin lasts. Every route to an
|