Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

PgClient.ts

642 lines22.4 KB

1/**
2 * PostgreSQL support for Effect SQL, backed by the native wire protocol client.
3 *
4 * @stability unstable
5 * @since 4.0.0
6 */
7import type * as Arr from "effect/Array"
8import * as Config from "effect/Config"
9import * as Context from "effect/Context"
10import type * as Duration from "effect/Duration"
11import * as Effect from "effect/Effect"
12import * as Layer from "effect/Layer"
13import type * as Pool from "effect/Pool"
14import type * as Queue from "effect/Queue"
15import * as Reactivity from "effect/reactivity/Reactivity"
16import type * as Redacted from "effect/Redacted"
17import type * as Scope from "effect/Scope"
18import * as Client from "effect/sql/SqlClient"
19import type { Borrower, Connection } from "effect/sql/SqlConnection"
20import { SqlError, UnknownError } from "effect/sql/SqlError"
21import type { Custom, Fragment } from "effect/sql/Statement"
22import * as Statement from "effect/sql/Statement"
23import * as Stream from "effect/Stream"
24import * as Tracer from "effect/Tracer"
25import type { Duplex } from "node:stream"
26import type { ConnectionOptions } from "node:tls"
27import { resolveConfig } from "./internal/config.ts"
28import { connectionInternals } from "./internal/connection.ts"
29import { validateChannelName } from "./internal/sqlError.ts"
30import * as PgConnection from "./PgConnection.ts"
31import * as PgPool from "./PgPool.ts"
32import * as PgTypes from "./PgTypes.ts"
33​
34/**
35 * The runtime type identifier for `PgClient`.
36 *
37 * @stability unstable
38 * @category type IDs
39 * @since 4.0.0
40 */
41export const TypeId: TypeId = "~@effect/sql-pg/PgClient"
42​
43/**
44 * The type-level identifier for `PgClient`.
45 *
46 * @stability unstable
47 * @category type IDs
48 * @since 4.0.0
49 */
50export type TypeId = "~@effect/sql-pg/PgClient"
51​
52/**
53 * A PostgreSQL `SqlClient` with JSON and `LISTEN`/`NOTIFY` helpers.
54 *
55 * @stability unstable
56 * @category services
57 * @since 4.0.0
58 */
59export interface PgClient extends Client.Base {
60 readonly [TypeId]: TypeId
61 readonly config: PgClientConfig
62 readonly json: (_: unknown) => Fragment
63 /**
64 * Registers a channel listener and returns its notification queue after
65 * PostgreSQL confirms `LISTEN`. The listener holds a connection until the
66 * scope closes.
67 * Connection failures after registration fail the queue with the original
68 * `SqlError`. Intentional scope closure interrupts consumers.
69 */
70 readonly listen: (
71 channel: string
72 ) => Effect.Effect<Queue.Dequeue<PgConnection.Notification, SqlError>, SqlError, Scope.Scope>
73 readonly notify: (channel: string, payload: string) => Effect.Effect<void, SqlError>
74 /**
75 * Returns a snapshot of connection pool occupancy. A client from `makeClient`
76 * has one session that stays leased for its lifetime, so it always reports
77 * `{ idle: 0, used: 1, pending: 0, min: 1, max: 1 }` whatever statements run
78 * on it.
79 */
80 readonly poolStats: Effect.Effect<Pool.Stats>
81 /**
82 * Runs a query and returns field metadata alongside positional rows of raw
83 * PostgreSQL text values (`string | null`), bypassing result codecs
84 * (including `types`), `transformResultNames`, and `Statement.CurrentTransformer`.
85 *
86 * **Details**
87 *
88 * Runs on the active transaction's connection inside `withTransaction`;
89 * otherwise borrows a connection like any statement.
90 *
91 * **Example** (Reading values as text)
92 *
93 * ```ts
94 * import { PgClient } from "@effect/sql-pg"
95 * import { Effect } from "effect"
96 *
97 * const program = Effect.gen(function*() {
98 * const sql = yield* PgClient.PgClient
99 * const result = yield* sql.withTransaction(
100 * sql.queryTextValues("SELECT now() AS at, $1::numeric AS amount", ["1.50"])
101 * )
102 * // result.fields: [{ name: "at", dataTypeId: 1184 }, { name: "amount", dataTypeId: 1700 }]
103 * // result.values: [["2026-11-24 12:00:00.123456+00", "1.50"]]
104 * })
105 * ```
106 */
107 readonly queryTextValues: (
108 sql: string,
109 params?: ReadonlyArray<unknown>
110 ) => Effect.Effect<PgConnection.TextResult, SqlError>
112​
113/**
114 * The service tag for `PgClient`.
115 *
116 * @stability unstable
117 * @category services
118 * @since 4.0.0
119 */
120export const PgClient = Context.Service<PgClient, PgClient & Client.SqlClient>("@effect/sql-pg/PgClient")
121​
122/**
123 * Connection and query settings for a PostgreSQL client.
124 *
125 * @stability unstable
126 * @category models
127 * @since 4.0.0
128 */
129export interface PgClientConfig<R = never> {
130 readonly url?: Redacted.Redacted | undefined
131​
132 readonly host?: string | undefined
133 readonly port?: number | undefined
134 readonly path?: string | undefined
135 readonly ssl?: boolean | ConnectionOptions | undefined
136 readonly database?: string | undefined
137 readonly username?: string | undefined
138 /**
139 * A static password or an Effect evaluated for each connection attempt.
140 * Providers must handle typed errors and require no services.
141 * {@link Effect.orDie} converts typed errors to defects, not retryable SQL errors.
142 */
143 readonly password?: Redacted.Redacted | Effect.Effect<Redacted.Redacted> | undefined
144​
145 readonly connectTimeout?: Duration.Input | undefined
146 /** Idle time before TCP keepalive probes start. See `PgConnection.Config.keepAlive`. */
147 readonly keepAlive?: Duration.Input | undefined
148​
149 readonly stream?: (() => Duplex) | undefined
150​
151 /**
152 * Overrides `startupParameters.application_name`, the URL's `application_name`,
153 * and the default `"@effect/sql-pg"`, in that order.
154 */
155 readonly applicationName?: string | undefined
156 /**
157 * Session defaults sent in every physical connection's startup packet.
158 * Names are lowercased; `user`, `database`, `replication`, and `options` are
159 * reserved. `client_encoding` only accepts UTF8 / UTF-8 (case-insensitive).
160 * Empty names and NUL bytes fail before connecting; PostgreSQL validates
161 * other settings. Do not set the same GUC here and in `startupOptions`.
162 */
163 readonly startupParameters?: Readonly<Record<string, string>> | undefined
164 /**
165 * Opaque PostgreSQL startup options, overriding the URL's `options` parameter.
166 * Forwarded without parsing `-c` flags or checking for duplicate GUCs.
167 */
168 readonly startupOptions?: string | undefined
169 readonly spanAttributes?: Record<string, unknown> | undefined
170​
171 readonly transformResultNames?: ((str: string) => string) | undefined
172 readonly transformQueryNames?: ((str: string) => string) | undefined
173 readonly transformJson?: boolean | undefined
174 readonly types?: PgTypes.Registry | undefined
175 /**
176 * Pipelines queries from multiple fibers on each pooled connection.
177 * Transactions, streams, and listeners still reserve a connection.
178 */
179 readonly multiplex?: boolean | undefined
180 /**
181 * How many statements may share one connection when `multiplex` is on.
182 * Defaults to `32`. Higher values trade tail latency for throughput: the
183 * statements sharing a connection are pipelined into one write, and they
184 * also queue behind the slowest of them.
185 */
186 readonly multiplexConcurrency?: number | undefined
187 /**
188 * Caches prepared statements by name. Enabled by default. Disable it for
189 * poolers that cannot preserve named statements between queries, such as
190 * PgBouncer in transaction mode with `max_prepared_statements = 0`.
191 *
192 * **Gotchas**
193 *
194 * With `multiplex` enabled, PgBouncer before 1.26.0 with
195 * `max_prepared_statements > 0` can misorder or drop responses to pipelined
196 * `Close` messages, failing connections with
197 * `Unexpected ParseComplete during close`. Set `prepare: false` or upgrade
198 * PgBouncer.
199 */
200 readonly prepare?: boolean | undefined
201 /** How many statements a connection keeps prepared. Defaults to `100`. */
202 readonly preparedStatementCacheSize?: number | undefined
203 /** Maximum backend message size in bytes. Defaults to 16 MiB. */
204 readonly maxMessageSize?: number | undefined
205 /**
206 * Runs after each connection checkout, in the fiber that uses the connection.
207 *
208 * **Details**
209 *
210 * Runs once per statement or stream outside a transaction, including
211 * multiplexed statements, and once per `withTransaction`, `reserve`, `listen`
212 * and `notify`. Finalizers it adds run when that acquisition ends. Services it
213 * requires are captured when the client is built, and the consuming fiber's
214 * services take precedence.
215 *
216 * **Gotchas**
217 *
218 * Keep it cheap: it runs while holding the connection. With `makeClient` and
219 * `acquireForStream`, it runs before a stream opens its own connection.
220 *
221 * **Example** (Reading request context on each checkout)
222 *
223 * ```ts
224 * import { PgClient } from "@effect/sql-pg"
225 * import { Context, Effect } from "effect"
226 *
227 * // Set by each request handler with `Effect.provideService`.
228 * const KeepAlive = Context.Reference<(() => void) | undefined>("app/KeepAlive", {
229 * defaultValue: () => undefined
230 * })
231 *
232 * const layer = PgClient.layer({
233 * onAcquire: Effect.gen(function*() {
234 * const keepAlive = yield* KeepAlive
235 * keepAlive?.()
236 * })
237 * })
238 * ```
239 */
240 readonly onAcquire?: Effect.Effect<void, never, R> | undefined
242​
243/**
244 * PostgreSQL client settings with connection pool limits and timeouts.
245 *
246 * @stability unstable
247 * @category models
248 * @since 4.0.0
249 */
250export interface PgPoolConfig<R = never> extends PgClientConfig<R> {
251 readonly idleTimeout?: Duration.Input | undefined
252​
253 readonly maxConnections?: number | undefined
254 readonly minConnections?: number | undefined
255 readonly connectionTTL?: Duration.Input | undefined
256 /** Bounds how long acquiring a pooled connection takes. See `PgPool.Config.acquireTimeout`. */
257 readonly acquireTimeout?: Duration.Input | undefined
259​
260/**
261 * Creates a scoped PostgreSQL client backed by a connection pool.
262 *
263 * @stability unstable
264 * @category constructors
265 * @since 4.0.0
266 */
267export const make = <R = never>(
268 options: PgPoolConfig<R>
269): Effect.Effect<PgClient & Client.SqlClient, SqlError, Scope.Scope | Reactivity.Reactivity | R> =>
270 Effect.flatMap(PgPool.make(options), (pool) =>
271 makeImpl({
272 acquirer: Effect.map(pool.get, makeConnection),
273 borrower: (f) => pool.use((connection) => f(makeConnection(connection))),
274 transactionAcquirer: Effect.map(pool.reserve, makeConnection),
275 listenAcquirer: pool.reserve,
276 config: options,
277 poolStats: pool.stats
278 }))
279​
280/**
281 * Creates a scoped PostgreSQL client backed by one connection.
282 *
283 * @stability unstable
284 * @category constructors
285 * @since 4.0.0
286 */
287export const makeClient = <R = never>(
288 options: PgClientConfig<R> & {
289 /**
290 * Opens a separate connection for each stream and listener when enabled.
291 */
292 readonly acquireForStream?: boolean | undefined
293 }
294): Effect.Effect<PgClient & Client.SqlClient, SqlError, Scope.Scope | Reactivity.Reactivity | R> =>
295 Effect.flatMap(PgConnection.make(options), (connection) =>
296 makeImpl({
297 acquirer: Effect.succeed(makeConnection(
298 connection,
299 options.acquireForStream ? PgConnection.make(options) : undefined
300 )),
301 transactionAcquirer: Effect.map(connection.pin, makeConnection),
302 listenAcquirer: options.acquireForStream ? PgConnection.make(options) : connection.pin,
303 config: options,
304 // The one session is leased for the client's lifetime.
305 poolStats: Effect.succeed({ idle: 0, used: 1, pending: 0, min: 1, max: 1 })
306 }))
307​
308/**
309 * Builds the shared SQL facade around native connection acquirers.
310 */
311const makeImpl = Effect.fnUntraced(function*<R>(
312 options: {
313 readonly acquirer: Effect.Effect<Connection, SqlError, Scope.Scope>
314 readonly borrower?: Borrower | undefined
315 readonly transactionAcquirer: Effect.Effect<Connection, SqlError, Scope.Scope>
316 readonly listenAcquirer: Effect.Effect<PgConnection.PgConnection, SqlError, Scope.Scope>
317 readonly config: PgClientConfig<R>
318 readonly poolStats: Effect.Effect<Pool.Stats>
319 }
320): Effect.fn.Return<PgClient & Client.SqlClient, SqlError, Scope.Scope | Reactivity.Reactivity | R> {
321 // The consuming fiber's services take precedence over the captured ones.
322 const hook = options.config.onAcquire
323 const context = yield* Effect.context<R>()
324 const onAcquire = hook &&
325 Effect.updateContext(hook, (current: Context.Context<never>) => Context.merge(context, current))
326 const config: PgClientConfig = { ...options.config, onAcquire }
327 const resolved = yield* resolveConfig(config)
328 let { acquirer, borrower, listenAcquirer, transactionAcquirer } = options
329 if (onAcquire !== undefined) {
330 acquirer = Effect.tap(acquirer, onAcquire)
331 transactionAcquirer = Effect.tap(transactionAcquirer, onAcquire)
332 listenAcquirer = Effect.tap(listenAcquirer, onAcquire)
333 if (borrower !== undefined) {
334 const borrow = borrower
335 // Scope each statement so hook finalizers run when it ends.
336 borrower = (f) => borrow((connection) => Effect.scoped(Effect.andThen(onAcquire, f(connection))))
337 }
338 }
339 const compiler = makeCompiler(
340 config.transformQueryNames,
341 config.transformJson
342 )
343 const transformRows = config.transformResultNames ?
344 Statement.defaultTransforms(
345 config.transformResultNames,
346 config.transformJson
347 ).array :
348 undefined
349​
350 const listen = (
351 channel: string
352 ): Effect.Effect<Queue.Dequeue<PgConnection.Notification, SqlError>, SqlError, Scope.Scope> =>
353 Effect.flatMap(listenAcquirer, (connection) => connection.listen(channel))
354​
355 const spanAttributes: ReadonlyArray<readonly [string, unknown]> = [
356 ...(config.spanAttributes ? Object.entries(config.spanAttributes) : []),
357 [ATTR_DB_SYSTEM_NAME, "postgresql"],
358 // PostgreSQL connects to the database named after the user when none is given.
359 [ATTR_DB_NAMESPACE, resolved.startupParameters.database ?? resolved.username],
360 [ATTR_SERVER_ADDRESS, resolved.host],
361 [ATTR_SERVER_PORT, resolved.port]
362 ]
363​
364 const client = yield* Client.make({
365 driver: "pg",
366 acquirer,
367 borrower,
368 // Postgres prepares transaction control like anything else, and a client
369 // with preparation turned off falls back to the unnamed path anyway.
370 prepareTransactionControls: true,
371 commit,
372 onCommitFailure,
373 // A session the server ended has nothing left to roll back.
374 isTransaction: (conn) => connectionInternals((conn as ConnectionImpl).connection).deadError() === undefined,
375 releaseSavepoint: (name) => `RELEASE SAVEPOINT ${name}`,
376 transactionAcquirer,
377 compiler,
378 spanAttributes,
379 transformRows
380 })
381​
382 // Routed and traced as a statement is, without the connection wait time.
383 const queryTextValues = (sql: string, params?: ReadonlyArray<unknown>) =>
384 Effect.useSpan(Statement.spanName(spanAttributes), { kind: "client" }, (span) =>
385 Effect.withFiber((fiber) => {
386 for (const [key, value] of spanAttributes) {
387 span.attribute(key, value)
388 }
389 span.attribute(ATTR_SQL_METHOD, "executeTextValues")
390 span.attribute(ATTR_DB_QUERY_TEXT, sql)
391 const run = (connection: Connection) => (connection as ConnectionImpl).connection.queryTextValues(sql, params)
392 const transaction = Context.getOrUndefined(fiber.context, client.transactionService)
393 const execute = transaction !== undefined
394 ? Effect.flatMap(Client.activeTransactionConnection(transaction), run)
395 : borrower !== undefined
396 ? borrower(run)
397 : Effect.scoped(Effect.flatMap(acquirer, run))
398 return fiber.cache.tracerEnabled && fiber.getRef(Statement.SpanPropagationEnabled)
399 ? Effect.provideService(execute, Tracer.ParentSpan, span)
400 : execute
401 }))
402​
403 return Object.assign(
404 client,
405 {
406 [TypeId]: TypeId as TypeId,
407 config,
408 poolStats: options.poolStats,
409 json: (_: unknown) => Statement.fragment([PgJson(_)]),
410 listen,
411 queryTextValues,
412 notify: (channel: string, payload: string) => {
413 const channelError = validateChannelName(channel, "notify")
414 return channelError !== undefined ?
415 Effect.fail(channelError) :
416 Effect.asVoid(Effect.scoped(Effect.flatMap(
417 acquirer,
418 (conn) => conn.executeRaw(`SELECT pg_notify($1, $2)`, [channel, payload])
419 )))
420 }
421 }
422 )
423})
424​
425class ConnectionImpl implements Connection {
426 readonly connection: PgConnection.PgConnection
427 readonly streamAcquirer: Effect.Effect<PgConnection.PgConnection, SqlError, Scope.Scope> | undefined
428​
429 constructor(
430 connection: PgConnection.PgConnection,
431 streamAcquirer?: Effect.Effect<PgConnection.PgConnection, SqlError, Scope.Scope> | undefined
432 ) {
433 this.connection = connection
434 this.streamAcquirer = streamAcquirer
435 }
436​
437 private run(query: string, params: ReadonlyArray<unknown>, prepare = true) {
438 return Effect.map(this.connection.query(query, params, prepare), (result) => result.rows)
439 }
440​
441 execute(
442 sql: string,
443 params: ReadonlyArray<unknown>,
444 transformRows: (<A extends object>(row: ReadonlyArray<A>) => ReadonlyArray<A>) | undefined
445 ) {
446 return transformRows
447 ? Effect.map(this.run(sql, params), transformRows)
448 : this.run(sql, params)
449 }
450 executeRaw(sql: string, params: ReadonlyArray<unknown>) {
451 return this.connection.query(sql, params)
452 }
453 executeWithoutTransform(sql: string, params: ReadonlyArray<unknown>) {
454 return this.run(sql, params)
455 }
456 executeValues(sql: string, params: ReadonlyArray<unknown>) {
457 return this.connection.queryValues(sql, params)
458 }
459 executeValuesUnprepared(sql: string, params: ReadonlyArray<unknown>) {
460 return this.connection.queryValues(sql, params, false)
461 }
462 executeUnprepared(
463 sql: string,
464 params: ReadonlyArray<unknown>,
465 transformRows: (<A extends object>(row: ReadonlyArray<A>) => ReadonlyArray<A>) | undefined
466 ) {
467 const operation = this.run(sql, params, false)
468 return transformRows
469 ? Effect.map(operation, transformRows)
470 : operation
471 }
472 executeStream(
473 sql: string,
474 params: ReadonlyArray<unknown>,
475 transformRows: (<A extends object>(row: ReadonlyArray<A>) => ReadonlyArray<A>) | undefined
476 ) {
477 const stream = this.streamAcquirer === undefined
478 ? this.connection.stream(sql, params)
479 : Stream.unwrap(Effect.map(this.streamAcquirer, (connection) => connection.stream(sql, params)))
480 return transformRows
481 ? Stream.mapArray(stream, (rows) => transformRows(rows) as Arr.NonEmptyReadonlyArray<PgConnection.Row>)
482 : stream
483 }
485​
486/** PostgreSQL returns `ROLLBACK` for `COMMIT` when a transaction is aborted. */
487const commit = (conn: Connection): Effect.Effect<void, SqlError> =>
488 Effect.flatMap(
489 conn.executeRaw("COMMIT", []) as Effect.Effect<PgConnection.Result, SqlError>,
490 (result) =>
491 result.command === "ROLLBACK"
492 ? Effect.fail(
493 new SqlError({
494 reason: new UnknownError({
495 cause: new Error("COMMIT rolled back an aborted transaction"),
496 message: "PgClient: COMMIT rolled back an aborted transaction",
497 operation: "commit"
498 })
499 })
500 )
501 : Effect.void
502 )
503​
504/**
505 * Rolls back a transaction left open by a `COMMIT` the backend rejected before
506 * running it. Outside a transaction `ROLLBACK` only warns. Its own failure is
507 * ignored so the `COMMIT` error is the one reported; a session it leaves
508 * aborted is closed on pin release.
509 */
510const onCommitFailure = (conn: Connection): Effect.Effect<void> =>
511 Effect.ignore(conn.executeUnprepared("ROLLBACK", [], undefined))
512​
513const makeConnection = (
514 connection: PgConnection.PgConnection,
515 streamAcquirer?: Effect.Effect<PgConnection.PgConnection, SqlError, Scope.Scope> | undefined
516): Connection => new ConnectionImpl(connection, streamAcquirer)
517​
518/**
519 * Provides both `PgClient` and `SqlClient` from an acquisition effect.
520 *
521 * @stability unstable
522 * @category layers
523 * @since 4.0.0
524 */
525export const layerFrom = <E, R>(
526 acquire: Effect.Effect<PgClient & Client.SqlClient, E, R>
527): Layer.Layer<PgClient | Client.SqlClient, E, Exclude<R, Scope.Scope | Reactivity.Reactivity>> =>
528 Layer.effectContext(
529 Effect.map(acquire, (client) =>
530 Context.make(PgClient, client).pipe(
531 Context.add(Client.SqlClient, client)
532 ))
533 ).pipe(Layer.provide(Reactivity.layer)) as any
534​
535/**
536 * Creates a client layer from wrapped pool configuration.
537 *
538 * @stability unstable
539 * @category layers
540 * @since 4.0.0
541 */
542export const layerConfig = <R = never>(
543 config: Config.Wrap<PgPoolConfig<R>>
544): Layer.Layer<
545 PgClient | Client.SqlClient,
546 Config.ConfigError | SqlError,
547 Exclude<R, Scope.Scope | Reactivity.Reactivity>
548> =>
549 layerFrom(Effect.flatMap(
550 Config.unwrap(config),
551 make
552 ))
553​
554/**
555 * Creates a client layer from pool configuration.
556 *
557 * @stability unstable
558 * @category layers
559 * @since 4.0.0
560 */
561export const layer = <R = never>(
562 config: PgPoolConfig<R>
563): Layer.Layer<PgClient | Client.SqlClient, SqlError, Exclude<R, Scope.Scope | Reactivity.Reactivity>> =>
564 layerFrom(make(config))
565​
566/**
567 * Creates the PostgreSQL statement compiler.
568 *
569 * @stability unstable
570 * @category constructors
571 * @since 4.0.0
572 */
573export const makeCompiler = (
574 transform?: (_: string) => string,
575 transformJson = true
576): Statement.Compiler => {
577 const transformValue = transformJson && transform
578 ? Statement.defaultTransforms(transform).value
579 : undefined
580​
581 return Statement.makeCompiler<PgCustom>({
582 dialect: "pg",
583 placeholder(_) {
584 return `$${_}`
585 },
586 onIdentifier: transform ?
587 function(value, withoutTransform) {
588 return withoutTransform ? escape(value) : escape(transform(value))
589 } :
590 escape,
591 onRecordUpdate(placeholders, valueAlias, valueColumns, values, returning) {
592 return [
593 `(values ${placeholders}) AS ${valueAlias}${valueColumns}${returning ? ` RETURNING ${returning[0]}` : ""}`,
594 returning ?
595 values.flat().concat(returning[1]) :
596 values.flat()
597 ]
598 },
599 onCustom(type, placeholder, withoutTransform) {
600 switch (type.kind) {
601 case "PgJson": {
602 const value = withoutTransform || transformValue === undefined
603 ? type.paramA
604 : transformValue(type.paramA)
605 return [
606 placeholder(undefined),
607 [PgTypes.jsonb(value)]
608 ]
609 }
610 }
611 }
612 })
614​
615const escape = Statement.defaultEscape("\"")
616​
617/**
618 * PostgreSQL-specific statement fragments.
619 *
620 * @stability unstable
621 * @category models
622 * @since 4.0.0
623 */
624export type PgCustom = PgJson
625​
626/**
627 * @category models
628 * @since 4.0.0
629 */
630interface PgJson extends Custom<"PgJson", unknown> {}
631/**
632 * @category constructors
633 * @since 4.0.0
634 */
635const PgJson = Statement.custom<PgJson>("PgJson")
636​
637const ATTR_DB_SYSTEM_NAME = "db.system.name"
638const ATTR_DB_NAMESPACE = "db.namespace"
639const ATTR_SERVER_ADDRESS = "server.address"
640const ATTR_SERVER_PORT = "server.port"
641const ATTR_DB_QUERY_TEXT = "db.query.text"
642const ATTR_SQL_METHOD = "effect.sql.method"