Skip to content

Pipeline reuse has undefined behavior #198

@fox0430

Description

@fox0430

Add proc reset*(p: Pipeline) to clear all state explicitly

type
  Pipeline* = ref object
    ...
    autoReset*: bool  ## Default: false (backward-compatible)

proc newPipeline*(conn: PgConnection, autoReset: bool = false): Pipeline =
  Pipeline(conn: conn, autoReset: autoReset)

proc reset*(p: Pipeline) =
  ## Clear all queued ops and SoA buffers. Safe to call any time.
  p.ops.setLen(0)
  p.inlineData.setLen(0)
  p.inlineRanges.setLen(0)
  p.inlineOids.setLen(0)
  p.inlineFormats.setLen(0)

# End of execute/executeIsolated:
try:
  # ... Main ...
finally:
  if p.autoReset:
    p.reset()

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions