php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #40542 "ORA-02248: invalid option for ALTER SESSION" on OCIPLogon
Submitted: 2007-02-19 13:06 UTC Modified: 2007-07-11 12:25 UTC
Votes:2
Avg. Score:4.0 ± 1.0
Reproduced:2 of 2 (100.0%)
Same Version:2 (100.0%)
Same OS:2 (100.0%)
From: marvin at chag dot net Assigned:
Status: Not a bug Package: OCI8 related
PHP Version: 5.2.1 OS: Linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: marvin at chag dot net
New email:
PHP Version: OS:

 

 [2007-02-19 13:06 UTC] marvin at chag dot net
Description:
------------
Problem is, that more or less often (not always) the call to OCIPLogon (or OCILogon) results into an Oracle error message "ORA-02248: invalid option for ALTER SESSION" and the connection to the database is not made.

Everything worked fine up to PHP 5.1.1 but all other versions starting from 5.1.2 up to 5.2.1 are showing this "ALTER SESSION" behavior.

The Oracle related environment for Apache startup is:

export ORACLE_SID=db
export ORACLE_TERM=vt220
export ORACLE_BASE=/opt/oracle
export ORACLE_HOME=$ORACLE_BASE/product/8.1.7
export CLASSPATH=$ORACLE_HOME/jdbc/lib/classes111.zip
export LD_LIBRARY_PATH=$ORACLE_HOME/lib
export TNS_ADMIN=$ORACLE_HOME/network/admin
export PATH=$PATH:$ORACLE_HOME/bin
export ORA_NLS33=$ORACLE_HOME/ocommon/nls/admin/data
export NLS_LANG=GERMAN_GERMANY.WE8ISO8859P1


Webserver: 
Linux 2.4.21-303-smp4G
Apache 1.3.37 + SSL Patch 1.57
PHP 5.2.1 compiled statically into Apache
Oracle Client 8.1.7.0.0

Database:
Oracle from version 8.1.6 to 8.1.7.0.4 running on different Linux and Windows

PHP configure line:
./configure  --with-ldap --enable-dbase --with-mysql --with-oci8 --with-oracle --with-gd --with-jpeg-dir --with-png-dir --with-tiff-dir --with-xpm-dir --enable-calendar --enable-sigchild --with-zlib --with-bz2 --enable-ftp --enable-sockets --with-apache=../apache_1.3.37 --with-gettext --enable-bcmath --with-mcrypt --with-mhash --with-ttf=/usr/include/freetype --with-gmp --enable-trans-sid --with-freetype-dir=/usr/include/freetype2 --enable-gd-native-ttf --with-libxml-dir --enable-soap


Reproduce code:
---------------
<?
OCIInternalDebug(1);

for ($i = 1; $i <= 10; $i++)
{
        $con = @OCIPLogon("<user>","<pass>","<db>");
        if ($con == true)
                break;
        else
        {
                echo var_dump(OCIError());
                break;
        }
};
?>

Expected result:
----------------
OCIPLogon() should give a valid DB connection.

Actual result:
--------------
When the connect is not working, DEBUG shows the following:

OCI8 DEBUG: OCIEnvCreate at (/php-5.2.1/ext/oci8/oci8.c:1216)
OCI8 DEBUG: OCIHandleAlloc at (/php-5.2.1/ext/oci8/oci8.c:1239)
OCI8 DEBUG: OCIServerAttach at (/php-5.2.1/ext/oci8/oci8.c:1248)
OCI8 DEBUG: OCIHandleAlloc at (/php-5.2.1/ext/oci8/oci8.c:1258)
OCI8 DEBUG: OCIHandleAlloc at (/php-5.2.1/ext/oci8/oci8.c:1267)
OCI8 DEBUG: OCIHandleAlloc at (/php-5.2.1/ext/oci8/oci8.c:1276)
OCI8 DEBUG: OCIAttrSet at (/php-5.2.1/ext/oci8/oci8.c:1286)
OCI8 DEBUG: OCIAttrSet at (/php-5.2.1/ext/oci8/oci8.c:1297)
OCI8 DEBUG: OCIAttrSet at (/php-5.2.1/ext/oci8/oci8.c:1307)
OCI8 DEBUG: OCIAttrSet at (/php-5.2.1/ext/oci8/oci8.c:1316)
OCI8 DEBUG: OCISessionBegin at (/php-5.2.1/ext/oci8/oci8.c:1350)
OCI8 DEBUG: OCIErrorGet at (/php-5.2.1/ext/oci8/oci8.c:922)
OCI8 DEBUG: OCIHandleFree at (/php-5.2.1/ext/oci8/oci8.c:1514)
OCI8 DEBUG: OCIServerDetach at (/php-5.2.1/ext/oci8/oci8.c:1518)
OCI8 DEBUG: OCIHandleFree at (/php-5.2.1/ext/oci8/oci8.c:1522)
OCI8 DEBUG: OCIHandleFree at (/php-5.2.1/ext/oci8/oci8.c:1526)
OCI8 DEBUG: OCIHandleFree at (/php-5.2.1/ext/oci8/oci8.c:1530)
OCI8 DEBUG: OCIHandleFree at (/php-5.2.1/ext/oci8/oci8.c:1534)

