Skip to content

segmentation fault with example project from README #53

Open
@alex-dukhno

Description

@alex-dukhno

Hi thank you for this crate, I am considering to use it in my db project instead of sqlparser

However, when I tried to run simple project from README example:

use postgres_parser::*;

fn main() {
    let args: Vec<String> = std::env::args().collect();
    let query_string = args.get(1).expect("no arguments");
    let parse_list = match parse_query(query_string) {
        Ok(query) => query,
        Err(e) => {
            eprintln!("{:?}", e);
            std::process::exit(1);
        }
    };

    let as_json = serde_json::to_string_pretty(&parse_list).expect("failed to convert to json");
    println!("{}", as_json);
}

I got segmentation fault:

alex-dukhno@Alexs-MacBook Projects/test-pro (master %) » cargo run ../isomorphicdb/docs/user-guide/sql/basic_queries.sql
    Finished dev [unoptimized + debuginfo] target(s) in 0.03s
     Running `target/debug/test-pro ../isomorphicdb/docs/user-guide/sql/basic_queries.sql`
[1]    45017 segmentation fault  cargo run ../isomorphicdb/docs/user-guide/sql/basic_queries.sql

however, when I run one example (e.g. scanner) it works 🤷‍♂️ :

alex-dukhno@Alexs-MacBook Projects/postgres-parser (fix-workflow-for-mac-os) » cargo run --example scanner ../isomorphicdb/docs/user-guide/sql/basic_queries.sql
   Compiling postgres-parser v0.2.2 (/Users/alex-dukhno/Projects/postgres-parser)
    Finished dev [unoptimized + debuginfo] target(s) in 15.26s
     Running `target/debug/examples/scanner ../isomorphicdb/docs/user-guide/sql/basic_queries.sql`
#1
-- Copyright 2020 - present Alex Dukhno
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
--     http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.

create schema SMOKE_QUERIES;
-- {"CreateSchemaStmt":{"schemaname":"smoke_queries","if_not_exists":false}}
....

any advice on how to troubleshoot this appreciated 😄

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions