Code Monkey home page Code Monkey logo

Comments (10)

shawnlaffan avatar shawnlaffan commented on August 21, 2024 1

Strawberry Perl provides a reduced set of postgres files, and this does not include initdb, pg_ctl, pg_config and a few others.
https://github.com/StrawberryPerl/build-extlibs/blob/d22291c1a0de960466d1983cb0af88bff8c974a7/build.sh#L819-L844

The tests started to fail some time after DBD::Pg 3.8.0, which is the version distributed with recent Strawberry Perls since the tests pass.

I've run some full postgres builds but am getting DBD::Pg failures related to dict_snowball - it seems the $libdir config value is not being populated or parsed correctly. I'll post more details here or in a new issue when I can provide reproduction steps and files but some hopefully useful info is below for now. FWIW, dict_snowball.dll lives in PKGLIBDIR.

FATAL:  could not access file "$libdir/dict_snowball": No such file or directory
> pg_config --libdir
C:/perls/STRAWB~1.1-R/c/lib
> pg_config --pkglibdir
C:/perls/STRAWB~1.1-R/c/lib/POSTGR~1

from dbdpg.

esabol avatar esabol commented on August 21, 2024

I know it's been 3 months, and you've probably already found a solution. I think you need to configure your PATH. You need to install the PostgreSQL tools and get them usable from the command line first. This StackOverflow seems to cover how to do this:

https://stackoverflow.com/questions/30401460/postgres-psql-not-recognized-as-an-internal-or-external-command

from dbdpg.

Brian2099 avatar Brian2099 commented on August 21, 2024

esabol,

Thank you for responding. FYI, none of my development computers have ever had Postgres installed. All CPAN modules have installed fine since 2015 until the most recent update 90 days ago. I did confirm that the %PATH% does not contain the C:\Program Files\PostgreSQL\ folders. However, that was expected because I've never installed PG on my development computers. I installed Strawberry Perl on my development computers and then programmatically connect at run-time to the Posgres database server.

The temporary (hopefully) workaround was to install the module with the -T option (Do not test modules. Simply install them.). I only used this override when installing the DBD::Pg module.

I'm still wondering why the installs worked for 7 years and all of a sudden abend with an error. I really don't think installing Postgres on my development computers is the answer to the above issue.

Many thanks.

from dbdpg.

esabol avatar esabol commented on August 21, 2024

I'm still wondering why the installs worked for 7 years and all of a sudden abend with an error. I really don't think installing Postgres on my development computers is the answer to the above issue.

Well, it wasn't clear from your initial message that that's what your issue was about. I thought you just wanted a solution to the error, and I believe installing PostgreSQL would solve the problem you encountered with running these tests.

I'm surprised to learn it was ever possible to install DBD::Pg without installing PostgreSQL. I could have sworn you needed at least some PostgreSQL library (DLL on Windows) and some PostgreSQL C headers to compile the DBD::Pg source code, but perhaps I'm mistaken. I've only ever compiled, tested, and installed DBD::Pg on computers that also have PostgreSQL installed.

from dbdpg.

PhilterPaper avatar PhilterPaper commented on August 21, 2024

I may be experiencing a very similar problem to the OP's. It's Windows 10 with Strawberry Perl 5.24, 5.26, and 5.32. I don't believe that PostgreSQL is installed on my PC. All I'm interested in is avoiding this error message (and the upgrade failure) when attempting to upgrade my installed packages (DBD::Pg comes preinstalled with Strawberry). I do have a wrapper around the cpan upgrade process to avoid trying to update DBD::Pg, but for the benefit of folks who haven't rolled such a tool, it would be good to be able to run a general "upgrade [all]" and not have to worry about it dying in the middle of multiple upgrades from some package like DBD::Pg.

This would probably involve changes to CPAN so that its tool could query the installation state of a subsystem (such as PostgreSQL) and what version it is, before deciding that the DBD::Pg package needs to be upgraded. In my case, it would see that PostgreSQL isn't even installed, and so wouldn't even try to upgrade DBD::Pg. I reported something similar against DBD::Oracle, where the client is too old to bother updating the package, and B, which only matches a given Perl level.

from dbdpg.

shawnlaffan avatar shawnlaffan commented on August 21, 2024

