Title: [BUG] PostgreSQL: ALTER TABLE ... ADD CONSTRAINT with DEFERRABLE INITIALLY DEFERRED / NOT VALID does not parse · Issue #2850 · JSQLParser/JSqlParser · GitHub
Open Graph Title: [BUG] PostgreSQL: ALTER TABLE ... ADD CONSTRAINT with DEFERRABLE INITIALLY DEFERRED / NOT VALID does not parse · Issue #2850 · JSQLParser/JSqlParser
X Title: [BUG] PostgreSQL: ALTER TABLE ... ADD CONSTRAINT with DEFERRABLE INITIALLY DEFERRED / NOT VALID does not parse · Issue #2850 · JSQLParser/JSqlParser
Description: These statements are valid in PostgreSQL. pg_dump writes the first one for every deferrable foreign key. CREATE TABLE accepts the same constraint attributes, ALTER TABLE ... ADD CONSTRAINT does not. JSqlParser: current master (90ac3a7), ...
Open Graph Description: These statements are valid in PostgreSQL. pg_dump writes the first one for every deferrable foreign key. CREATE TABLE accepts the same constraint attributes, ALTER TABLE ... ADD CONSTRAINT does not...
X Description: These statements are valid in PostgreSQL. pg_dump writes the first one for every deferrable foreign key. CREATE TABLE accepts the same constraint attributes, ALTER TABLE ... ADD CONSTRAINT does not...
Opengraph URL: https://github.com/JSQLParser/JSqlParser/issues/2850
X: @github
Domain: github.com
IPv4 address: 140.82.112.4
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[BUG] PostgreSQL: ALTER TABLE ... ADD CONSTRAINT with DEFERRABLE INITIALLY DEFERRED / NOT VALID does not parse","articleBody":"These statements are valid in PostgreSQL. `pg_dump` writes the first one for every deferrable foreign key. `CREATE TABLE` accepts the same constraint attributes, `ALTER TABLE ... ADD CONSTRAINT` does not.\r\n\r\nJSqlParser: current `master` (90ac3a7), JDK 25.\r\n\r\n```java\r\nCCJSqlParserUtil.parse(\"ALTER TABLE ONLY public.t ADD CONSTRAINT t_fk FOREIGN KEY (a_id) REFERENCES public.a(id) DEFERRABLE INITIALLY DEFERRED\");\r\n```\r\n\r\n| Statement | Result |\r\n|---|---|\r\n| `ALTER TABLE t ADD CONSTRAINT fk FOREIGN KEY (a) REFERENCES u (id) DEFERRABLE` | parses |\r\n| `... FOREIGN KEY (a) REFERENCES u (id) DEFERRABLE INITIALLY DEFERRED` | `Encountered: \u003cS_IDENTIFIER> / \"INITIALLY\"` |\r\n| `... FOREIGN KEY (a) REFERENCES u (id) INITIALLY IMMEDIATE` | `Encountered: \u003cS_IDENTIFIER> / \"INITIALLY\"` |\r\n| `ALTER TABLE t ADD CONSTRAINT t_uq UNIQUE (a) DEFERRABLE INITIALLY DEFERRED` | `Encountered: \"INITIALLY\"` |\r\n| `ALTER TABLE t ADD CONSTRAINT t_pk PRIMARY KEY (a) DEFERRABLE INITIALLY IMMEDIATE` | `Encountered: \"INITIALLY\"` |\r\n| `ALTER TABLE t ADD CONSTRAINT t_ck CHECK (a > 0) NOT VALID` | `Encountered: \u003cK_NOT> / \"NOT\"` |\r\n| `ALTER TABLE t ADD FOREIGN KEY (a) REFERENCES u (id) DEFERRABLE INITIALLY DEFERRED` | `Encountered: \u003cK_DEFERRABLE> / \"DEFERRABLE\"` (without `CONSTRAINT name`, even plain `DEFERRABLE` fails) |\r\n| `CREATE TABLE t (a int, CONSTRAINT fk FOREIGN KEY (a) REFERENCES u (id) DEFERRABLE INITIALLY DEFERRED)` | parses |\r\n\r\nThe `CREATE TABLE` path goes through `PostgreSqlConstraintAttributeList` (the `INITIALLY` and `NOT VALID` handling in `JSqlParserCC.jjt`). The `ALTER TABLE ... ADD` production seems not to call it for all constraint kinds.\r\n\r\nFound while checking a list of about 200 statements against `master`. Most of them parsed and round-tripped.\r\n","author":{"url":"https://github.com/ItsDeadlyProgrammer","@type":"Person","name":"ItsDeadlyProgrammer"},"datePublished":"2026-10-23T05:39:30Z","url":"https://github.com/JSQLParser/JSqlParser/issues/2850"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:1f45b0d2-6620-066d-13c3-d625667b7042 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 8B4A:3A6B0F:9394D5:D0C76C:6B042EAF |
| html-safe-nonce | 053bb2214a910bffec8579ee778cd64597c3c6ea3e4806467ccfec67b948ee09 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4QjRBOjNBNkIwRjo5Mzk0RDU6RDBDNzZDOjZCMDQyRUFGIiwidmlzaXRvcl9pZCI6IjEyMjEzNjIwMTIxMjc1MDYwOTUiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 960752b90413f68b8ced4e20b292c83e19725a779fc0d4229be031ad359a2afa |
| hovercard-subject-tag | issue:5992558327 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/JSQLParser/JSqlParser/2850/issue_layout |
| twitter:image | https://opengraph.githubassets.com/f81685838219b991b32e12e9413ad30856d79f53e6e0865bebc0b8ac9cc8f25e/JSQLParser/JSqlParser/issues/2850 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/f81685838219b991b32e12e9413ad30856d79f53e6e0865bebc0b8ac9cc8f25e/JSQLParser/JSqlParser/issues/2850 |
| og:image:alt | These statements are valid in PostgreSQL. pg_dump writes the first one for every deferrable foreign key. CREATE TABLE accepts the same constraint attributes, ALTER TABLE ... ADD CONSTRAINT does not... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | ItsDeadlyProgrammer |
| hostname | github.com |
| expected-hostname | github.com |
| None | b7a1d2b9101496921b08579fbee988d014345aef2f5bd660d1f8c7332d81560e |
| turbo-cache-control | no-preview |
| go-import | github.com/JSQLParser/JSqlParser git https://github.com/JSQLParser/JSqlParser.git |
| octolytics-dimension-user_id | 4643847 |
| octolytics-dimension-user_login | JSQLParser |
| octolytics-dimension-repository_id | 1944709 |
| octolytics-dimension-repository_nwo | JSQLParser/JSqlParser |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 1944709 |
| octolytics-dimension-repository_network_root_nwo | JSQLParser/JSqlParser |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | c3dd496c3da6ea6b77e69c09279d2b81604654f1 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | max-age=0, private, must-revalidate |
Viewport: width=device-width