|
From: <ken...@us...> - 2009-03-23 19:04:50
|
Revision: 1323
http://andro.svn.sourceforge.net/andro/?rev=1323&view=rev
Author: kendowns
Date: 2009-03-23 19:04:46 +0000 (Mon, 23 Mar 2009)
Log Message:
-----------
Sourceforge 2706831.
Modified Paths:
--------------
trunk/andro/application/androBuild.php
Modified: trunk/andro/application/androBuild.php
===================================================================
--- trunk/andro/application/androBuild.php 2009-03-20 18:01:00 UTC (rev 1322)
+++ trunk/andro/application/androBuild.php 2009-03-23 19:04:46 UTC (rev 1323)
@@ -2725,6 +2725,39 @@
"cols_par"=>$pk,
"cols_both"=>$both,
"cols_match"=>$match);
+
+ # KFD 3/23/09 Sourceforge 2706831
+ # HORRIBLE HACK. Make a second list of foreign keys
+ # that includes the prefix also. Good news is we
+ # could gradually switch over to using this proper
+ # one. We cannot change the original one because
+ # we would break all kinds of things.
+ $combo =
+ trim($row["table_id"])."_".
+ trim($row['prefix'])."_".
+ trim($row["table_id_par"])."_".
+ $suffix;
+
+ $this->ufks2[$combo] = array(
+ "combo"=>$combo,
+ "table_id_chd"=>trim($row["table_id"]),
+ "table_id_par"=>trim($row["table_id_par"]),
+ "suffix"=>trim($row["suffix"]),
+ "auto_insert"=>$row["auto_insert"],
+ "copysamecols"=>$row["copysamecols"],
+ "nocolumns"=>$row["nocolumns"],
+ "allow_empty"=>$row["allow_empty"],
+ "allow_orphans"=>$row["allow_orphans"],
+ "delete_cascade"=>$row["delete_cascade"],
+ "prevent_fk_change"=>$row["prevent_fk_change"],
+ "uidisplay"=>$row['uidisplay'],
+ "cols_chd"=>$fk,
+ "cols_par"=>$pk,
+ "cols_both"=>$both,
+ "cols_match"=>$match
+ );
+
+
$rc++;
}
return $retval;
@@ -4270,7 +4303,8 @@
,'auto_prefix'=>$row['auto_prefix']
,'auto_suffix'=>$row['auto_suffix']
);
- $tpi = $row['table_id'].'_'.$tp.'_'.$row['auto_suffix'];
+ # KFD 3/23/09 Sourceforge 2706831 Respect auto_prefix
+ $tpi = $row['table_id'].'_'.$row['auto_prefix'].'_'.$tp.'_'.$row['auto_suffix'];
// This creates definitions grouped by foreign key definitions
if(!isset($ddall[$row['table_id']][$tpi])) {
@@ -4315,16 +4349,19 @@
// Generate the keys match between the two tables
// KFD 2/16/07, big change to allow suffix/prefix
//$keyname = $table_id."_".$table_id_par."_";
+ # KFD 3/23/09 Sourceforge 2706831 Use alternate FK List
$keyname = $foreign_key;
- $keys = $this->ufks[$keyname]["cols_both"];
+ $keys = $this->ufks2[$keyname]["cols_both"];
// KFD 10/12/06, part of general changes to range foreign keys
//$match = str_replace(","," AND new.",$keys);
//$match = "new.".str_replace(":"," = par.",$match);
- $match=str_replace("chd.","new.",$this->ufks[$keyname]['cols_match']);
+ # KFD 3/23/09 Sourceforge 2706831 Use alternate FK List
+ $match=str_replace("chd.","new.",$this->ufks2[$keyname]['cols_match']);
// KFD 6/22/07, don't do a fetch if the foreign key is null
- $keyskids=$this->ufks[$keyname]['cols_chd'];
+ # KFD 3/23/09 Sourceforge 2706831 Use alternate FK List
+ $keyskids=$this->ufks2[$keyname]['cols_chd'];
$akeyskids=explode(',',$keyskids);
$nullchecks = array();
foreach($akeyskids as $akeykid) {
@@ -4332,7 +4369,8 @@
}
// Generate a key change expression for child table
- $keychga = explode(",",$this->ufks[$keyname]["cols_chd"]);
+ # KFD 3/23/09 Sourceforge 2706831 Use alternate FK List
+ $keychga = explode(",",$this->ufks2[$keyname]["cols_chd"]);
$keychgb = array();
foreach($keychga as $keycol) {
$type_id=$this->utabs[$table_id]['flat'][$keycol]['formshort'];
@@ -4442,15 +4480,18 @@
// Generate the keys match between the two tables
// KFD 3/1/07, fix this
$keyname=$foreign_key;
- $keys = $this->ufks[$keyname]["cols_both"];
+ # KFD 3/23/09 Sourceforge 2706831 Use alternate FK List
+ $keys = $this->ufks2[$keyname]["cols_both"];
// KFD 10/12/06, part of range foreign keys actually
// KFD Fixed 6/18/07, this was wrong, making the wrong match
// not picked up cuz we don't use DISTRIBUTE much
- $match=str_replace("chd.",$table_id.".",$this->ufks[$keyname]['cols_match']);
+ # KFD 3/23/09 Sourceforge 2706831 Use alternate FK List
+ $match=str_replace("chd.",$table_id.".",$this->ufks2[$keyname]['cols_match']);
$match=str_replace('par.','new.',$match);
// For "SYNCH" automations, build the reverse match
- $matchr=str_replace("chd.","new.",$this->ufks[$keyname]['cols_match']);
+ # KFD 3/23/09 Sourceforge 2706831 Use alternate FK List
+ $matchr=str_replace("chd.","new.",$this->ufks2[$keyname]['cols_match']);
$matchr=str_replace("par.",$table_id_par.".",$matchr);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ken...@us...> - 2009-04-04 12:48:58
|
Revision: 1332
http://andro.svn.sourceforge.net/andro/?rev=1332&view=rev
Author: kendowns
Date: 2009-04-04 12:48:56 +0000 (Sat, 04 Apr 2009)
Log Message:
-----------
Sourceforge 2722150, detect suffix/prefix combos that result in empty column names.
Modified Paths:
--------------
trunk/andro/application/androBuild.php
Modified: trunk/andro/application/androBuild.php
===================================================================
--- trunk/andro/application/androBuild.php 2009-03-24 02:11:19 UTC (rev 1331)
+++ trunk/andro/application/androBuild.php 2009-04-04 12:48:56 UTC (rev 1332)
@@ -6439,6 +6439,26 @@
);
$this->LogEntry("ERROR >> ");
}
+
+ // KFD 4/4/09 Sourceforge 2722150
+ $this->LogEntry("Looking for bad suffix/prefix combos, empty columns");
+ $results = $this->SQLRead(
+ "select table_id,prefix,suffix from zdd.tabflat ".
+ " where column_id_src=''");
+ while($row=pg_fetch_array($results)) {
+ $errors++;
+ $this->LogEntry("");
+ $this->LogEntry(
+ "ERROR >> table ". $row["table_id"]." has an empty column."
+ );
+ $this->LogEntry(
+ "ERROR >> maybe the prefix or suffix is wrong?"
+ );
+ $this->LogEntry("ERROR >> "
+ ." Prefix: ".$row['prefix'].", Suffix: ".$row['suffix']
+ );
+ $this->LogEntry("ERROR >> ");
+ }
// Check for no automation Id for some automations
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ken...@us...> - 2009-04-06 18:40:05
|
Revision: 1336
http://andro.svn.sourceforge.net/andro/?rev=1336&view=rev
Author: kendowns
Date: 2009-04-06 18:39:44 +0000 (Mon, 06 Apr 2009)
Log Message:
-----------
Sourceforge 2738278, allow explicit typecasts in chain arguments
Sourceforge 2738280, fix !EMPTY comparison for dates and datetimes
Modified Paths:
--------------
trunk/andro/application/androBuild.php
Modified: trunk/andro/application/androBuild.php
===================================================================
--- trunk/andro/application/androBuild.php 2009-04-06 17:35:31 UTC (rev 1335)
+++ trunk/andro/application/androBuild.php 2009-04-06 18:39:44 UTC (rev 1336)
@@ -5767,8 +5767,13 @@
$retval = $arg1. " $not BETWEEN ".implode(" AND ",$args);
break;
case "!EMPTY":
- $sfb=$this->SQLFORMATBLANK($cta1,true,true);
- $retval = "COALESCE($arg1,$sfb) <> $sfb";
+ if($cta1=='date' || $cta1=='datetime') {
+ $retval = "$arg1 IS NOT NULL";
+ }
+ else {
+ $sfb=$this->SQLFORMATBLANK($cta1,true,true);
+ $retval = "COALESCE($arg1,$sfb) <> $sfb";
+ }
break;
case "EMPTY":
$sfb=$this->SQLFORMATBLANK($cta1,true,true);
@@ -6536,8 +6541,29 @@
$errors+=$this->SpecValidateRI('histcols' ,'retcol' ,'History Definition');
$errors+=$this->SpecValidateRI('tabprojcols' ,'column_id','Projection');
$errors+=$this->SpecValidateRI('colchaintests','column_id','Chain Test Definition');
- $errors+=$this->SpecValidateRI('colchainargs' ,'column_id_arg','Chain Argument Definition');
+ #$errors+=$this->SpecValidateRI('colchainargs' ,"replace(column_id_arg,'::int','')",'Chain Argument Definition');
+
+ $this->LogEntry("Checking column definitions in chain arguments");
+ $errors = 0;
+ $sq="SELECT table_id,column_id_arg as column_id FROM zdd.colchainargs
+ WHERE column_id_arg <> ''
+ AND NOT EXISTS (
+ SELECT * from zdd.tabflat
+ WHERE table_id = zdd.colchainargs.table_id
+ AND column_id = REGEXP_REPLACE(zdd.colchainargs.column_id_arg,'::.*','')
+ )";
+ $results = $this->SQLRead($sq);
+ while ($row=pg_fetch_array($results)) {
+ $retval=false;
+ $this->LogEntry("");
+ $this->LogEntry(
+ "ERROR >> Chain Argument Definition in table colchainargs"
+ ." refers to undefined column ".$row['column_id']
+ );
+ $errors++;
+ }
+
// Some manual RI checks
$sq="SELECT h.history,hc.table_id,hc.column_id
FROM zdd.histcols hc
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ken...@us...> - 2009-04-11 15:37:38
|
Revision: 1340
http://andro.svn.sourceforge.net/andro/?rev=1340&view=rev
Author: kendowns
Date: 2009-04-11 15:37:29 +0000 (Sat, 11 Apr 2009)
Log Message:
-----------
Sourceforge 2753136, update sequence when a SEQDEFAULT value is provided by user
Sourceforge 2753174, allow SEQUENCE and SEQDEFAULT to work for char/varchar fields.
Sourceforge 2753129, fix column dependencies when a chain argument uses typecasts.
Modified Paths:
--------------
trunk/andro/application/androBuild.php
Modified: trunk/andro/application/androBuild.php
===================================================================
--- trunk/andro/application/androBuild.php 2009-04-09 17:58:52 UTC (rev 1339)
+++ trunk/andro/application/androBuild.php 2009-04-11 15:37:29 UTC (rev 1340)
@@ -2149,6 +2149,8 @@
function SpecFlatten_ColumnDeps() {
$retval=true;
$this->LogEntry("COLUMN DEPENDENCIES: From Chains");
+ // KFD 4/11/09 Sourceforge 2753129, remove typecasting
+ // from chain column arguments
// KFD 5/30/07, add filtering out self-dependencies, we
// don't need to know and it gives false sequencing errors
// KFD 6/ 8/07, putting in the filter caused other problems,
@@ -2163,7 +2165,8 @@
INSERT INTO zdd.column_deps
(table_id,column_id,table_dep,column_dep,automation_id)
SELECT DISTINCT table_id,column_id
- ,table_id,column_id_arg,'EXTEND'
+ ,table_id
+ ,regexp_replace(column_id_arg,'::.*',''),'EXTEND'
FROM zdd.colchainargs
WHERE zdd.colchainargs.column_id_arg <> ''
AND zdd.colchainargs.chain <> 'cons'
@@ -3512,7 +3515,7 @@
function SpecDDL_Triggers_Defaults() {
$this->LogEntry("Building default clauses");
$results = $this->SQLRead(
- "SELECT table_id,column_id,automation_id,formshort,auto_formula,type_id".
+ "SELECT table_id,column_id,automation_id,formshort,colprec,auto_formula,type_id".
" FROM zdd.tabflat ".
" WHERE automation_id IN ('BLANK','DEFAULT','SEQUENCE','SEQDEFAULT','TS_INS','UID_INS','TS_UPD','UID_UPD','QUEUEPOS','TS_UPD_PG','UID_UPD_PG')"
);
@@ -3522,7 +3525,7 @@
$table_id = $row["table_id"];
$column_id = trim($row["column_id"]);
$automation_id = trim(strtoupper($row["automation_id"]));
- $formshort = $row["formshort"];
+ $formshort = trim($row["formshort"]);
if ($automation_id=="SEQUENCE") {
$s1 = "\n".
@@ -3552,10 +3555,15 @@
" END IF;\n";
}
$Seq = $this->DBB_SequenceName($table_id,$row["auto_formula"],$column_id);
+ # KFD 4/11/09 Sourceforge 2753174 Support char/varchar
+ $nextval = "nextval(##". $Seq . "##)";
+ if($formshort=='char' || $formshort=='varchar') {
+ $nextval = "lpad($nextval::varchar,{$row['colprec']},##0##)";
+ }
$s1 =
" -- 1011 sequence/default assignment\n".
" IF new.". $column_id . " IS NULL THEN \n".
- " new.". $column_id . " = nextval(##". $Seq . "##);\n".
+ " new.". $column_id . " = $nextval;\n".
$nlist.
" END IF;\n";
$this->SpecDDL_TriggerFragment($table_id,"INSERT","BEFORE","1011",$s1);
@@ -3571,11 +3579,25 @@
" END IF;\n";
$this->SpecDDL_TriggerFragment($table_id,"UPDATE","BEFORE","1010",$s1);
- $Seq = $this->DBB_SequenceName($table_id,$row["auto_formula"],$column_id);
+ $Seq = $this->DBB_SequenceName($table_id,$row["auto_formula"],$column_id);
+ # KFD 4/11/09 Sourceforge 2753136 If SEQDEFAULT value is provided,
+ # make sure next sequence value will be after it.
+ # KFD 4/11/09 Sourceforge 2753174 Support char/varchar
+ $nextval = "nextval(##". $Seq . "##)";
+ if($formshort=='char' || $formshort=='varchar') {
+ $nextval = "lpad($nextval::varchar,{$row['colprec']},##0##)";
+ }
$s1 =
" -- 1011 sequence assignment\n".
- " IF new.". $column_id . " IS NULL OR new.".$column_id." = 0 THEN \n".
- " new.". $column_id . " = nextval(##". $Seq . "##);\n".
+ " IF new.". $column_id . " IS NULL OR new.".$column_id."::int = 0 THEN \n".
+ " new.". $column_id . " = $nextval;\n".
+ " ELSE\n".
+ " AnyInt = nextval(##$Seq##);\n".
+ " IF AnyInt < new.$column_id::int THEN\n".
+ " perform setval(##$Seq##,new.$column_id::int);\n".
+ " ELSE\n".
+ " perform setval(##$Seq##,AnyInt-1);\n".
+ " END IF;\n".
" END IF;\n";
$this->SpecDDL_TriggerFragment($table_id,"INSERT","BEFORE","1011",$s1);
@@ -6779,12 +6801,17 @@
$this->PlanMake_Security();
// 11/27/06, fix all sequences so they are always safe
- $res=$this->SQLRead("Select table_id,column_id FROM zdd.tabflat
+ $res=$this->SQLRead("Select table_id,column_id,formshort FROM zdd.tabflat
Where automation_id in ('SEQUENCE','SEQDEFAULT')");
while ($row=pg_fetch_array($res)) {
$tid=$row['table_id'];
$cid=$row['column_id'];
$seq=$tid."_SEQ_".$cid;
+ # KFD 4/11/09 Sourceforge 2753174, support char/varchar for
+ # SEQUENCE and SEQDEFAULT
+ if(in_array(trim($row['formshort']),array('char','varchar'))) {
+ $cid.='::int';
+ }
$sq="SELECT SETVAL(#$seq#,(SELECT MAX($cid) FROM $tid)+1)";
$this->PlanMakeEntry("6050",$sq);
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ken...@us...> - 2009-04-13 19:21:07
|
Revision: 1348
http://andro.svn.sourceforge.net/andro/?rev=1348&view=rev
Author: kendowns
Date: 2009-04-13 19:20:57 +0000 (Mon, 13 Apr 2009)
Log Message:
-----------
Slight change to char/varchar support for SEQUENCE/SEQDEFAULT
Modified Paths:
--------------
trunk/andro/application/androBuild.php
Modified: trunk/andro/application/androBuild.php
===================================================================
--- trunk/andro/application/androBuild.php 2009-04-13 18:19:07 UTC (rev 1347)
+++ trunk/andro/application/androBuild.php 2009-04-13 19:20:57 UTC (rev 1348)
@@ -3595,12 +3595,14 @@
# make sure next sequence value will be after it.
# KFD 4/11/09 Sourceforge 2753174 Support char/varchar
$nextval = "nextval(##". $Seq . "##)";
+ $compare = '0';
if($formshort=='char' || $formshort=='varchar') {
- $nextval = "lpad($nextval::varchar,{$row['colprec']},##0##)";
+ $nextval = "lpad($nextval::varchar,{$row['colprec']},##0##)";
+ $compare = '####';
}
$s1 =
" -- 1011 sequence assignment\n".
- " IF new.". $column_id . " IS NULL OR new.".$column_id."::int = 0 THEN \n".
+ " IF new.". $column_id . " IS NULL OR new.".$column_id." = $compare THEN \n".
" new.". $column_id . " = $nextval;\n".
" ELSE\n".
" AnyInt = nextval(##$Seq##);\n".
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ken...@us...> - 2009-04-15 22:35:22
|
Revision: 1351
http://andro.svn.sourceforge.net/andro/?rev=1351&view=rev
Author: kendowns
Date: 2009-04-15 22:35:08 +0000 (Wed, 15 Apr 2009)
Log Message:
-----------
Sourceforge 2766496
Modified Paths:
--------------
trunk/andro/application/androBuild.php
Modified: trunk/andro/application/androBuild.php
===================================================================
--- trunk/andro/application/androBuild.php 2009-04-15 16:00:09 UTC (rev 1350)
+++ trunk/andro/application/androBuild.php 2009-04-15 22:35:08 UTC (rev 1351)
@@ -4327,12 +4327,19 @@
// little piece is sequenced. Notice for delete cascade we put it
// at the front, so if there are any complex chains, they will all
// be worked out before the rest of the trigger fires.
+ # KFD 4/15/09 Sourceforge 2766496 Moved delete cascade from before to
+ # after. This is rather counter-intuitive, but if the
+ # delete is in the BEFORE, and the child table has a SUM
+ # or some other reason to update the parent, the parent row
+ # is never actually deleted. Only the children are. And
+ # postgres says, "Query executed, 0 rows affected."
+ # If you move the child delete to the AFTER, it works.
if ($this->zzArray($ufk,"delete_cascade")=="Y") {
$prntList = str_replace("chd.","",$prntList);
$s1 = "\n".
" -- 6000 FK Delete cascades to child rows \n".
" DELETE FROM ".$ufk["table_id_chd"]. " WHERE ".$prntList."; \n";
- $this->SpecDDL_TriggerFragment($ptab,"DELETE","BEFORE","0005",$s1);
+ $this->SpecDDL_TriggerFragment($ptab,"DELETE","AFTER","6000",$s1);
}
else {
$s1 = "\n".
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|