I've now run a world-bin build of postgresql using the Strawberry perl build system.

The set of packed files are at https://github.com/StrawberryPerl/build-extlibs/releases/download/gcc13.2_ucrt_posix/64bit_postgresql-16.2-bin_20240613_world_bin.zip . Not all are packed so some might still be needed.

This build uses the compiler setup used for SP 5.40-RC1. That SP release can be downloaded from https://github.com/StrawberryPerl/Perl-Dist-Strawberry/releases/tag/dev_5.40.0_RC1_UCRT

I can get further than before but now hit issues with database creation in t\01connect.t:

# DBD::Pg                     Version 3.18.0
# Perl                        Version 5.40.0
# OS                          MSWin32
# PostgreSQL (compiled)       ?
# PostgreSQL (target)         ?
# PostgreSQL (reported)       ?
# Default port                ?
# DBI_DSN                     ?

# DBI_USER                    <not set>
# Test schema                 dbd_pg_testschema
# Adjusted:                   initdb
# Error was: Previous failure (Could not startup new database (pg_ctl -o '-k C:/perls/dbdpg_exp/DBD-Pg-3.18.0/dbdpg_test_database/data/socket' -l C:/perls/dbdpg_exp/DBD-Pg-3.18.0/dbdpg_test_database/dbdpg_test.logfile -D C:/perls/dbdpg_exp/DBD-Pg-3.18.0/dbdpg_test_database/data start) () ())
Bailout called.  Further testing stopped:  Cannot continue: connection failed
Bail out!  Cannot continue: connection failed
skipped: Connection to database failed, cannot continue testing

The single quotes around the -k argument look suspicious to me. The Cmd shell prefers double quotes. Changing them and running from the Cmd prompt does not change the result, though.

To reproduce:

  1. Install SP 5.40-RC1 portable somewhere on your system. Use a short path as otherwise the test db names are too long under cpanm.
  2. Copy the c dir contents from the zip file into the Strawberry Perl c dir, overwriting as needed.
  3. Download and build the DBD::Pg distribution. I initially downloaded using cpanm --look but then copied the contents to a shorter path.
  4. Run the tests.

The log file contents are:

2024-06-13 15:02:33.664 AEST [32956] LOG:  starting PostgreSQL 16.2 on x86_64-w64-mingw32, compiled by x86_64-w64-mingw32-gcc.exe (MinGW-W64 x86_64-ucrt-posix-seh, built by Brecht Sanders, r8) 13.2.0, 64-bit
2024-06-13 15:02:33.667 AEST [32956] LOG:  listening on IPv4 address "127.0.0.1", port 5440
2024-06-13 15:02:33.670 AEST [32956] FATAL:  could not create lock file "C:/perls/dbdpg_exp/DBD-Pg-3.18.0/dbdpg_test_database/data/socket/.s.PGSQL.5440.lock": No such file or directory
2024-06-13 15:02:33.671 AEST [32956] LOG:  database system is shut down
2024-06-13 15:03:21.300 AEST [27136] LOG:  starting PostgreSQL 16.2 on x86_64-w64-mingw32, compiled by x86_64-w64-mingw32-gcc.exe (MinGW-W64 x86_64-ucrt-posix-seh, built by Brecht Sanders, r8) 13.2.0, 64-bit
2024-06-13 15:03:21.303 AEST [27136] LOG:  listening on IPv4 address "127.0.0.1", port 5440
2024-06-13 15:03:21.306 AEST [27136] FATAL:  could not create lock file "C:/perls/dbdpg_exp/DBD-Pg-3.18.0/dbdpg_test_database/data/socket/.s.PGSQL.5440.lock": No such file or directory
2024-06-13 15:03:21.307 AEST [27136] LOG:  database system is shut down
2024-06-13 15:03:45.471 AEST [22240] LOG:  starting PostgreSQL 16.2 on x86_64-w64-mingw32, compiled by x86_64-w64-mingw32-gcc.exe (MinGW-W64 x86_64-ucrt-posix-seh, built by Brecht Sanders, r8) 13.2.0, 64-bit
2024-06-13 15:03:45.473 AEST [22240] LOG:  listening on IPv4 address "127.0.0.1", port 5440
2024-06-13 15:03:45.476 AEST [22240] FATAL:  could not create lock file "C:/perls/dbdpg_exp/DBD-Pg-3.18.0/dbdpg_test_database/data/socket/.s.PGSQL.5440.lock": No such file or directory
2024-06-13 15:03:45.478 AEST [22240] LOG:  database system is shut down

