Index: openacs-4/packages/acs-tcl/tcl/00-database-procs-postgresql.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-tcl/tcl/Attic/00-database-procs-postgresql.tcl,v diff -u -r1.4 -r1.5 --- openacs-4/packages/acs-tcl/tcl/00-database-procs-postgresql.tcl 20 Apr 2001 02:03:49 -0000 1.4 +++ openacs-4/packages/acs-tcl/tcl/00-database-procs-postgresql.tcl 24 Apr 2001 23:59:24 -0000 1.5 @@ -55,7 +55,7 @@ # drops the function. Future work might involve converting this to cache the # function calls -ad_proc -private db_exec_plpgsql { db statement_name sql fname } { +ad_proc -private db_exec_plpgsql { db statement_name pre_sql fname } { A helper procedure to execute a SQL statement, potentially binding depending on the value of the $bind variable in the calling environment @@ -69,10 +69,10 @@ } { set start_time [clock clicks] - ns_log Notice "PRE-QD: the SQL is $sql" + ns_log Notice "PRE-QD: the SQL is $pre_sql" # Query Dispatcher (OpenACS - ben) - set sql [db_qd_replace_sql $statement_name $sql] + set sql [db_qd_replace_sql $statement_name $pre_sql] ns_log Notice "POST-QD: the SQL is $sql" @@ -83,7 +83,9 @@ ns_log Notice "PLPGSQL: converted: $sql to: select $function_name ()" # insert tcl variable values (Openacs - Dan) - set sql [uplevel 2 [list subst -nocommands -nobackslashes $sql]] + if {![string equal $sql $pre_sql]} { + set sql [uplevel 2 [list subst -nobackslashes $sql]] + } # create a function definition statement for the inline code # binding is emulated in tcl. (OpenACS - Dan) @@ -190,7 +192,7 @@ return $lsql } -ad_proc -private db_exec { type db statement_name sql args } { +ad_proc -private db_exec { type db statement_name pre_sql args } { A helper procedure to execute a SQL statement, potentially binding depending on the value of the $bind variable in the calling environment @@ -199,13 +201,15 @@ } { set start_time [clock clicks] - ns_log Notice "PRE-QD: the SQL is $sql for $statement_name" + ns_log Notice "PRE-QD: the SQL is $pre_sql for $statement_name" # Query Dispatcher (OpenACS - ben) - set sql [db_qd_replace_sql $statement_name $sql] + set sql [db_qd_replace_sql $statement_name $pre_sql] # insert tcl variable values (Openacs - Dan) - set sql [uplevel 2 [list subst -nocommands -nobackslashes $sql]] + if {![string equal $sql $pre_sql]} { + set sql [uplevel 2 [list subst -nobackslashes $sql]] + } ns_log Notice "POST-QD: the SQL is $sql" @@ -291,10 +295,76 @@ ad_arg_parser { bind file args } $args db_with_handle db { - eval [list db_exec blob_get_file $db $statement_name $sql $file] $args + db_exec_lob $db $statement_name $sql $file } } +ad_proc -private db_exec_lob { db statement_name pre_sql file } { + + A helper procedure to execute a SQL statement, potentially binding + depending on the value of the $bind variable in the calling environment + (if set). + + Low level replacement for db_exec which emulates blob handling. + +} { + set start_time [clock clicks] + + ns_log Notice "PRE-QD: the SQL is $pre_sql" + + # Query Dispatcher (OpenACS - ben) + set sql [db_qd_replace_sql $statement_name $pre_sql] + + ns_log Notice "POST-QD: the SQL is $sql" + + # insert tcl variable values (Openacs - Dan) + if {![string equal $sql $pre_sql]} { + set sql [uplevel 2 [list subst -nobackslashes $sql]] + } + + # create a function definition statement for the inline code + # binding is emulated in tcl. (OpenACS - Dan) + + set errno [catch { + upvar bind bind + if { [info exists bind] && [llength $bind] != 0 } { + if { [llength $bind] == 1 } { + set bind_vars [list] + set len [ns_set size $bind] + for {set i 0} {$i < $len} {incr i} { + lappend bind_vars [ns_set key $bind $i] \ + [ns_set value $bind $i] + } + set lob_sql [db_bind_var_substitution $sql $bind_vars] + } else { + set lob_sql [db_bind_var_substitution $sql $bind] + } + } else { + set lob_sql [uplevel 2 [list db_bind_var_substitution $sql]] + } + + # get the lob id + set selection [ns_db 1row $db $lob_sql] + set lob_id [ns_set value $selection 0] + + ns_pg blob_select file $db $lob_id $file + return + + } error] + + global errorInfo errorCode + set errinfo $errorInfo + set errcode $errorCode + + ad_call_proc_if_exists ds_collect_db_call $db 0or1row $statement_name $sql $start_time $errno $error + + if { $errno == 2 } { + return $error + } + + return -code $errno -errorinfo $errinfo -errorcode $errcode $error +} + ad_proc db_get_pgbin { } { Returns the database name from the first database pool. It assumes the Index: openacs-4/packages/acs-tcl/tcl/apm-file-procs-oracle.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-tcl/tcl/apm-file-procs-oracle.xql,v diff -u -r1.1 -r1.2 --- openacs-4/packages/acs-tcl/tcl/apm-file-procs-oracle.xql 24 Apr 2001 06:02:26 -0000 1.1 +++ openacs-4/packages/acs-tcl/tcl/apm-file-procs-oracle.xql 24 Apr 2001 23:59:24 -0000 1.2 @@ -2,13 +2,6 @@ oracle8.1.6 - - - - select distribution_tarball from apm_package_versions where version_id = :version_id - - - Index: openacs-4/packages/acs-tcl/tcl/apm-file-procs-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-tcl/tcl/apm-file-procs-postgresql.xql,v diff -u -r1.5 -r1.6 --- openacs-4/packages/acs-tcl/tcl/apm-file-procs-postgresql.xql 24 Apr 2001 06:02:26 -0000 1.5 +++ openacs-4/packages/acs-tcl/tcl/apm-file-procs-postgresql.xql 24 Apr 2001 23:59:24 -0000 1.6 @@ -3,12 +3,6 @@ postgresql7.1 - - - FIX ME LOB select distribution_tarball from apm_package_versions where version_id = :version_id - - - Index: openacs-4/packages/acs-tcl/tcl/apm-file-procs.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-tcl/tcl/apm-file-procs.xql,v diff -u -r1.1 -r1.2 --- openacs-4/packages/acs-tcl/tcl/apm-file-procs.xql 24 Apr 2001 06:02:26 -0000 1.1 +++ openacs-4/packages/acs-tcl/tcl/apm-file-procs.xql 24 Apr 2001 23:59:24 -0000 1.2 @@ -7,6 +7,12 @@ + + + select distribution_tarball from apm_package_versions where version_id = :version_id + + + Index: openacs-4/packages/acs-tcl/tcl/object-type-procs-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-tcl/tcl/object-type-procs-postgresql.xql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/acs-tcl/tcl/object-type-procs-postgresql.xql 24 Apr 2001 23:59:24 -0000 1.1 @@ -0,0 +1,11 @@ + + + + + +[acs_object_type_hierarchy_pg_sql $object_type $indent_string $indent_width] + + + + + Index: openacs-4/packages/acs-tcl/tcl/object-type-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-tcl/tcl/object-type-procs.tcl,v diff -u -r1.1 -r1.2 --- openacs-4/packages/acs-tcl/tcl/object-type-procs.tcl 13 Mar 2001 22:59:26 -0000 1.1 +++ openacs-4/packages/acs-tcl/tcl/object-type-procs.tcl 24 Apr 2001 23:59:24 -0000 1.2 @@ -74,3 +74,54 @@ return $result } + + +ad_proc -public acs_object_type_hierarchy_pg_sql { + + -object_type + -indent_string + -indent_width + +} { + + Returns pg version of sql for acs_object_type_hierarchy routine. This + routine is called by the query dispatcher. + + @author Dan Wickstrom (dcwickstrom@earthlink.net) + @creation-date April 24, 2001 + @param object_type the object type for which to show a hierarchy for. + @param indent_string string with which to lpad + @param indent_width number of times to insert indent_string into indentation + +} { + + if { [exists_and_not_null object_type] } { + + set sql " + select ot2.object_type, + ot2.pretty_name, + '' as indent, + tree_level(ot2.tree_sortkey) as level + from acs_object_types ot1, acs_object_types ot2 + where ot1.object_type = :object_type + and ot2.tree_sortkey <= ot1.tree_sortkey + and ot1.tree_sortkey like (ot2.tree_sortkey || '%') + order by level desc + " + + } else { + #FIXME: what is the equivalent of oracle's replace function? + set sql " + select object_type, + pretty_name, + replace(lpad(' ', (tree_level(tree_sortkey) - 1) * $indent_width), ' ', '$indent_string') as indent + from acs_object_types + where tree_sortkey like (select tree_sortkey || '%' + from acs_object_types + where supertype is null) + " + + } + + return $sql +} Index: openacs-4/packages/acs-tcl/tcl/object-type-procs.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-tcl/tcl/Attic/object-type-procs.xql,v diff -u -r1.1 -r1.2 --- openacs-4/packages/acs-tcl/tcl/object-type-procs.xql 24 Apr 2001 06:02:27 -0000 1.1 +++ openacs-4/packages/acs-tcl/tcl/object-type-procs.xql 24 Apr 2001 23:59:24 -0000 1.2 @@ -3,7 +3,7 @@ - $sql + $sql