xotcl.wu-wien.ac.at
Begin main content
Methods: Source: Variables:
[All Methods | Documented Methods | Hide Methods] [Display Source | Hide Source] [Show Variables | Hide Variables]

::xotcl::Object[i] ::xo::db::require

::xotcl::Object create ::xo::db::require

Methods

  • proc function_args (public)

    ::xo::db::require[i] function_args \
        [ -kernel_older_than kernel_older_than ] \
        [ -package_key_and_version_older_than package_key_and_version_older_than ] \
        [ -check_function check_function ] sql_file
    Load the sql file, if the the kernel is older than the specified version, and the version of the specified package is older, and the check_function does not exist in function_args.

    Sample usage: ::xo::db::require function_args \
      -kernel_older_than 5.5.0 \
      -older_than_package_key_and_version "xowiki 0.50" \
      -check_function "acs_object_type__create_type" \
      [acs_package_root_dir xotcl-request-broker]/patches/funcs-1.sql

    Switches:
    -kernel_older_than (optional)
    -package_key_and_version_older_than (optional)
    -check_function (optional)
    Parameters:
    sql_file
    ::xowiki::policy5 proc function_args {-kernel_older_than -package_key_and_version_older_than -check_function sql_file} {
        if {[db_driverkey ""] eq "postgresql"} {
          # only necessary with postgres
          if {[info exists kernel_older_than]} {
    	if {[apm_version_names_compare  $kernel_older_than [ad_acs_version]] < 1} {
    	  # nothing to do
    	  return
    	}
          }
          if {[info exists package_key_and_version_older_than]} {
    	set p [split $package_key_and_version_older_than]
    	if {[llength $p] != 2} {
    	  error "package_key_and_version_older_than should be of the form 'package_key version'"
    	}
    	foreach {package_key version} $p break
    	set installed_version [apm_highest_version_name $package_key]
    	if {[apm_version_names_compare $installed_version $version] > -1} {
    	  # nothing to do
    	  return
    	}
          }
          if {[info exists check_function]} {
    	set check_function [string toupper $check_function]
    	set function_exists [::xo::db_string query_version {
    	  select 1 from acs_function_args where function = :check_function 
    	  limit 1
    	} 0]
    	if {$function_exists} {
    	  # nothing to do
    	  return
    	}
          }
    
          if {[file readable $sql_file]} {
    	my log "Sourcing '$sql_file'"
    	db_source_sql_file $sql_file
    	::xo::db::Class create_all_functions
    	return 1
          } else {
    	my log "Could not source '$sql_file'"
          }
        }
        return 0
      }
    

Methods: Source: Variables:
[All Methods | Documented Methods | Hide Methods] [Display Source | Hide Source] [Show Variables | Hide Variables]