php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #69877 i5_lib should be ignored or throw an exception if 'i5_naming' => DB2_I5_NAMING_
Submitted: 2015-06-18 16:54 UTC Modified: 2015-09-03 13:36 UTC
Votes:2
Avg. Score:3.5 ± 0.5
Reproduced:2 of 2 (100.0%)
Same Version:2 (100.0%)
Same OS:2 (100.0%)
From: davelhs03 at yahoo dot com Assigned:
Status: Wont fix Package: ibm_db2 (PECL)
PHP Version: Irrelevant OS: IBM i
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2015-06-18 16:54 UTC] davelhs03 at yahoo dot com
Description:
------------
I think the extension should either ignore i5_lib or throw an exception when i5_naming is set to DB2_I5_NAMING_ON.  What it actually does is it uses the i5_lib on the 2nd call to the connection.  This is a very hard to find bug

When making a connection with db2_pconnect with the options i5_lib set to a library and i5_naming set to DB2_I5_NAMING_ON the executed SQL on the first call to the connection uses the default library of the previous connection.  In the documentation, it states i5_lib is not valid if the connection is using system naming mode.  

Test Script:
In the test script below you'll see 4 connections are made to production and then 6 connections and sql calls are made to Development.  On the 1st connection to development it still goes against a PRODUCTION library.

PHP Documentation:
i5_lib - A character value that indicates the default library that will be used for resolving unqualified file references. This is not valid if the connection is using system naming mode.




Test script:
---------------
<?php
// Simulate connections to production applications
$db = connectToProduction('USER1','MYPASS');
$db = connectToProduction('USER2','MYPASS');
$db = connectToProduction('USER3','MYPASS');
$db = connectToProduction('USER4','WEBUSER');

$i = 0;
while($i <= 5) {

    // Simulate connection to development application 6 times
    $db = connectToDevelopment();

    $sql = "SELECT ENV FROM LIBTEST";
    $stmt = db2_prepare($db, $sql);
    $result = db2_execute($stmt);
    $row = db2_fetch_assoc($stmt);

    echo $row['ENV']."<br>";

    $i++;
}

function connectToProduction($username, $password)
{
    $db = db2_pconnect('*LOCAL', $username, $password,
        [
            'i5_naming' => DB2_I5_NAMING_ON,
            'i5_libl' => 'PRODLIB',
            'i5_lib' => 'PRODLIB'
        ]
    );
    if (!$db){throw new Exception('Connection failed');}
    echo "Production DB connection successful<br>";
    return $db;
}

function connectToDevelopment()
{
    $db = db2_pconnect('*LOCAL', 'WEBTEST', 'WEBTEST',
        [
            'i5_naming' => DB2_I5_NAMING_ON,
            'i5_libl' => 'DEVLIB',
            'i5_lib' => 'DEVLIB'
        ]
    );
    if (!$db){throw new Exception('Connection failed');}
    echo "Development DB connection successful<br>";
    return $db;
}


Expected result:
----------------
Production DB connection successful<br>
Production DB connection successful<br>
Production DB connection successful<br>
Production DB connection successful<br>
Development DB connection successful<br>
development
Development DB connection successful<br>
development
Development DB connection successful<br>
development
Development DB connection successful<br>
development
Development DB connection successful<br>
development
Development DB connection successful<br>
development

Actual result:
--------------
Production DB connection successful<br>
Production DB connection successful<br>
Production DB connection successful<br>
Production DB connection successful<br>
Development DB connection successful<br>
production
Development DB connection successful<br>
development
Development DB connection successful<br>
development
Development DB connection successful<br>
development
Development DB connection successful<br>
development
Development DB connection successful<br>
development

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2015-09-03 13:36 UTC] rangercairns@php.net
-Status: Open +Status: Wont fix
 [2015-09-03 13:36 UTC] rangercairns@php.net
This is suggestion for DB2 CLI SQLSetConnectAttr - SQL_ATTR_DBC_DEFAULT_LIB - A character value that indicates the default library that is used for resolving unqualified file references. Please handle this DB2 CLI requestthrough IBM service channels.
 
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Sun Nov 28 06:03:16 2021 UTC