MapServer / MapServer-import

3 stars 2 forks source link

Empty Oracle environmental variables cause failure without error message #1846

Open tbonfort opened 12 years ago

tbonfort commented 12 years ago

Reporter: maris.gis@gmail.com Date: 2006/07/26 - 00:12

If Oracle environmental variables are undefined, then OCIErrorGet() does not return any error message thus last_oci_call_ms_error variable is empty and no error message is returned to user.

Empty last_oci_call_ms_error is returnet by TRY() (maporaclespatial.c:282) to msOracleSpatialLayerOpen() (maporaclespatial.c:1577).

Solution: check required environmental variables before trying to connet to Oracle database.

like:

*** maporaclespatial.c.orig Fri Apr 29 01:19:41 2005
--- maporaclespatial.c  Wed Jul 26 01:08:16 2006
***************
*** 1560,1565 ****
--- 1560,1594 ----
      }

      last_oci_call_ms_status = MS_SUCCESS;
+
+     if (getenv("ORACLE_HOME") == NULL)
+     {
+         msSetError( MS_ORACLESPATIALERR, "Missing ORACLE_HOME environmental
variable!", "msOracleSpatialLayerOpen()");
+
+         msOCICloseDataHandlers( dthand );
+         msOCIClearLayerInfo( layerinfo );
+
+         return MS_FAILURE;
+     }
+     if (getenv("ORACLE_BASE") == NULL)
+     {
+         msSetError( MS_ORACLESPATIALERR, "Missing ORACLE_BASE environmental
variable!", "msOracleSpatialLayerOpen()");
+
+         msOCICloseDataHandlers( dthand );
+         msOCIClearLayerInfo( layerinfo );
+
+         return MS_FAILURE;
+     }
+     if (getenv("ORACLE_SID") == NULL)
+     {
+         msSetError( MS_ORACLESPATIALERR, "Missing ORACLE_SID environmental
variable!", "msOracleSpatialLayerOpen()");
+
+         msOCICloseDataHandlers( dthand );
+         msOCIClearLayerInfo( layerinfo );
+
+         return MS_FAILURE;
+     }
+
      msSplitLogin( layer->connection, username, password, dblink );

      hand = (msOracleSpatialHandler *) msConnPoolRequest( layer );
tbonfort commented 12 years ago

Author: dmorissette Date: 2007/08/30 - 16:44 Fernando, were you planning to fix this one in 5.0? If not then please set milestone to 5.2.

tbonfort commented 12 years ago

Author: fsimon Date: 2007/08/30 - 17:08 Hi, Just for 5.2, I'm studding a better way to do this. I just have another bug (I will create the ticket today) to fix (it's easy and will commit this weekend).

Because the Oracle, by default, just need one environment, and I don't want to force anything. I believe that the best, is change the Oracle Spatial doc to add the settings (these environments and others tips about config).

Best regards.

tbonfort commented 12 years ago

Author: dmorissette Date: 2009/10/06 - 22:40 Fernando, can you please explain what you had in mind to reduce the usage to a single environment variable?

tbonfort commented 12 years ago

Author: aboudreault Date: 2009/12/16 - 19:36 I guess this patch is ok, will check try it.

tbonfort commented 12 years ago

Author: aboudreault Date: 2009/12/16 - 20:40 It seems that the OCIEnvCreate() function set the environnement variables if they are undefined. maris, what version were you using? My oracle client lib version is 11.1.[[BR]]

I've also tried to unset manually the variables to reproduce the bug, but that makes mapserver crashed. I guess without those variables, nothing would work.[[BR]]

Should we consider the fix to ensure that problem wont happen with older oracle client lib?

tbonfort commented 12 years ago

Author: aboudreault Date: 2009/12/16 - 20:48 I've successfully unset the variables immediately after the OCISetHandler call, which doesn't make mapserver crash, but everything seems to work fine and the oracle errors are reported properly.

tbonfort commented 12 years ago

Author: marisn Date: 2009/12/16 - 21:31 I can't check anything regarding this patch anymore, as I have changed laptops and distributions since last time I needed a Oracle DB. At that time I used some of Oracle 10g (that free limited version). Only issue where missing Oracle env settings for Apache and no error messages to indicate such situation. It took me few days till I got mapserver + Oracle running as mapserver was simply silently refusing to do any business with Oracle as mapserver had no idea where to look for Oracle and mapserver's oracle connection error reporting was relaying on Oracle provided error messages -> no Oracle - no error.

Everything else is written in patch description, still it's for 4.6 and I have no idea if something has changed since then.

tbonfort commented 12 years ago

Author: aboudreault Date: 2009/12/21 - 16:11 I haven't been able to reproduce the problem with a recent MapServer. If anyone is able to reproduce that bug, please reopen the ticket.