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

Expose frame options #77

Open
autarch opened this issue Nov 22, 2020 · 4 comments
Open

Expose frame options #77

autarch opened this issue Nov 22, 2020 · 4 comments

Comments

@autarch
Copy link

autarch commented Nov 22, 2020

The frameOptions field shows up in a couple different structs. It's currently defined as an int in the struct_defs.json file, but it's really a set of bitmasks. It'd be nice if these were exposed in some form or other. I'm not sure exactly where the data should go, though. Maybe this needs a new file in srcdata for such things?

@autarch
Copy link
Author

autarch commented Nov 22, 2020

There are a few other similar cases that I've noticed, including AclMode and cursor options, CURSOR_OPT_*.

@lfittl
Copy link
Member

lfittl commented Feb 20, 2021

@autarch Thats a good point - but I'm not sure how to expose that information either (we could certainly extract it from the source). If you are at the C layer (i.e. writing C code yourself) you could potentially access the C defines, so its mostly a question of how to solve this in a higher-level language wrapper.

To help me prioritize this, can you describe your use case for libpg_query a bit more?

@autarch
Copy link
Author

autarch commented Feb 21, 2021

I'm using the JSON files to generate Rust structs for a Rust program that uses libpg_query via libpg_query-sys. The latter is a very thin Rust wrapper around libpg_query that returns parse results as JSON. I turn those JSON results into actual structs.

You can see an example of the generated code at https://github.com/houseabsolute/pg-pretty/blob/master/parser/src/ast.rs. For now I've just made my own FrameOptions enum manually in https://github.com/houseabsolute/pg-pretty/blob/master/parser/src/flags.rs, but if I had the relevant JSON data I'm sure I could generate this as well, which would be preferable.

Just FYI, the program I'm writing is a pretty printer for Postges SQL (and hopefully PL/pgSQL in the future).

@lfittl
Copy link
Member

lfittl commented Feb 21, 2021

@autarch Makes sense, thanks for sharing!

I'll keep in mind how we can address this in the future. For now I'm fully focused on finally getting the Postgres 13 parser release out, but this would certainly be a change worth making after that (but can't make any promises at this point when I'll get to it).

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

No branches or pull requests

2 participants