Opened 18 years ago

Closed 14 years ago

#1846 closed defect (invalid)

Empty Oracle environmental variables cause failure without error message

Reported by: maris.gis@… Owned by: aboudreault
Priority: high Milestone: 6.0 release
Component: Input - Native Oracle Spatial Support Version: 4.6
Severity: normal Keywords:
Cc: fsimon, dmorissette

Description (last modified by dmorissette)

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 );

Change History (11)

comment:1 by dmorissette, 17 years ago

Description: modified (diff)
Milestone: 5.0 release

comment:2 by dmorissette, 17 years ago

Fernando, were you planning to fix this one in 5.0? If not then please set milestone to 5.2.

comment:3 by fsimon, 17 years ago

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.

comment:4 by fsimon, 17 years ago

Milestone: 5.0 release5.2 release

comment:5 by dmorissette, 15 years ago

Cc: fsimon dmorissette added
Milestone: 5.2.1 release5.6 release
Owner: changed from fsimon@… to aboudreault

Fernando, can you please explain what you had in mind to reduce the usage to a single environment variable?

comment:6 by dmorissette, 14 years ago

Milestone: 5.6 release6.0 release

comment:7 by aboudreault, 14 years ago

I guess this patch is ok, will check try it.

comment:8 by aboudreault, 14 years ago

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.

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.
Should we consider the fix to ensure that problem wont happen with older oracle client lib?

comment:9 by aboudreault, 14 years ago

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.

comment:10 by marisn, 14 years ago

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.

comment:11 by aboudreault, 14 years ago

Resolution: invalid
Status: newclosed

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.

Note: See TracTickets for help on using tickets.