Index: openacs-4/packages/acs-subsite/tcl/attribute-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-subsite/tcl/attribute-procs.tcl,v diff -u -r1.4 -r1.5 --- openacs-4/packages/acs-subsite/tcl/attribute-procs.tcl 19 Aug 2001 16:32:14 -0000 1.4 +++ openacs-4/packages/acs-subsite/tcl/attribute-procs.tcl 20 Aug 2001 05:15:28 -0000 1.5 @@ -281,7 +281,7 @@ } { # Just insert it if we can db_dml insert_enum_value { - insert into acs_enum_values v + insert into acs_enum_values (attribute_id, sort_order, enum_value, pretty_name) select :attribute_id, :sort_order, :enum_value, :enum_value from dual Index: openacs-4/packages/acs-subsite/tcl/attribute-procs.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-subsite/tcl/attribute-procs.xql,v diff -u -r1.3 -r1.4 --- openacs-4/packages/acs-subsite/tcl/attribute-procs.xql 11 Aug 2001 21:31:03 -0000 1.3 +++ openacs-4/packages/acs-subsite/tcl/attribute-procs.xql 20 Aug 2001 05:15:28 -0000 1.4 @@ -104,5 +104,18 @@ + + + + insert into acs_enum_values + (attribute_id, sort_order, enum_value, pretty_name) + select :attribute_id, :sort_order, :enum_value, :enum_value + from dual + where not exists (select 1 + from acs_enum_values v2 + where v2.pretty_name = :enum_value + and v2.attribute_id = :attribute_id) + + Index: openacs-4/packages/acs-subsite/tcl/rel-types-procs-oracle.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-subsite/tcl/rel-types-procs-oracle.xql,v diff -u -r1.1 -r1.2 --- openacs-4/packages/acs-subsite/tcl/rel-types-procs-oracle.xql 6 May 2001 21:40:21 -0000 1.1 +++ openacs-4/packages/acs-subsite/tcl/rel-types-procs-oracle.xql 20 Aug 2001 05:15:28 -0000 1.2 @@ -16,5 +16,34 @@ + + +begin acs_rel_type.drop_type(:rel_type); end; + + + + + + begin + acs_rel_type.create_type ( + rel_type => :rel_type, + supertype => :supertype, + pretty_name => :pretty_name, + pretty_plural => :pretty_plural, + table_name => :table_name, + id_column => 'rel_id', + package_name => :package_name, + object_type_one => :object_type_one, + role_one => :role_one, + min_n_rels_one => :min_n_rels_one, + max_n_rels_one => :max_n_rels_one, + object_type_two => :object_type_two, + role_two => :role_two, + min_n_rels_two => :min_n_rels_two, + max_n_rels_two => :max_n_rels_two + ); + end; + + Index: openacs-4/packages/acs-subsite/tcl/rel-types-procs-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-subsite/tcl/rel-types-procs-postgresql.xql,v diff -u -r1.3 -r1.4 --- openacs-4/packages/acs-subsite/tcl/rel-types-procs-postgresql.xql 19 Aug 2001 16:32:14 -0000 1.3 +++ openacs-4/packages/acs-subsite/tcl/rel-types-procs-postgresql.xql 20 Aug 2001 05:15:28 -0000 1.4 @@ -61,4 +61,14 @@ + + + create table $table_name ( + rel_id integer constraint $fk_constraint_name + references $references_table ($references_column) + constraint $pk_constraint_name primary key + ); + + + Index: openacs-4/packages/acs-subsite/tcl/rel-types-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-subsite/tcl/rel-types-procs.tcl,v diff -u -r1.3 -r1.4 --- openacs-4/packages/acs-subsite/tcl/rel-types-procs.tcl 19 Aug 2001 16:32:14 -0000 1.3 +++ openacs-4/packages/acs-subsite/tcl/rel-types-procs.tcl 20 Aug 2001 05:15:28 -0000 1.4 @@ -147,34 +147,14 @@ set plsql [list] # Create the actual acs object type - lappend plsql_drop [list "drop_type" "begin acs_rel_type.drop_type(:rel_type); end;" db_exec_plsql] - lappend plsql [list "create_type" { - begin - acs_rel_type.create_type ( - rel_type => :rel_type, - supertype => :supertype, - pretty_name => :pretty_name, - pretty_plural => :pretty_plural, - table_name => :table_name, - id_column => 'rel_id', - package_name => :package_name, - object_type_one => :object_type_one, - role_one => :role_one, - min_n_rels_one => :min_n_rels_one, - max_n_rels_one => :max_n_rels_one, - object_type_two => :object_type_two, - role_two => :role_two, - min_n_rels_two => :min_n_rels_two, - max_n_rels_two => :max_n_rels_two - ); - end; - } db_exec_plsql] - - # Mark the type as dynamic - lappend plsql [list update_type "update acs_object_types set dynamic_p='t' where object_type = :rel_type" "db_dml"] - + lappend plsql_drop [list db_exec_plsql drop_type {FOO}] + lappend plsql [list db_exec_plsql create_type {FOO}] + + # Mark the type as dynamic + lappend plsql [list db_dml update_type {FOO}] + foreach pair $plsql { - eval [lindex $pair 2] [lindex $pair 0] [lindex $pair 1] + eval [lindex $pair 0] [lindex $pair 1] [lindex $pair 2] } # The following create table statement commits the @@ -186,10 +166,12 @@ references $references_table ($references_column) constraint $pk_constraint_name primary key )"} errmsg] } { + ns_log Notice "BEN PROBLEM : $errmsg" + # Roll back our work so for for { set i [expr [llength $plsql_drop] - 1] } { $i >= 0 } { incr i -1 } { - set pair [lindex $plsql_drop $i] - if { [catch {db_exec_plsql [lindex $drop_pair 0] [lindex $drop_pair 1]} err_msg_2] } { + set drop_pair [lindex $plsql_drop $i] + if { [catch {eval [lindex $drop_pair 0] [lindex $drop_pair 1] [lindex $drop_pair 2]} err_msg_2] } { append errmsg "\nAdditional error while trying to roll back: $err_msg_2" return -code error $errmsg } Index: openacs-4/packages/acs-subsite/www/admin/rel-types/delete-2-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-subsite/www/admin/rel-types/delete-2-postgresql.xql,v diff -u -r1.2 -r1.3 --- openacs-4/packages/acs-subsite/www/admin/rel-types/delete-2-postgresql.xql 11 Aug 2001 21:31:03 -0000 1.2 +++ openacs-4/packages/acs-subsite/www/admin/rel-types/delete-2-postgresql.xql 20 Aug 2001 05:15:29 -0000 1.3 @@ -5,12 +5,7 @@ - - BEGIN - acs_rel_type__drop_type( rel_type => :rel_type, - cascade_p => 't' ); - END; - + select acs_rel_type__drop_type(:rel_type,'t') Index: openacs-4/packages/acs-subsite/www/admin/rel-types/delete-2.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-subsite/www/admin/rel-types/delete-2.tcl,v diff -u -r1.1 -r1.2 --- openacs-4/packages/acs-subsite/www/admin/rel-types/delete-2.tcl 13 Mar 2001 22:59:26 -0000 1.1 +++ openacs-4/packages/acs-subsite/www/admin/rel-types/delete-2.tcl 20 Aug 2001 05:15:29 -0000 1.2 @@ -60,7 +60,7 @@ rel_segments_delete $segment_id } - db_dml drop_relationship_type { + db_exec_plsql drop_relationship_type { BEGIN acs_rel_type.drop_type( rel_type => :rel_type, cascade_p => 't' ); Index: openacs-4/packages/acs-subsite/www/admin/rel-types/roles/delete-2-oracle.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-subsite/www/admin/rel-types/roles/delete-2-oracle.xql,v diff -u -r1.1 -r1.2 --- openacs-4/packages/acs-subsite/www/admin/rel-types/roles/delete-2-oracle.xql 15 May 2001 16:59:01 -0000 1.1 +++ openacs-4/packages/acs-subsite/www/admin/rel-types/roles/delete-2-oracle.xql 20 Aug 2001 05:15:29 -0000 1.2 @@ -3,6 +3,12 @@ oracle8.1.6 + + +begin acs_rel_type.drop_role(:role);end; + + + Index: openacs-4/packages/acs-subsite/www/admin/rel-types/roles/delete-2-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-subsite/www/admin/rel-types/roles/delete-2-postgresql.xql,v diff -u -r1.1 -r1.2 --- openacs-4/packages/acs-subsite/www/admin/rel-types/roles/delete-2-postgresql.xql 15 May 2001 16:59:01 -0000 1.1 +++ openacs-4/packages/acs-subsite/www/admin/rel-types/roles/delete-2-postgresql.xql 20 Aug 2001 05:15:29 -0000 1.2 @@ -3,6 +3,13 @@ postgresql7.1 + + + +select acs_rel_type__drop_role(:role) + + + Index: openacs-4/packages/acs-subsite/www/admin/rel-types/roles/index.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-subsite/www/admin/rel-types/roles/index.xql,v diff -u -r1.1 -r1.2 --- openacs-4/packages/acs-subsite/www/admin/rel-types/roles/index.xql 15 May 2001 16:59:01 -0000 1.1 +++ openacs-4/packages/acs-subsite/www/admin/rel-types/roles/index.xql 20 Aug 2001 05:15:29 -0000 1.2 @@ -3,18 +3,14 @@ - FIX ME OUTER JOIN - select r.role, r.pretty_name, coalesce(num1.number_rels,0) + coalesce(num2.number_rels,0) as number_rel_types - from (select t.role_one as role, count(*) as number_rels + from acs_rel_roles r left join + (select t.role_one as role, count(*) as number_rels from acs_rel_types t - group by t.role_one) num1, + group by t.role_one) num1 on r.role=num1.role left join (select t.role_two as role, count(*) as number_rels from acs_rel_types t - group by t.role_two) num2, - acs_rel_roles r - where r.role = num1.role(+) - and r.role = num2.role(+) + group by t.role_two) num2 on r.role=num2.role order by lower(r.role) 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.21 -r1.22 --- openacs-4/packages/acs-tcl/tcl/00-database-procs-postgresql.tcl 19 Aug 2001 21:26:05 -0000 1.21 +++ openacs-4/packages/acs-tcl/tcl/00-database-procs-postgresql.tcl 20 Aug 2001 05:15:29 -0000 1.22 @@ -37,11 +37,16 @@ db_with_handle db { # plsql calls that are simple selects bypass the plpgsql # mechanism for creating anonymous functions (OpenACS - Dan). + # if a table is being created, we need to bypass things, too (OpenACS - Ben). set test_sql [db_qd_replace_sql $full_statement_name $sql] if {[regexp -nocase -- {^\s*select} $test_sql match]} { db_qd_log Notice "PLPGSQL: bypassed anon function" set selection [db_exec 0or1row $db $full_statement_name $sql] - } else { + } elseif {[regexp -nocase -- {^\s*create table} $test_sql match] || [regexp -nocase -- {^\s*drop table} $test_sql match]} { + db_qd_log Notice "PLPGSQL: bypassed anon function -- create/drop table" + set selection [db_exec dml $db $full_statement_name $sql] + return "" + } else { db_qd_log Notice "PLPGSQL: using anonymous function" set selection [db_exec_plpgsql $db $full_statement_name $sql \ $statement_name]