Skip to content
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

feat: add support for create publication #92

Closed
wants to merge 4 commits into from

Conversation

cvng
Copy link
Contributor

@cvng cvng commented Dec 19, 2023

What kind of change does this PR introduce?

Bug fix, feature, docs update, ...

What is the current behavior?

Please link any relevant issues here.

What is the new behavior?

panics

View log
Parsing node CreatePublicationStmt(
    CreatePublicationStmt {
        pubname: "mypublication",
        options: [],
        pubobjects: [
            Node {
                node: Some(
                    PublicationObjSpec(
                        PublicationObjSpec {
                            pubobjtype: PublicationobjTable,
                            name: "",
                            pubtable: Some(
                                PublicationTable {
                                    relation: Some(
                                        RangeVar {
                                            catalogname: "",
                                            schemaname: "",
                                            relname: "users",
                                            inh: true,
                                            relpersistence: "p",
                                            alias: None,
                                            location: 43,
                                        },
                                    ),
                                    where_clause: None,
                                    columns: [],
                                },
                            ),
                            location: 0,
                        },
                    ),
                ),
            },
            Node {
                node: Some(
                    PublicationObjSpec(
                        PublicationObjSpec {
                            pubobjtype: PublicationobjTable,
                            name: "",
                            pubtable: Some(
                                PublicationTable {
                                    relation: Some(
                                        RangeVar {
                                            catalogname: "",
                                            schemaname: "",
                                            relname: "departments",
                                            inh: true,
                                            relpersistence: "p",
                                            alias: None,
                                            location: 50,
                                        },
                                    ),
                                    where_clause: None,
                                    columns: [],
                                },
                            ),
                            location: 50,
                        },
                    ),
                ),
            },
        ],
        for_all_tables: false,
    },
)
thread 'valid_statements' panicked at crates/parser/src/parse/libpg_query_node.rs:373:13:
assertion `left == right` failed: Tried to start node Node {
    kind: PublicationObjSpec,
    depth: 2,
    properties: [],
    location: Some(
        0,
    ),
} with location 0 but current location is 43
  left: 0
 right: 43
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
thread 'valid_statements' panicked at crates/parser/tests/statement_parser_test.rs:36:17:
Failed to parse statement 0050:
CREATE PUBLICATION mypublication FOR TABLE users, departments;

Additional context

failing case:

CREATE PUBLICATION mypublication FOR TABLE users, departments;
^                                        ^

NOTE: adding a PublicationObjSpec in get_node_properties did not help but I have to check again

@cvng cvng marked this pull request as draft December 19, 2023 01:18
@cvng
Copy link
Contributor Author

cvng commented Dec 19, 2023

after inspection, it looks like the location (Some(0)) of the first PublicationObjSpec from the AST is wrong

EDIT: it turns out the PublicationObjSpec has an inner RangeVar where the location (Some(43)) is indeed correct

CREATE PUBLICATION mypublication FOR TABLE users, departments;
            Node {
                node: Some(
                    PublicationObjSpec(
                        PublicationObjSpec {
                            pubobjtype: PublicationobjTable,
                            name: "",
                            pubtable: Some(
                                PublicationTable {
                                    relation: Some(
                                        RangeVar {
                                            catalogname: "",
                                            schemaname: "",
                                            relname: "users",
                                            inh: true,
                                            relpersistence: "p",
                                            alias: None,
                                            location: 43, // <-
                                        },
                                    ),
                                    where_clause: None,
                                    columns: [],
                                },
                            ),
                            location: 0, // <-
                        },
                    ),
                ),
            },
thread 'valid_statements' panicked at crates/parser/src/parse/libpg_query_node.rs:373:13:
assertion `left == right` failed: Tried to start node Node {
    kind: PublicationObjSpec,
    depth: 2,
    properties: [],
    location: Some(
        0,
    ),
} with location 0 but current location is 43
  left: 0
 right: 43

cc @psteinroe

@cvng
Copy link
Contributor Author

cvng commented Dec 22, 2023

Included in #94

@cvng cvng closed this Dec 22, 2023
@cvng cvng deleted the feat/create-publication branch December 22, 2023 19:47
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.

1 participant