dotnet-db-samples icon indicating copy to clipboard operation
dotnet-db-samples copied to clipboard

OracleDataSourceBuilder's UseModuleName and UseActionName do not work

Open heku opened this issue 8 months ago • 3 comments

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=...;

heku avatar Jun 28 '25 07:06 heku

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.

alexkeh avatar Jun 28 '25 17:06 alexkeh

@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 avatar Jun 30 '25 14:06 heku

@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.

alexkeh avatar Jul 04 '25 03:07 alexkeh