-
Notifications
You must be signed in to change notification settings - Fork 187
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
Windows Support #44
Comments
I did look at making it build on Windows, but besides adding some more -DDEFINEs and some stubs, I haven't progressed far. I think the general approach is to fake as much of the "normal" Pg environments to get the code to compile without any changes to the Pg code at all, but I don't understand why the files are copied during the build process. Can you maybe outline a bit what the general approach is? I have the rough idea that you implemented a preprocessor that rewrites/copies the C files according to some preset #defines, but a bit more detail would help me get more of the general approach. |
@Corion The general approach taken is that code is extracted using LLVM/clang (plus a Ruby helper script), see https://github.com/lfittl/libpg_query/blob/10-latest/scripts/extract_source.rb That means the code that gets extracted is partially dependent on the environment where the extraction runs, as well as the defines passed to clang: https://github.com/lfittl/libpg_query/blob/10-latest/scripts/extract_source.rb#L205 My general thoughts on how to make progress on this:
|
I've pushed my (really hacky) changes that I needed to make some progress on Windows as https://github.com/Corion/libpg_query/tree/win32-hackery . I think parts of my lack of progress can be attributed to the simply missing build files for Win32, but I'm not sure if the source code really has that many OS dependencies. I think at least the second point ("list of places where we error out") should be somewhat reduced with the changes in the win32-hackery branch. Please note that I approached the issue strictly with the mindset of "anything that's necessary to get this to compile", not with the mindset of understanding things or finding a nice/maintainable solution. So cherry-picking patches is not really advised except for maybe the parts where a #define was hacked. |
@Corion Nice, thanks for sharing! Its a priority for me to make progress on this, however there is a few other things on my plate too unfortunately. I'll update here with any progress I make as well to keep you and others in the loop. |
Any progress? |
@akeeman Not yet - thanks for checking! I'm curious, whats your use case for the library on Windows? |
A few of my colleagues are working on windows, and run some code on their local machine outside of their Docker container on a schedule. All the other code is platform independent, so before it was fine to do so. We use this library via pglast to extract the tables given a query. During tests it's for dynamically only inititalizing those tables used in the test during integration tests. Besides that it's for automatically locking tables we write. |
Hi, @lfittl any progress here? Here's my use case: I use Windows as my development workstation, although eventually this will be deployed to Heroku, running on some flavor of Linux. But while I am developing the code, I'd like to be able to run it locally to test/develop. I need to parse a view so that I can walk the parse tree and attempt to figure out which rows are dependent on a row currently being updated. Thank you for your hard work to maintain such a useful package! I can't wait to start using it. |
@amhuhn2 Nothing to report yet, but thanks for the additional context of your use case - that is helpful to know. I may be able to take some time to work on this in the upcoming weeks, and will certainly update this issue as I get closer to making this a reality. Thanks for your patience! |
Sounds good, @lfittl , thank you. |
@lfittl Any progess on this? In our use case, we use pg-query-parser for our package for building dynamic AST queries in node. pg-query-parser relies on pg-query-native, which in turn, relies on this package. Because this package doesn't have windows support, some of the build symbols for the other packages fail, thus making the whole project to fail install. All of our team works on macs, where this package works, but in order to allow windows development, this is the only package out of hundreds that ends up preventing it. |
Any updates on this? |
@daisuke-yoshimoto No updates at this point - Windows support is definitely doable, but I (and the team at pganalyze) have our hands full with other things. PRs are of course welcome, if you are affected by this and would like to help solve the issue (since Postgres itself builds fine on Windows, we are most likely just missing a few files for portability). We may have time to work on this with the Postgres 14 version of the parser, planned for later this year. |
Thank you for your reply. I understood the situation. I will use it via wsl for a while. |
Hi @lfittl Any Update on this? |
Hi @lfittl , Thanks for the amazing library. This library has proved to be ver helpful for us. Just wanted to check if windows support is still in your list. If not can you please suggest libraries which help us do so. |
@heysinghal @404shades Its still something I'd like to support eventually, but its not a high priority at this point (and there is no ETA for supporting it). The main challenge here is related to build tooling - Postgres itself of course supports Windows, but that has a lot of supporting logic we don't have in libpg_query today. If you are looking for alternate solutions I would just search for other SQL parser projects (and investigate e.g. CockroachDB's SQL parser). The main motivation for using pg_query is for when you need full Postgres compatibility. For that I'm not aware of any other projects that provide the Postgres parser as a library. Hope that helps! |
Just chiming in here to say that it seems that this is affecting our bootcamp students who are trying to use the amazing SafeQL SQL linter (
So the people on Windows currently cannot get linting errors on their SQL queries 😬 Thanks for the project by the way! Really incredible what it enables. Windows support would enable more people to access this! |
@lfittl if anyone has time to take a look at this before you get around to it, do you have any idea about the reasons that this is breaking? Below is the build log copied from ts-safeql/safeql#80 (the lines with
|
@lfittl Oh sorry, I see now that you posted back in 2018 a todo list about this - is this still accurate? If it is still accurate, would you mind adding a bit more detail as to how to achieve each step in your list? Then maybe someone like @Eprince-hub may be able to spend some time on this - at least to compile the list of errors that happen. |
@karlhorky Yes, this is still accurate. What I would recommend is comparing a Postgres source build and a libpg_query build side-by-side, and see what the differences are that need to be addressed. Its likely that the defines that are set are not correct for Windows (Postgres usually autodetects this via the configure script), as well as some files might be missing that need to be present. Assuming you are working with the latest This might be easy, or a lot of effort, but unfortunately due to time constraints (and lack of access to a Windows dev machine) I won't have time to help much on this at this point in time. |
If there was a bounty on this issue, would this change the situation for you at all? :) We would love to jump in and do this, but are also constrained on time at the moment. |
Thanks for the offer, but the problem is our team being time limited / having an engineer with a Windows machine ready to take this on, not that we wouldn't want to pay someone to work on it :) |
Is there any way for someone, who has never worked with C (aka me), to help with this? I do have a Windows desktop and would like to help in any way I can! |
Wonder if an unconventional alternative would be to compile the C code to WebAssembly (Wasm) using something like Of course, ideally Also, if the compiled Wasm could be published to npm, then it may offer a way to avoid the compilation step every time the cc @Newbie012 |
@RReverser recently ported Sharp to WebAssembly, and used the |
@gregnr opened a PR using @lfittl would this be an acceptable approach for mainline |
cc @yrashk, in case figuring out compiling |
Thank you all for your patience on getting this resolved! After a lot of experimentation over the holidays, I'm happy to say that this is resolved, and the latest libpg_query 16-5.1.0 release now supports Windows. If you're using libpg_query through a binding in another language, I would expect the corresponding maintainers to update soon (and we at pganalyze will be releasing updated Go/Ruby/Rust bindings later this week). |
Yes, I hope to tackle this in lelit/pglast#7: main problem is to figure out how to call |
Issue to track support of Windows - currently it is not supported, in part due to build process, in part because the code extraction from Postgres intentionally ignores Windows code.
The text was updated successfully, but these errors were encountered: