>> I'll try and get a patch out in the next day or two (unless I hit >> any unexpected snags). >> >> I've named the new function "ora_cygwin_set_env" - is that >> suitable? > > Perfect. Thanks Andy.
Patch attached. I've also added a README.cygwin.txt with the couple of extra bits of information that are needed when building under Cygwin; native vs. Cygwin paths, and the dependency on the w32api package. All tests now successful; test results for r2429 (i.e. same revision as RC5) plus patch applied, at the following address: http://www.andyh.co.uk/temp/DBD-Oracle/r2429_plus_cygwin_patch/ -- Andy Hassall :: [EMAIL PROTECTED] :: http://www.andyh.co.uk http://www.andyhsoftware.co.uk/space :: disk and FTP usage analysis tool
Index: README.cygwin.txt =================================================================== --- README.cygwin.txt (revision 0) +++ README.cygwin.txt (revision 0) @@ -0,0 +1,20 @@ +When building under Cygwin, ensure that your ORACLE_HOME environment +variable is set to a native Windows path, but is included in the PATH +environment variable using the Cygwin format (using "/cygdrive/"). + +You can convert from Windows paths to Cygwin paths using the cygpath +command. For example: + +export ORACLE_HOME='g:\oracle\product\10.2.0\db_1' +export PATH=`cygpath -u $ORACLE_HOME`/bin:$PATH + +If building using Oracle Instant Client, omit "/bin". + +You will need the "w32api" Cygwin package installed, as DBD::Oracle requires +headers from that package to address an issue where environment +variable changes during the test suite are not passed to the Oracle DLL. +This can be installed using the Cygwin installer, and selecting +"w32api" under the "Libs" section. + +For more information on the issue see: +http://groups.google.co.uk/group/perl.dbi.dev/msg/a369d927fae277b2 Index: dbdimp.c =================================================================== --- dbdimp.c (revision 2429) +++ dbdimp.c (working copy) @@ -12,6 +12,11 @@ #define strcasecmp strcmpi #endif +#ifdef __CYGWIN32__ +#include "w32api/windows.h" +#include "w32api/winbase.h" +#endif /* __CYGWIN32__ */ + #include "Oracle.h" #if defined(CAN_USE_PRO_C) @@ -95,7 +100,35 @@ return buf; } +#ifdef __CYGWIN32__ +/* Under Cygwin there are issues with setting environment variables + * at runtime such that Windows-native libraries loaded by a Cygwin + * process can see those changes. + * + * Cygwin maintains its own cache of environment variables, and also + * only writes to the Windows environment using the "_putenv" win32 + * call. This call writes to a Windows C runtime cache, rather than + * the true process environment block. + * + * In order to change environment variables so that the Oracle client + * DLL can see the change, the win32 function SetEnvironmentVariable + * must be called. This function gives an interface to that API. + * + * It is only available when building under Cygwin, and is used by + * the testsuite. + * + * Whilst it could be called by end users, it should be used with + * caution, as it bypasses the environment variable conversions that + * Cygwin typically performs. + */ void +ora_cygwin_set_env(char *name, char *value) +{ + SetEnvironmentVariable(name, value); +} +#endif /* __CYGWIN32__ */ + +void dbd_init(dbistate_t *dbistate) { DBIS = dbistate; Index: Oracle.pm =================================================================== --- Oracle.pm (revision 2429) +++ Oracle.pm (working copy) @@ -25,7 +25,8 @@ ) ], ora_session_modes => [ qw( ORA_SYSDBA ORA_SYSOPER ) ], ); - @EXPORT_OK = qw(ORA_OCI SQLCS_IMPLICIT SQLCS_NCHAR ora_env_var); + @EXPORT_OK = qw(ORA_OCI SQLCS_IMPLICIT SQLCS_NCHAR ora_env_var ora_cygwin_set_env); + #unshift @EXPORT_OK, 'ora_cygwin_set_env' if $^O eq 'cygwin'; Exporter::export_ok_tags(qw(ora_types ora_session_modes)); my $Revision = substr(q$Revision: 1.103 $, 10); Index: dbdimp.h =================================================================== --- dbdimp.h (revision 2429) +++ dbdimp.h (working copy) @@ -263,6 +263,9 @@ char *ora_sql_error _((imp_sth_t *imp_sth, char *msg)); char *ora_env_var(char *name, char *buf, unsigned long size); +#ifdef __CYGWIN32__ +void ora_cygwin_set_env(char *name, char *value); +#endif /* __CYGWIN32__ */ sb4 dbd_phs_in _((dvoid *octxp, OCIBind *bindp, ub4 iter, ub4 index, dvoid **bufpp, ub4 *alenp, ub1 *piecep, dvoid **indpp)); Index: Oracle.xs =================================================================== --- Oracle.xs (revision 2429) +++ Oracle.xs (working copy) @@ -56,7 +56,17 @@ sv_setpv(sv, p); ST(0) = sv; +#ifdef __CYGWIN32__ +void +ora_cygwin_set_env(name, value) + char * name + char * value + CODE: + ora_cygwin_set_env(name, value); +#endif /* __CYGWIN32__ */ + + INCLUDE: Oracle.xsi MODULE = DBD::Oracle PACKAGE = DBD::Oracle::st Index: t/nchar_test_lib.pl =================================================================== --- t/nchar_test_lib.pl (revision 2429) +++ t/nchar_test_lib.pl (working copy) @@ -420,6 +420,10 @@ } else { undef $ENV{NLS_NCHAR}; # XXX windows? (perhaps $ENV{NLS_NCHAR}=""?) } + # Special treatment for environment variables under Cygwin - + # see comments in dbdimp.c for details. + DBD::Oracle::ora_cygwin_set_env('NLS_NCHAR', $ENV{NLS_NCHAR}||'') + if $^O eq 'cygwin'; print defined ora_env_var("NLS_NCHAR") ? # defined? "set \$ENV{NLS_NCHAR}=$cset\n" : "set \$ENV{NLS_LANG}=undef\n" # XXX ? @@ -436,6 +440,10 @@ $ENV{NLS_LANG} = ""; # not the same as set_nls_nchar() above which uses undef print "set \$ENV{NLS_LANG}=''\n" if ( $verbose ); } + # Special treatment for environment variables under Cygwin - + # see comments in dbdimp.c for details. + DBD::Oracle::ora_cygwin_set_env('NLS_LANG', $ENV{NLS_LANG}||'') + if $^O eq 'cygwin'; } sub byte_string {
