(ctx context.Context, params *riverdriver.JobInsertFastManyParams)
| 527 | } |
| 528 | |
| 529 | func (e *Executor) JobInsertFastMany(ctx context.Context, params *riverdriver.JobInsertFastManyParams) ([]*riverdriver.JobInsertFastResult, error) { |
| 530 | // We use a special `(xmax != 0)` trick in Postgres to determine whether an |
| 531 | // upserted row was inserted or skipped, but as far as I can find, there's no |
| 532 | // such trick possible in SQLite. Instead, we roll a random nonce and insert |
| 533 | // it to metadata. If the same nonce comes back, we know we really inserted |
| 534 | // the row. If not, we're getting an existing row back. |
| 535 | uniqueNonce := randutil.Hex(8) |
| 536 | |
| 537 | jobsParam, err := sqliteJobInsertFastManyJobsParam(params.Jobs, uniqueNonce) |
| 538 | if err != nil { |
| 539 | return nil, err |
| 540 | } |
| 541 | |
| 542 | jobs, err := dbsqlc.New().JobInsertFastMany(schemaTemplateParam(ctx, params.Schema), e.dbtx, jobsParam) |
| 543 | if err != nil { |
| 544 | return nil, interpretError(err) |
| 545 | } |
| 546 | |
| 547 | return sliceutil.MapError(jobs, func(internal *dbsqlc.RiverJob) (*riverdriver.JobInsertFastResult, error) { |
| 548 | job, err := jobRowFromInternal(internal) |
| 549 | if err != nil { |
| 550 | return nil, err |
| 551 | } |
| 552 | |
| 553 | return &riverdriver.JobInsertFastResult{ |
| 554 | Job: job, |
| 555 | UniqueSkippedAsDuplicate: gjson.GetBytes(job.Metadata, rivercommon.MetadataKeyUniqueNonce).Str != uniqueNonce, |
| 556 | }, nil |
| 557 | }) |
| 558 | } |
| 559 | |
| 560 | func (e *Executor) JobInsertFastManyNoReturning(ctx context.Context, params *riverdriver.JobInsertFastManyParams) (int, error) { |
| 561 | jobsParam, err := sqliteJobInsertFastManyJobsParam(params.Jobs, "") |
nothing calls this directly
no test coverage detected