Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update INI documentation for ibm_db2 #3061

Merged
merged 9 commits into from
Jan 5, 2024

Conversation

NattyNarwhal
Copy link
Member

A bunch of previously undocumented stuff, including things that are ugly and probably should be deprecated.

Note some of these are platform-specific; I have tried to word based on this ("on IBM i" vs. "when connecting to IBM i"), but I've considered adding a column, if that would make sense.

Many of these are IBM i specific (though some it doesn't make sense for
it to be; I might fix that later).

Also change the table sorting to be ASCII sort order.

Considering adding platform support to the table, and rewriting some of
the word salad in other entries.
Also mention what is definitely suspicious (I will prob deprecate these
in ibm_db2)
Copy link
Member

@Girgias Girgias left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor nits but looks good overall

reference/ibm_db2/ini.xml Outdated Show resolved Hide resolved
reference/ibm_db2/ini.xml Outdated Show resolved Hide resolved
reference/ibm_db2/ini.xml Outdated Show resolved Hide resolved
reference/ibm_db2/ini.xml Show resolved Hide resolved
reference/ibm_db2/ini.xml Show resolved Hide resolved
reference/ibm_db2/ini.xml Show resolved Hide resolved
make suggest changes from gina (phrasing, markup), use XML literals
running on IBM i.
By default, this option is <literal>0</literal>.
When enabled, a blank user ID and password is always used when
connecting, so it uses the current profile when connecting.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@NattyNarwhal The historical use case for null user and password was to stay out of Server Mode, i.e. not connect to a QSQSRVR job. The database is accessed directly inside PHP. It was a performance optimization. The danger is not only being limited to the web server user, (in the case of a web application), but that database resources could potentially linger in the PHP job.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Null username/password avoiding spawning a server job isn't documented elsewhere for ibm_db2; the underlying SQLConnect mentions non-server mode, but implies you can just use server mode where null uid/pwd still uses a server, just with current profile. So how does it handle to use server vs. in process?

Checking ibm_db2, it does set the environment attribute to use a here, if this option is off:

            if (IBM_DB2_G(i5_ignore_userid) < 1 && !is_i5_server_mode) {
                attr = SQL_TRUE;
                rc = SQLSetEnvAttr((SQLHENV)conn_res->henv, SQL_ATTR_SERVER_MODE, (SQLPOINTER)(intptr_t)attr, SQL_IS_INTEGER);
                if (rc == SQL_SUCCESS) {
                    is_i5_server_mode=1;
                }
            }

...and it checks the option here for if it should set the job's subsystem if using a server:

        /* 1.9.7 - IBM i consultant request switch subsystem QSQSRVR job (customer workload issues) */
        if (IBM_DB2_G(i5_servermode_subsystem) && strlen(IBM_DB2_G(i5_servermode_subsystem)) > 0 && IBM_DB2_G(i5_ignore_userid) < 1) {
            rc = SQLSetConnectAttr((SQLHDBC)conn_res->hdbc, SQL_ATTR_SERVERMODE_SUBSYSTEM, (SQLPOINTER) IBM_DB2_G(i5_servermode_subsystem), SQL_NTS);
        } 

...so this option is kind of misleadingly named - it should be more like "run database job in the same job as PHP". That's a lot to describe. And the funny thing is I think you can still use a different profile for same-job, it just suppresses the passed options to SQLConnect if so:

#ifdef PASE /* 1.9.7 - IBM i cosolidate connect differences/options (code clarity) */
            /* If the string contains a =, use SQLDriverConnect */
            if ( strstr(database, "=") != NULL ) { 
                /* IBM i unqualified connect requires output buffer (long time ibm_db2 bug) */
                rc = SQLDriverConnect((SQLHDBC)conn_res->hdbc, (SQLHWND)NULL,
                        (SQLCHAR*)database, SQL_NTS, i_buffer, 255, &i_outlen, SQL_DRIVER_NOPROMPT );
            } else { /* IBM i allow/not blank db, uid, pwd (customer request vs. security issue) */
                if (IBM_DB2_G(i5_ignore_userid) > 0 || (IBM_DB2_G(i5_blank_userid) > 0 && uid_len == 0 && password_len == 0) ) {
                    rc = SQLConnect( (SQLHDBC)conn_res->hdbc, (SQLCHAR *)database,
                            (SQLSMALLINT)database_len, (SQLCHAR *)NULL, (SQLSMALLINT)0,
                            (SQLCHAR *)NULL, (SQLSMALLINT)0);
                } else { /* normal uid/pwd connection */
                    rc = SQLConnect( (SQLHDBC)conn_res->hdbc, (SQLCHAR *)database,
                        (SQLSMALLINT)database_len, (SQLCHAR *)uid, (SQLSMALLINT)uid_len,
                        (SQLCHAR *)password, (SQLSMALLINT)password_len );
                }
            }
#else /* LUW */
            /* If the string contains a =, use SQLDriverConnect */
            if ( strstr(database, "=") != NULL ) {
                rc = SQLDriverConnect((SQLHDBC)conn_res->hdbc, (SQLHWND)NULL,
                        (SQLCHAR*)database, SQL_NTS, NULL, 0, NULL, SQL_DRIVER_NOPROMPT );
            } else {
                rc = SQLConnect( (SQLHDBC)conn_res->hdbc, (SQLCHAR *)database,
                        (SQLSMALLINT)database_len, (SQLCHAR *)uid, (SQLSMALLINT)uid_len,
                        (SQLCHAR *)password, (SQLSMALLINT)password_len );
            }
#endif /* PASE */

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@NattyNarwhal Thanks for confirming and clarifying. Yes, Tony sometimes named things literally in a technical sense, not so much what the purpose was. Yes, the purpose is to run the database job in the same job as PHP. Should we provide an alias called "i5-use-client-job" or something?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it should probably be renamed in ibm_db2, but that's a separate issue (tracking here). For now, we should document the existing behaviour in this PR.

sentence breaking on lines, clear up language, use PASE CCSID
terminology instead, mention how locales map to CCSIDs
ignore_userid is VERY misleadingly named, but document the actual
functionality.
@NattyNarwhal
Copy link
Member Author

This doesn't include i5_check_pconnect, but that option is Not Good and contains some suspect functionality.

reference/ibm_db2/ini.xml Outdated Show resolved Hide resolved
reference/ibm_db2/ini.xml Outdated Show resolved Hide resolved
NattyNarwhal and others added 2 commits January 5, 2024 11:48
suggested change from gina

Co-authored-by: Gina Peter Banyard <girgias@php.net>
suggested change from gina

Co-authored-by: Gina Peter Banyard <girgias@php.net>
@Girgias Girgias merged commit 7b0e8c8 into php:master Jan 5, 2024
2 checks passed
@Girgias
Copy link
Member

Girgias commented Jan 5, 2024

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants