Identifier.pls is missing single quotes on constant identifier_max_length.
Correct line should be:
identifier_max_length constant number:= '<?php print ORACLE_IDENTIFIER_MAX_LENGTH; ?>';

There is an assumption in identifier.plb that the drupal account has database admin privileges; if there is no user that matches the prefix, then it will try and grant connect and resource to the user. The prefix should only be interpreted as an account if it is not null, and it contains an '.'. A better rewrite for function check_db_prefix should be:


function check_db_prefix(p_db_prefix varchar2)
return varchar2
as pragma autonomous_transaction;
v_db_prefix varchar2(30):= upper(get_for(p_db_prefix));
begin
if(v_db_prefix is not null and instrc(p_db_prefix,'.') > 0) then
select username
into v_db_prefix
from all_users
where username= v_db_prefix;
end if ;

return v_db_prefix;

exception
when no_data_found then
raise_application_error(-20001,'User '||v_db_prefix||' does not exist') ;
/* execute immediate 'grant connect, resource to "'||v_db_prefix||'" identified by "'||v_db_prefix||'"';
* return v_db_prefix;
*/
end;

Full corrected versions of identifier.pls and identifier.plb are included as attachments.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

BobA’s picture

Issue summary: View changes

website misinterpreting string constant.

BobA’s picture

Issue summary: View changes

minor text change

brianV’s picture

Issue summary: View changes

fix code formatting

brianV’s picture

Status: Active » Needs review
FileSize
1.53 KB

Patch attached which implements the above fix.

aaaristo’s picture

Status: Needs review » Closed (won't fix)

brian:

1. ORACLE_IDENTIFIER_MAX_LENGTH is a number so it does not need single quotes, better: you SHOULD not use single quotes.

2. p_db_prefix SHOULD not contain a dot '.' so i cannot see how these helps

3. i don't want to raise any exception is clearly stated in the INSTALL.oracle.txt that if you whant to use db_prefixes you SHOULD grant
dba privileges or equivalent to create accounts to the drupal oracle account. This is because in the Drupal philosophy things MUST
work as much as they can out of the box. If somebody whants a different behavior it will code it yourself, but this will not be released
with this driver.

brianV’s picture

Status: Closed (won't fix) » Needs work

Moving to code needs work because I think this bears more conversation.

Also posting the following on behalf of BobA as he's a coworker and doesn't have his d.org password handy at the moment:

For Identifier.pls having embedded php code, presents some awkwardness, because if it has to be manually reinstalled, the strings would not be interpreted correctly by sqlplus. I suggest substituting the same onstant values as defined in database.inc for the php strings, as in:

  long_identifier_prefix  constant varchar2(10):= 'L#';
  identifier_max_length   constant number:= 30;
  empty_replacer_char     constant varchar2(10):= '^';
  

For Identifier.plb, if the table prefix is always interpreted as a username, and not a general table prefix as in the case with Mantis, then the code can be left as is, except there should be a test to make sure the table prefix is not null. If you want to extend this to allow for general table prefixes, you can distinquish between a table prefix as a username, vs a table name modifier if the prefix contains an embedded '.'. In this case the username search can be done using the substring up to but not including the '.'. I would as a minimum leave the check for null string, in case this function is ever called when the prefix is a null string, ie:

     if(v_db_prefix is not null) then
     select username
       into v_db_prefix
       from all_users
      where username= v_db_prefix;
	 end if ;
  

The issue in our case was that not all of the support functions/procedures/packages were installed into when the driver was enabled, so we were experiencing confusing error statement, until these were installed manually. Having everything work out of the box is good, but when it doesn't then this can complicate the installation and cause much wasted time.

brianV’s picture

fix some linespace issues.