5

I try to build plpgsql_check extension by @PavelStehule (Erwin Brandstetter recommended it to me in this answer) on Windows XP 32bit with Visual Studio 2010 (I used this article as a manual). However, I got following errors:

error LNK2001: unresolved external symbol _exec_get_datum_type
error LNK2001: unresolved external symbol _plpgsql_compile
error LNK2001: unresolved external symbol _plpgsql_build_datatype
error LNK2001: unresolved external symbol _plpgsql_stmt_typename
error LNK2001: unresolved external symbol _plpgsql_parser_setup

In addition, there are two IntelliSense errors: expected a ')' in plpgsql.h (lines 923 and 953 - both in datum-related functions) - I expect these to be false alerts (if they are important, how to solve them?).

After some googling I found that someone had a similar problem on OS X. The problem was that plpgsql.so either wasn't linked or didn't work. I have no plpgsql.so on my computer, but I have plpgsql.dll which should correspond to it. So I linked it and the error changed:

error LNK1107: invalid or corrupt file: cannot read at 0x2A8

This dynamic library is part of the PostgreSQL distribution, so it shouldn't be corrupt. However, I'm afraid that what Pavel wrote in the linked discussion applies here:

It needs link against plpgsql.so. I didn't test it against clang - I remember a talk with Tom Lane, he was surprised so this code works and probably on some platforms can be unavailable.

...

Nobody expected so plpgsql will be used from other extensions - and environment is not prepared for it :(

The worst case would be that plpgsql checker extension is simply not available under Windows, because it is too low-mana area for such a mighty magic. :-) If I just need a different approach, please point me to it.

  • 1
    I don't know about the last part of the question, but anyway you don't link with a .DLL at build time, that's the root cause of the error. You want the corresponding .LIB instead. See for example stackoverflow.com/questions/24222423 but knowing that plpgsql.lib does not ship with entreprisedb pre-compiled binaries. – Daniel Vérité Jun 20 '14 at 16:15
  • @DanielVérité: I examined all finds of "plpgsql.lib" Google search with no luck - it's not in my binaries and I don't know where else should I get it. So how to make sure the library (in static or dynamic version) gets included in the project anyhow? The only referrence of the problem in the first part of my question suggests that it's caused by missing, not included or somehow incomplete/incompatible plpgsql library, so without the library I'm stuck. – Pavel V. Jun 21 '14 at 11:05
  • It looks like you'd have to build it yourself from the source code. – Daniel Vérité Jun 22 '14 at 16:11
1

You can find Adam Bartoszewicz's instructions here on Google Groups (also published on Pavel Stehule's blog):

  1. Download and install PostgreSQL 9.3.4 for Win32 from http://www.enterprisedb.com
  2. Download and install Microsoft Visual C++ 2010 Express
  3. Lern tutorial http://blog.2ndquadrant.com/compiling-postgresql-extensions-visual-studio-windows
  4. The plpgsql_check depends on plpgsql and we need to add plpgsql.lib to the library list. Unfortunately PostgreSQL 9.4.3 does not contain this library.
  5. Create a plpgsql.lib from plpgsql.dll as described in http://adrianhenke.wordpress.com/2008/12/05/create-lib-file-from-dll
  6. Change plpgsql_check.c file, add PGDLLEXPORT line before evry extension function, as described in http://blog.2ndquadrant.com/compiling-postgresql-extensions-visual-studio-windows
    ...
    PGDLLEXPORT Datum plpgsql_check_function_tb(PG_FUNCTION_ARGS); PGDLLEXPORT Datum plpgsql_check_function(PG_FUNCTION_ARGS);
    ...
    PGDLLEXPORT Datum plpgsql_check_function(PG_FUNCTION_ARGS) { Oid funcoid = PG_GETARG_OID(0);
    ...
    PGDLLEXPORT Datum plpgsql_check_function_tb(PG_FUNCTION_ARGS) { Oid funcoid = PG_GETARG_OID(0);
    ...
  7. Build plpgsql_check.dll
  8. Install plugin
    • copy plpgsql_check.dll to PostgreSQL\9.3\lib
    • copy plpgsql_check.control and plpgsql_check--0.8.sql to PostgreSQL\9.3\share\extension

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.