- Methods: All Methods Documented Methods Hide Methods
- Source: Display Source Hide Source
- Variables: Show Variables Hide Variables
Class ::acs::db::postgresql
::acs::db::postgresql create ...
Class Relations
- class: ::nx::Class
- superclass: ::acs::db::SQL
- subclass: ::acs::db::nsdbi-postgresql, ::acs::db::nsdb-postgresql
::nx::Class create ::acs::db::postgresql \ -superclass ::acs::db::SQLMethods (to be applied on instances)
get_all_package_functions (scripted)
if {![db_table_exists acs_function_args]} { ns_log notice "acs_function_args is not (yet) defined, don't create stub functions now" return {} } set definitions [::acs::dc list_of_lists -dbn $dbn dbqd..get_all_package_functions { select function, arg_name, arg_default from acs_function_args order by function, arg_seq }] set db_definitions {} set last_function "" set argument_names {}; set defaulted {}; set defaults {} foreach definition $definitions { lassign $definition function arg_name default if {$last_function ne "" && $last_function ne $function} { dict set db_definitions $last_function [list argument_names $argument_names defaulted $defaulted defaults $defaults] set argument_names {}; set defaulted {}; set defaults {} } lappend argument_names $arg_name lappend defaulted [expr {$default eq "" ? "N" : "Y"}] lappend defaults $default set last_function $function } dict set db_definitions $last_function [list argument_names $argument_names defaulted $defaulted defaults $defaults] ns_log notice "loaded [dict size $db_definitions] definitions from function args" # # Get all package functions (package name, object name, # argument types, return type) from PostgreSQL system # catalogs. # set pg_data [::acs::dc list_of_lists -dbn $dbn dbqd..[current method] { select distinct af.function, substring(af.function from 0 for position('__' in af.function)) as package_name, substring(af.function from position('__' in af.function)+2) as object_name, oidvectortypes(proargtypes), format_type(prorettype, NULL) from pg_proc, acs_function_args af where proname = lower(af.function) }] foreach item $pg_data { lassign $item key package_name object_name argument_types result_type set argument_types [lmap argument_type [split $argument_types ,] { string trim $argument_type }] set nr_defined_args [llength [dict get $db_definitions $key argument_names]] if {[llength $argument_types] < $nr_defined_args} { # # This might be a definition with fewer arguments; we # aim always for the definition with the most # arguments. # continue } elseif {[llength $argument_types] < $nr_defined_args} { ns_log warning "generate_stubs: $key has lessf arguments in " "function_definitions ($nr_defined_args) than in DB [llength $argument_types]" continue } dict set db_definitions $key result_type $result_type dict set db_definitions $key types $argument_types dict set db_definitions $key package_name $package_name dict set db_definitions $key object_name $object_name } return [lmap {key entry} $db_definitions { if {![dict exists $entry package_name]} { ns_log warning "missing DB for $key: <$entry>" continue } list [dict get $entry package_name] [dict get $entry object_name] $entry }] return $db_definitionsmap_function_name (scripted)
return $sql
- Methods: All Methods Documented Methods Hide Methods
- Source: Display Source Hide Source
- Variables: Show Variables Hide Variables