oracle/dotnet-db-samples

OracleDataSourceBuilder's UseModuleName and UseActionName do not work

Opened this issue · 3 comments

heku commented

The following code set module name to 'odpnet.module' and action name to 'odpnet.action'

  var oracle = new OracleDataSourceBuilder("......")
      .UseModuleName("odpnet.module")
      .UseActionName("odpnet.action") 
      .Build();

  var sid = oracle.CreateCommand("select sys_context('USERENV','SID') from dual").ExecuteScalar();
  Console.WriteLine(sid);

Then, expected result of query below should be 'odpnet.module' and 'odpnet.action', but it is not.

select module, action from v$session where sid=...;

With ExecuteScalar() in DataSourceBuilder, the connection closes immediately after the command completes. Are you performing the "select module..." statement after the connection closes?

If you ExecuteReader() instead, retrieve the SID, then perform the "select module..." BEFORE closing the reader, do you now see the correct module and action values? ExecuteReader is the only command OracleDataSourceBuilder will keep the connection open for after executing the command.

heku commented

@alexkeh Actually, it still does not work.

var oracle = new OracleDataSourceBuilder("......")
    .UseModuleName("odpnet.module")         // not work
    .UseActionName("odpnet.action")         // not work
    .UseClientId("odpnet.client id")        // not work
    .UseClientInfo("odpnet.client info")    // not work
    .Build();

var cmd = oracle.CreateCommand("select module, action, client_identifier, client_info from v$session where sid = sys_context('USERENV','SID')");
var reader = cmd.ExecuteReader();
while (reader.Read())
{
    Console.WriteLine("module:{0}", reader.GetValue("module"));                 // expect: odpnet.module,       actual: CONSOLE_PROJECT_NAME.EXE
    Console.WriteLine("action:{0}", reader.GetValue("action"));                 // expect: odpnet.action,       actual: null
    Console.WriteLine("client id:{0}", reader.GetValue("client_identifier"));   // expect: odpnet.client id,    actual: null
    Console.WriteLine("client info:{0}", reader.GetValue("client_info"));       // expect: odpnet.client info,  actual: null
}

@heku Thanks for the test case! I was able to reproduce the error. I filed a bug (38151399) to have the dev team review the issue and fix it.