from dbdpg.

esabol avatar esabol commented on August 21, 2024

@shawnlaffan wrote:

The single quotes around the -k argument look suspicious to me. The Cmd shell prefers double quotes. Changing them and running from the Cmd prompt does not change the result, though.

First off, thank you for supporting DBD::Pg in Strawberry Perl!

I suspect your problem is in t/dbdpg_test_setup.pl around here:

dbdpg/t/dbdpg_test_setup.pl

Lines 565 to 576 in f3d3c92

if ($^O !~ /Win32/) {
my $sockdir = "$testdir/data/socket";
if (! -e $sockdir) {
mkdir $sockdir;
if ($su) {
if (! chown $uid, -1, $sockdir) {
warn "chown of $sockdir failed!\n";
}
}
}
}
my $COM = qq{$pg_ctl -o '-k $testdir/data/socket' -l $testdir/dbdpg_test.logfile -D $testdir/data start};

The if ($^O !~ /Win32/) { test implies that a socket directory should not be specified on Windows.

What happens if you drop the -o '-k ...' entirely and execute pg_ctl -l C:/perls/dbdpg_exp/DBD-Pg-3.18.0/dbdpg_test_database/dbdpg_test.logfile -D C:/perls/dbdpg_exp/DBD-Pg-3.18.0/dbdpg_test_database/data start?

In other words, change line 576 to my $COM = qq{$pg_ctl -l $testdir/dbdpg_test.logfile -D $testdir/data start};.

Alternatively, you might also try changing line 565 to if (1) { to force the setup of the socket directory on Win32. My googling shows that Windows support for sockets was added to PostgreSQL many years ago, so maybe it would work if the socket directory was setup properly (i.e. created)?

from dbdpg.

shawnlaffan avatar shawnlaffan commented on August 21, 2024

Dropping the socket component seems to work from the cmd prompt:

> pg_ctl -l C:/perls/dbdpg_exp/DBD-Pg-3.18.0/dbdpg_test_database/dbdpg_test.logfile -D C:/perls/dbdpg_exp/DBD-Pg-3.18.0/dbdpg_test_database/data start
waiting for server to start.... done
server started

I also changed the single quotes to double quotes in both places they are used (L191 and L576) but then discovered pg_resetwal.exe needs to be packed. I'm rebuilding and repacking everything at the moment.

from dbdpg.

shawnlaffan avatar shawnlaffan commented on August 21, 2024

We have progress now all the files are packed. https://github.com/StrawberryPerl/build-extlibs/releases/download/gcc13.2_ucrt_posix/64bit_postgresql-16.2-bin_20240613_dll_suffix_wf.zip

Removing the socket command seems to result in a hang so I left it in, but double quoted.

t/00_signature.t ....... skipped: Set the environment variable TEST_SIGNATURE to enable this test
t/00basic.t ............ ok
t/01connect.t .......... Please wait, creating new database (version 16.2) for testing
t/01connect.t .......... 29/30 #
# DBI                         Version 1.643
# DBD::Pg                     Version 3.18.0
# Perl                        Version 5.40.0
# OS                          MSWin32
# PostgreSQL (compiled)       160002
# PostgreSQL (target)         160002
# PostgreSQL (reported)       PostgreSQL 16.2 on x86_64-w64-mingw32, compiled by x86_64-w64-mingw32-gcc.exe (MinGW-W64 x86_64-ucrt-posix-seh, built by Brecht Sanders, r8) 13.2.0, 64-bit
# Default port                5432
# DBI_DSN                     dbi:Pg:db="postgres";port=5440;host=localhost
# DBI_USER                    z9803549
# Test schema                 dbd_pg_testschema
# LANG                        C
# Adjusted:                   initdb
t/01connect.t .......... ok
t/01constants.t ........ ok
t/02attribs.t .......... 245/293 DBD::Pg::db commit failed: no connection to the server at t/02attribs.t line 1449.
# Looks like your test exited with 255 just after 246.
t/02attribs.t .......... Dubious, test returned 255 (wstat 65280, 0xff00)
Failed 47/293 subtests
        (less 1 skipped subtest: 245 okay)
t/03dbmethod.t ......... 1/?
t/03dbmethod.t ......... 5/? #   Failed test 'DB handle method "last_insert_id" fails when called in a failed transaction'
#   at t/03dbmethod.t line 92.
#          got: '08000'
#     expected: '25P02'
DBD::Pg::db rollback failed: no connection to the server at t/03dbmethod.t line 95.
# Tests were run but no plan was declared and done_testing() was not seen.
# Looks like your test exited with 255 just after 5.
t/03dbmethod.t ......... Dubious, test returned 255 (wstat 65280, 0xff00)
Failed 1/5 subtests
t/03smethod.t .......... ok
t/04misc.t ............. 108/109 Error removing C:\perls\dbdpg_exp\DBD-Pg-3.18.0\dbdpg_test_DqQCXB.tst at C:/perls/strawberry-perl-5.40.0.1-RC1-64bit-portable/perl/lib/File/Temp.pm line 899.
t/04misc.t ............. ok
t/06bytea.t ............ ok
t/07copy.t ............. ok
t/08async.t ............ ok
t/09arrays.t ........... ok
t/10_pg_error_field.t .. ok
t/12placeholders.t ..... ok
t/20savepoints.t ....... ok
t/30unicode.t .......... ok
t/99cleanup.t .......... ok

Test Summary Report
-------------------
t/02attribs.t        (Wstat: 65280 (exited 255) Tests: 246 Failed: 0)
  Non-zero exit status: 255
  Parse errors: Bad plan.  You planned 293 tests but ran 246.
t/03dbmethod.t       (Wstat: 65280 (exited 255) Tests: 5 Failed: 1)
  Failed test:  5
  Non-zero exit status: 255
  Parse errors: No plan found in TAP output
Files=17, Tests=2345, 158 wallclock secs ( 0.11 usr +  0.01 sys =  0.12 CPU)
Result: FAIL
Failed 2/17 test programs. 1/2345 subtests failed.
gmake: *** [makefile:989: test_dynamic] Error 255

from dbdpg.

shawnlaffan avatar shawnlaffan commented on August 21, 2024

Although now it is failing again so I am not sure what caused the previous pass.

> prove -vb
t/00_signature.t ....... skipped: Set the environment variable TEST_SIGNATURE to enable this test
t/00basic.t ............ ok
t/01connect.t .......... ----
#
# DBI                         Version 1.643
# DBD::Pg                     Version 3.18.0
# Perl                        Version 5.40.0
# OS                          MSWin32
# PostgreSQL (compiled)       ?
# PostgreSQL (target)         ?
# PostgreSQL (reported)       ?
# Default port                ?
# DBI_DSN                     ?
# DBI_USER                    <not set>
# Test schema                 dbd_pg_testschema
# Adjusted:                   initdb
# Error was: connection to server at "localhost" (::1), port 5440 failed: Connection refused (0x0000274D/10061)
Bailout called.  Further testing stopped:  Cannot continue: connection failed
t/01connect.t .......... skipped: Connection to database failed, cannot continue testing
Can't use an undefined value as a subroutine reference at C:/perls/strawberry-perl-5.40.0.1-RC1-64bit-portable/perl/lib/TAP/Harness.pm line 612.
gmake: *** [makefile:989: test_dynamic] Error 255

Edit:
And some log details.

2024-06-13 19:39:04.611 AEST [8680] LOG:  starting PostgreSQL 16.2 on x86_64-w64-mingw32, compiled by x86_64-w64-mingw32-gcc.exe (MinGW-W64 x86_64-ucrt-posix-seh, built by Brecht Sanders, r8) 13.2.0, 64-bit
2024-06-13 19:39:04.614 AEST [8680] LOG:  listening on IPv4 address "127.0.0.1", port 5440
2024-06-13 19:39:04.617 AEST [8680] FATAL:  could not create lock file "C:/perls/dbdpg_exp/dbdpg/dbdpg_test_database/data/socket/.s.PGSQL.5440.lock": No such file or directory
2024-06-13 19:39:04.618 AEST [8680] LOG:  database system is shut down

from dbdpg.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.