Comments (19)
Hi,
Unfortunately this is out of my knowledge. I don't have a windows system and didn't use one in more than a decade, so I'm not in a position to do it.
If you have a windows system, you could maybe try https://wiki.postgresql.org/wiki/Building_and_Installing_PostgreSQL_Extension_Modules or https://www.2ndquadrant.com/en/blog/compiling-postgresql-extensions-visual-studio-windows/.
Note that I'll be happy to fix any problem this may undercover with the source code (it will likely have issue with missing PGDLLEXPORT, maybe other things).
from pg_qualstats.
That's an excellent news! Thanks a lot for testing @gdonufrio!
I will upload the zip archives and installers for all pg versions then, and will keep doing so for all upcoming releases for all the extensions I maintain!
from pg_qualstats.
Hi, playing with compilation on windows as advised here: https://wiki.postgresql.org/wiki/Building_and_Installing_PostgreSQL_Extension_Modules
I got just one error:
Severity Code Description Project File Line Suppression State
Error LNK2001 unresolved external symbol autovacuum_max_workers pg_qualstats pg_qualstats.obj 1
Otherwise, the compilation goes fine.
Also, I suppose need to be added PGDLLEXPORT as advised above (see link)
from pg_qualstats.
@suprimex thanks a lot for looking at it!
Unfortunately the problem with autovacuum_max_workers
has to be fixed in postgres, not pg_qualstats. Looking at previous changes in postgres to add PGDLLIMPORT, such annotation aren't backported so it means that pg_qualstats wouldn't be compilable on windows before postgres 15 at best. I'll try to have the PGDLLIMPORT added in postgres 15 and also see if I can use an alternative method to retrieve the value so you can compile pg_qualstats on windows with existing postgres versions. It would be a bit less efficient but it's only needed once during server startup so it shouldn't be a problem.
from pg_qualstats.
@suprimex I just pushed a fix_windows branch (https://github.com/powa-team/pg_qualstats/tree/fix_windows) that should fix at least this issue. Is that enough to allow compilation on Windows?
from pg_qualstats.
Thanks, @rjuju now it is compiled without errors.
But do not forget about PGDLLEXPORT as advised above link, otherwise, at runtime, we getting an error:
Could not find function "pg_qualstats_2_0" in file ... pg_qualstats.ddl
from pg_qualstats.
p.s. (quote) You should also add a prototype marked PGDLLEXPORT for the function so that MSVC knows to export its symbol:
PGDLLEXPORT Datum <your_function_name>(PG_FUNCTION_ARGS); /* << like this*/
PG_FUNCTION_INFO_V1(your_function_name);
from pg_qualstats.
Thanks for checking the patch. For the PGDLLEXPORT, I thought that PG_FUNCTION_INFO_V1 would take care of that. But looking twice it's actually doing half the work unfortunately, as seen in https://github.com/postgres/postgres/blob/master/src/include/fmgr.h#L417:
* On Windows, the function and info function must be exported. Our normal
* build processes take care of that via .DEF files or --export-all-symbols.
* Module authors using a different build process might need to manually
* declare the function PGDLLEXPORT. We do that automatically here for the
* info function, since authors shouldn't need to be explicitly aware of it.
*/
#define PG_FUNCTION_INFO_V1(funcname) \
extern Datum funcname(PG_FUNCTION_ARGS); \
extern PGDLLEXPORT const Pg_finfo_record * CppConcat(pg_finfo_,funcname)(void); \
const Pg_finfo_record * \
[...]
So I'm assuming that I have to do it for all the functions declared as PG_FUNCTION_INFO_V1()? Do you know if other things need it too (like maybe the GUC variables)?
from pg_qualstats.
yes, I just added:
PGDLLEXPORT Datum pg_qualstats_reset (PG_FUNCTION_ARGS);
PGDLLEXPORT Datum pg_qualstats (PG_FUNCTION_ARGS);
PGDLLEXPORT Datum pg_qualstats_2_0 (PG_FUNCTION_ARGS);
PGDLLEXPORT Datum pg_qualstats_names (PG_FUNCTION_ARGS);
PGDLLEXPORT Datum pg_qualstats_names_2_0 (PG_FUNCTION_ARGS);
PGDLLEXPORT Datum pg_qualstats_example_query (PG_FUNCTION_ARGS);
PGDLLEXPORT Datum pg_qualstats_example_queries (PG_FUNCTION_ARGS);
But now, I assume, there is something wrong with the mechanism which detecting how the library was loaded.
Any call to the library gives me a message "ERROR: pg_qualstats must be loaded via shared_preload_libraries"
SHOW shared_preload_libraries; gives me "pg_qualstats, pg_stat_statements"
from pg_qualstats.
Any call to the library gives me a message "ERROR: pg_qualstats must be loaded via shared_preload_libraries"
SHOW shared_preload_libraries; gives me "pg_qualstats, pg_stat_statements"
Building on windows shouldn'thave any impact on this I think. The error message is not really accurate anymore though, as pg_qualstats can also be used in a "stand alone" mode. Did you restart postgres after compiling and changing the shared_preload_libraries? Is it working it you do something like:
SET pg_qualstats.sample_rate = 1;
SET pg_qualstats.track_pg_catalog = 1;
SELECT count(*) from pg_class where relname = 'pg_qualstats';
SELECT * from pg_qualstats();
from pg_qualstats.
Sure ;-) restarted.
SET pg_qualstats.sample_rate = 1;
Query OK, 0 rows affected
SET pg_qualstats.track_pg_catalog = 1;
Query OK, 0 rows affected
SELECT count(*) from pg_class where relname = 'pg_qualstats';
1
SELECT * from pg_qualstats();
ERROR: pg_qualstats must be loaded via shared_preload_libraries
from log:
2021-07-27 13:06:05.556 EEST [25760] ERROR: 55000: pg_qualstats must be loaded via shared_preload_libraries
2021-07-27 13:06:05.556 EEST [25760] LOCATION: pg_qualstats_common, C:\Users<my_user_name>\source\repos\pg_qualstats\pg_qualstats.c:1988
2021-07-27 13:06:05.556 EEST [25760] STATEMENT: SELECT * from pg_qualstats();
from pg_qualstats.
I see. It seems that your first guess was correct: compilation works fine but somehow the loading code isn't executed. The _PG_init (and _PG_fini) functions are explicitly called after dynamically loading the shared library, so I'm assuming that a PGDLLEXPORT is also required there.
I pushed another commit to add all those missing annotations (331ee73). Does it solve all the remaining problems?
from pg_qualstats.
Thanks to @suprimex help we could fix all issues with Windows environment.
I just merged the commits on the master branch, which should now compile cleanly and work as intended on Windows!
from pg_qualstats.
Hi @gdonufrio
I spent some time setting up a build environment on Windows. Does this archivework for you?
pg_qualstats-2.0.3-pg12-x64.zip
It should be extracted in the root folder of your postgres 12 installation.
from pg_qualstats.
from pg_qualstats.
Great, thanks a lot! I also have an installer if you prefer, but github doesn't let me add it here. I temporarily added it to the 2.0.3 release at https://github.com/powa-team/pg_qualstats/releases/download/2.0.3/pg_qualstats-2.0.3-pg12-x64.exe
Let me know one you downloaded it so I can remove it from the release, as I'm not entirely sure that it's working as expected yet.
from pg_qualstats.
from pg_qualstats.
@rjuju Where can I find a Windows installer for 2.0.4?
from pg_qualstats.
@cowwoc sorry, I want to automate this but never found the time to work on that. I just attached the zip and installers for the 2.0.4.
from pg_qualstats.
Related Issues (20)
- pg_qualstats_indexes usage post 2.0 HOT 2
- Detect columns with dependencies and suggest to create extended statistics on it HOT 1
- [Doc] ALTER EXTENSION UPDATE fails HOT 4
- version 2.0.2 has no update path from version "1.0.7" and could not find function "pg_qualstats_2_0" in file HOT 2
- Support for Citus HOT 2
- PostgreSQL 14 support HOT 3
- pg_qualstats_example_query truncated return HOT 3
- pg_qualstats_example_query() and queries() don't fill in all the predicate values HOT 1
- different utf8const handling HOT 4
- cppcheck find bug HOT 2
- set-valued function called in context that cannot accept a set HOT 1
- multi node stat collection HOT 5
- Provide context for index advice HOT 4
- ERROR: there is no parameter $1 when i try execute the function. HOT 3
- pg_qualstats_index_advisor functionality HOT 14
- pg_qualstats_index_advisor index within JSON HOT 1
- PG15 binary for Windows HOT 2
- PG16 binary for Windows HOT 3
- Dereference after null HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pg_qualstats.