Index: openacs-4/packages/acs-tcl/tcl/01-database-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-tcl/tcl/Attic/01-database-procs.tcl,v diff -u -N -r1.1.2.41 -r1.1.2.42 --- openacs-4/packages/acs-tcl/tcl/01-database-procs.tcl 29 Aug 2022 09:06:15 -0000 1.1.2.41 +++ openacs-4/packages/acs-tcl/tcl/01-database-procs.tcl 25 Nov 2022 13:07:58 -0000 1.1.2.42 @@ -2773,14 +2773,26 @@ ad_proc -public db_get_database {{-dbn ""}} { - PostgreSQL only. + PostgreSQL and NSDB only. -

- @return the database name from the first database pool. It assumes the - datasource is properly formatted since we've already verified that we - can connect to the pool. + Return the database name from the first database pool. It assumes + the datasource is properly formatted since we've already verified + that we can connect to the pool. + On the longer range, it might be better to use SQL queries, at + least in cases, where database is already connected. + + PostgreSQL: + + SELECT current_database() + + Oracle: + + SELECT name from v$database; + SELECT ora_database_name FROM dual + @param dbn The database name to use. If empty_string, uses the default database. + @return database name } { set pool [lindex [db_available_pools $dbn] 0] set datasource [ns_config "ns/db/pool/$pool" DataSource] @@ -2789,7 +2801,13 @@ ns_log Error "datasource contains no \":\"? datasource = $datasource" return "" } - return [string range $datasource $last_colon_pos+1 end] + set dbname [string range $datasource $last_colon_pos+1 end] + set equal_pos [string first "=" $dbname] + if {$equal_pos > -1} { + # The value after the last colon is a + regexp {dbname=([^ ]+) ?} $dbname . dbname + } + return $dbname }