Skip to content

internal/dinosql: Implement advisory locks #212

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Dec 24, 2019
Merged

Conversation

kyleconroy
Copy link
Collaborator

Fixes #211

@kyleconroy
Copy link
Collaborator Author

This still isn't perfect, mainly due to the void return type

$ sqlc generate
2019/12/22 19:12:29 unknown Postgres type: void
2019/12/22 19:12:29 unknown Postgres type: void
2019/12/22 19:12:29 unknown Postgres type: void

@kyleconroy
Copy link
Collaborator Author

Okay, it's looking good now

const acquireLock = `-- name: AcquireLock :exec
SELECT pg_advisory_xact_lock($1)
`

func (q *Queries) AcquireLock(ctx context.Context, key int64) error {
    _, err := q.db.ExecContext(ctx, acquireLock, key)                                                                                                                                                       
    return err
}

@kyleconroy kyleconroy merged commit 3a876eb into master Dec 24, 2019
@kyleconroy kyleconroy deleted the advisory-lock branch December 24, 2019 01:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Acquire advisory lock
1 participant