db_get_port (public)

 db_get_port [ -dbn dbn ]

Defined in packages/acs-tcl/tcl/01-database-procs.tcl

PostgreSQL only.

Switches:
-dbn
(optional)
The database name to use. If empty_string, uses the default database.
Returns:
the port number from the first database pool. It assumes the datasource is properly formatted since we've already verified that we can connect to the pool. It returns an empty string for an empty port value.

Partial Call Graph (max 5 caller/called nodes):
%3 db_load_sql_data db_load_sql_data (public) db_get_port db_get_port db_load_sql_data->db_get_port db_source_sql_file db_source_sql_file (public) db_source_sql_file->db_get_port db_available_pools db_available_pools (public) db_get_port->db_available_pools

Testcases:
No testcase defined.
Source code:
    set pool [lindex [db_available_pools $dbn] 0]
    set datasource [ns_config "ns/db/pool/$pool" DataSource]
    set last_colon_pos [string last ":" $datasource]
    if { $last_colon_pos == -1 } {
        ns_log Error "datasource contains no \":\"? datasource = $datasource"
        return ""
    }
    set first_colon_pos [string first ":" $datasource]

    if { $first_colon_pos == $last_colon_pos || ($last_colon_pos - $first_colon_pos) == 1 } {
        # No port specified
        return ""
    }

    return [string range $datasource $first_colon_pos+1 $last_colon_pos-1]
XQL Not present:
Generic, PostgreSQL, Oracle
[ hide source ] | [ make this the default ]
Show another procedure: