{"id":17783547,"url":"https://github.com/skalt/psql_splitter","last_synced_at":"2025-10-04T07:20:00.288Z","repository":{"id":139646312,"uuid":"434931287","full_name":"SKalt/psql_splitter","owner":"SKalt","description":"a nom parser combinator that matches a psql statement.","archived":false,"fork":false,"pushed_at":"2022-02-27T15:02:57.000Z","size":21,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-01T22:33:36.407Z","etag":null,"topics":["parser","parsing","postgres","postgresql","psql","sql"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/SKalt.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-12-04T15:00:44.000Z","updated_at":"2021-12-06T14:12:28.000Z","dependencies_parsed_at":"2023-06-09T16:30:20.936Z","dependency_job_id":null,"html_url":"https://github.com/SKalt/psql_splitter","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/SKalt/psql_splitter","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SKalt%2Fpsql_splitter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SKalt%2Fpsql_splitter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SKalt%2Fpsql_splitter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SKalt%2Fpsql_splitter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SKalt","download_url":"https://codeload.github.com/SKalt/psql_splitter/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SKalt%2Fpsql_splitter/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261487389,"owners_count":23166079,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["parser","parsing","postgres","postgresql","psql","sql"],"created_at":"2024-10-27T07:43:11.027Z","updated_at":"2025-10-04T07:19:55.238Z","avatar_url":"https://github.com/SKalt.png","language":"Rust","readme":"# psql_splitter\n\na [`nom`](https://github.com/Geal/nom) parser combinator that matches a psql statement.\n\nPostgres has a dialect of SQL that I'm going to call pgsql.\nPostgres also has a client, `psql`, which recognizes meta-commands and inline-copy syntax that normal pgsql does not.\nThis parser recognizes psql meta-commands and pgsql tokens, allowing the `statement` combinator to know when a statement has ended.\nThe `statement` combinator also attaches color commentary on the end of a line to the previous statement, so `select 1; -- take a number` is matched as one statement.\n\n## Status\n\nThis is a hack with some tests, a README, and a license.\n\nThis parser doesn't understand all the tokens in pgsql and psql, which has its pros:\n\n- `psql_splitter::statement` is more likely to split statements out of invalid psql\n- a simpler parser is easier to maintain\n\nbut also its cons:\n\n- a simpler parser is more likely to be missing something about the enormous pgsql language\n\n## Scope/features\n\n- the splitter should match invalid psql, always splitting the input into one or more statements\n- the splitter should treat psql meta-commands as statement terminators, e.g `select 1 as foo \\gset` and `\\d my_table` would both be complete statements.\n- the splitter should ignore statement-terminators inside pgsql strings and parentheses and exotic psql such as `\\if ... \\endif` and `COPY table_name FROM STDIN; ... \\.`\n- the splitter should somewhat-reliably split psql and pgsql statements as defined by postgres, but not neccessarily other sql-like dialects derived from postgres's psql and pgsql.\n- the splitter should be correct. Speed, a small binary, and memory efficiency aren't goals, but they're nice to have.\n\n## Contributing\n\nIf you find a bug, please submit an issue with a reproduction case.\nPRs for tooling would also be welcome.\n\n## License\n\nWhile this library is offered under the attached BSD 3-clause at ./LICENSE, `./src/*.sql` are excerpts from the postgres codebase, and so are covered by [the postgres license](https://www.postgresql.org/about/licence/).\n\n## Prior art\n\n[`libpg_query`'s `split_with_scanner`](https://github.com/pganalyze/libpg_query)\n[`codeschool/sqlite-parser`'s test-suite-extraction tools](https://github.com/codeschool/sqlite-parser/blob/master/test/misc/test-grammar.pegjs)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fskalt%2Fpsql_splitter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fskalt%2Fpsql_splitter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fskalt%2Fpsql_splitter/lists"}