DEBUG XXX
OCI8 DEBUG: OCIErrorGet at (/php-5.2.1/ext/oci8/oci8.c:922) array(4) { ["code"]=> int(604) ["message"]=> string(94) "ORA-00604: error occurred at recursive SQL level 1 ORA-02248: invalid option for ALTER SESSION" ["offset"]=> int(0) ["sqltext"]=> string(0) "" }

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-02-19 13:14 UTC] tony2001@php.net
Not PHP problem.
I'd also recommend upgrading the DB, 8i is not supported by Oracle for a long time.
 [2007-02-19 13:37 UTC] marvin at chag dot net
Hi Tony2001, 

The only change to our systems is switching between PHP <= 5.1.1 and PHP >= 5.1.2 (today it was 5.2.1). 

The result is: for PHP <= 5.1.1 the database connections are working fine and for PHP >= 5.1.2 they are not.

So I kindly ask, wether you please can tell me what else should cause this problem, if not PHP / OCI8?
 
Sadly upgrading this databases in this special configuration is no option. PHP documentation http://de.php.net/manual/en/ref.oci8.php states that OCI8 can be used for Oracle 7 and 8 databases, though.
 [2007-02-20 07:52 UTC] marvin at chag dot net
open again
 [2007-02-20 10:03 UTC] tony2001@php.net
>So I kindly ask, wether you please can tell me what else
>should cause this problem, if not PHP / OCI8?

Sure. I'd look in Oracle or in the client library.
With such an old version it's no wonder there are problems.

Though, we can try do it this way:
Please install 5.1.1 and make sure it does work fine.
Then I'll need an unprivileged ssh account on your machine to install 5.2.1, reproduce the problem and investigate it.
I'll also need Oracle connection details.
 [2007-02-22 07:13 UTC] marvin at chag dot net
Hi Tony2001, 
Thank you very much for the kind offer. Unfortunately our companies security policies does not allow such an approach. But I will happily investigate the problem according to your requirements and send you the debugging information & results you need to isolate the problematic lines.
 [2007-02-23 07:31 UTC] jmgonet at iware dot ch
I have just the same problem, executing a PHP script as a Windows' batch. I've set the NLS_LANG environment variable to 'NLS_LANG=FRENCH_SWITZERLAND.WE8PC850'.

I'm using Oracle 10 light client.

I've found in this (http://dbforums.com/t927204.html) and other forums, a possible explanation:

'NLS_LANG cannot be changed by alter session, NLS_LANGUAGE and NLS_TERRITORY can.'
 [2007-02-23 08:43 UTC] jmgonet at iware dot ch
I've found the following workaround for that problem:

- Instead of setting the NLS_LANG environment variable, you can specify the charset while establishing the connection:

$conn=oci_connect("USER","PASSWORD","SERVER","CHARSET");

Where charset should be the one used by PHP client (not the one used by the Oracle server). In the case of a windows system, it is "WE8MSWIN1252" (In my PHP server, this code is specified in the NLS_LANG registry key, but oci_connect doesn't take it as default value). It is "WE8MSWIN1252" even if the PHP is executed as a script, from the command line.

The CHARSET for a linux/unix system may be "WE8ISO8851P1", or at least it seems to be usual in Europe.
 [2007-02-23 09:09 UTC] marvin at chag dot net
I tried the workaround jmgonet kindly rovided and removed all NLS_LANG setting from environment and startup scripts of the Apache server. The problem persists in exactly the same way as before. Adding the charset to the OCILogon did not help either. So maybe another env. variable tries to "alter session"?
 [2007-02-23 16:27 UTC] tony2001@php.net
>So maybe another env. variable tries to "alter session"?
I doubt env variables might "alter session" and even if they do, it's not PHP problem.
Changing the status to suspended - I'm unable to reproduce it and I believe it's something wrong with your system or the client lib.
 [2007-03-02 20:56 UTC] christopher dot jones at oracle dot com
jmgonet, the "lite" version of Oracle Instant Client has reduced
language and character set support.  One counter example is:

  [cjones@localhost w]$ export NLS_LANG=_SWITZERLAND.AL32UTF8
  [cjones@localhost w]$ ~/phpsrc/php5/sapi/cli/php t1.php

  Warning: ociplogon(): ORA-00604: error occurred at recursive SQL level 1
  ORA-02248: invalid option for ALTER SESSION in t1.php on line 30
  ORA-00604: error occurred at recursive SQL level 1
  ORA-02248: invalid option for ALTER SESSION[cjones@localhost w]$ 

PHP successfully connects when NLS_LANG supported components are used e.g.
  export NLS_LANG=_AMERICA.AL32UTF8

(Check the Oracle docs for supported values)
 [2007-07-11 12:25 UTC] tony2001@php.net
.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 15:01:28 2024 UTC