Hi,

Am Montag, 28. November 2011, 18:18:31 schrieb Miroslav Suchy:
> Dne 28.11.2011 17:33, Michael Calmer napsal(a):
> > 0004-replace-synonyms-with-real-table-names-and-change-sy.patch
> >
> >
> >  From ab387975796b4b04a4ccab2cd600f01d0b69db2a Mon Sep 17 00:00:00 2001
> > From: Michael Calmer<m...@suse.de>
> > Date: Mon, 28 Nov 2011 16:30:11 +0100
> > Subject: [PATCH 4/6] replace synonyms with real table names and change
> > sysdate to current_timestamp
> 
> Hmm I would be happy to apply that part with s/sysdate/current_timestamp/
> 
> But I have problem with that alias. Why replacing it only in one file. 
> It is presented in other files as well. I would welcome to remove it in 
> all files or keep it as is.

Attached are now 4 patches. One with only the sysdate=>current_timestamp
and 3 with synonym replaces.

There are some other files uses synonyms, but it seems they are not part of a 
package (only available in git). So maybe a candidate to remove them?

monitoring/SputLite/lib/FetchCommands.pm
monitoring/SputLite/lib/UploadResults.pm
monitoring/SputLite/lib/CommandQueue.pm
monitoring/tsdb/cull_deleted_ts_sc_files

-- 
Regards

        Michael Calmer

--------------------------------------------------------------------------
Michael Calmer
SUSE LINUX Products GmbH, Maxfeldstr. 5, D-90409 Nuernberg
T: +49 (0) 911 74053 0
F: +49 (0) 911 74053575  - e-mail: michael.cal...@suse.com
--------------------------------------------------------------------------
SUSE LINUX Products GmbH, GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer
HRB 16746 (AG Nürnberg)
From 6651001519ecd1b657a63d22d0dead7c7f21952a Mon Sep 17 00:00:00 2001
From: Michael Calmer <m...@suse.de>
Date: Tue, 29 Nov 2011 17:55:01 +0100
Subject: [PATCH 1/4] replace sysdate with current_timestamp

---
 monitoring/PerlModules/NP/OracleDB/CF_DB.pm |   22 +++++++++++-----------
 1 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/monitoring/PerlModules/NP/OracleDB/CF_DB.pm b/monitoring/PerlModules/NP/OracleDB/CF_DB.pm
index 4d25b0d..032c109 100644
--- a/monitoring/PerlModules/NP/OracleDB/CF_DB.pm
+++ b/monitoring/PerlModules/NP/OracleDB/CF_DB.pm
@@ -100,7 +100,7 @@ sub CQ_Commands {
     $idnum = $rv->[0]->[0];
     unshift(@$whereclauses, '?');
     unshift(@$bindvars, $idnum);
-    push(@$whereclauses, sprintf("'%s'", $self->username), 'sysdate');
+    push(@$whereclauses, sprintf("'%s'", $self->username), 'current_timestamp');
 
   } elsif ($action eq 'select') {
 
@@ -158,7 +158,7 @@ sub CQ_Instances {
     $idnum = $rv->[0]->[0];
     unshift(@$whereclauses, '?');
     unshift(@$bindvars, $idnum);
-    push(@$whereclauses, 'sysdate', sprintf("'%s'", $self->username), 'sysdate');
+    push(@$whereclauses, 'current_timestamp', sprintf("'%s'", $self->username), 'current_timestamp');
 
   } elsif ($action eq 'select') {
 
@@ -212,7 +212,7 @@ sub CQ_Execs {
 
   } elsif ($action eq 'insert') {
 
-    push(@$whereclauses, 'sysdate');
+    push(@$whereclauses, 'current_timestamp');
 
   } elsif ($action eq 'select') {
 
@@ -289,7 +289,7 @@ sub CQ_Sessions {
 
   } elsif ($action eq 'insert') {
 
-    push(@$whereclauses, sprintf("'%s'", $self->username), 'sysdate');
+    push(@$whereclauses, sprintf("'%s'", $self->username), 'current_timestamp');
 
   } elsif ($action eq 'select') {
 
@@ -350,7 +350,7 @@ sub Customer {
     $idnum = $rv->[0]->[0];
     unshift(@$whereclauses, '?');
     unshift(@$bindvars, $idnum);
-    push(@$whereclauses, sprintf("'%s'", $self->username), 'sysdate');
+    push(@$whereclauses, sprintf("'%s'", $self->username), 'current_timestamp');
 
   } elsif ($action eq 'select') {
 
@@ -411,7 +411,7 @@ sub Netsaint {
     $idnum = $rv->[0]->[0];
     unshift(@$whereclauses, '?');
     unshift(@$bindvars, $idnum);
-    push(@$whereclauses, sprintf("'%s'", $self->username), 'sysdate');
+    push(@$whereclauses, sprintf("'%s'", $self->username), 'current_timestamp');
 
   } elsif ($action eq 'select') {
 
@@ -477,7 +477,7 @@ sub Node {
     $idnum = $rv->[0]->[0];
     unshift(@$whereclauses, '?');
     unshift(@$bindvars, $idnum);
-    push(@$whereclauses, sprintf("'%s'", $self->username), 'sysdate');
+    push(@$whereclauses, sprintf("'%s'", $self->username), 'current_timestamp');
 
   } elsif ($action eq 'select') {
 
@@ -580,7 +580,7 @@ sub Contact {
     $idnum = $rv->[0]->[0];
     unshift(@$whereclauses, '?');
     unshift(@$bindvars, $idnum);
-    push(@$whereclauses, sprintf("'%s'", $self->username), 'sysdate');
+    push(@$whereclauses, sprintf("'%s'", $self->username), 'current_timestamp');
 
   } elsif ($action eq 'select') {
 
@@ -820,7 +820,7 @@ sub getUnexpiredCQ_Execs_by_instance_netsaint {
   my @where    = ("netsaint_id = ?", 
                   "instance_id = ?",
 		  "instance_id = ins.recid",
-		  "expiration_date > sysdate");
+		  "expiration_date > current_timestamp");
 
   my @bind     = ($nsid, $iid); 
 
@@ -962,7 +962,7 @@ sub getUnexpiredCQ_SessionBySessionId {
 
   my($dataref, $ordref) = 
     $self->CQ_Sessions('select', ['session_id = ?', 
-                                  'expiration_date > sysdate'], [$sid]);
+                                  'expiration_date > current_timestamp'], [$sid]);
 
   # This query should only return one row, so just return the record.
   if (scalar(@$ordref)) {
@@ -1419,7 +1419,7 @@ sub get_sysdate {
 #################
   my $self = shift();
 
-  my $statement = sprintf("SELECT TO_CHAR(sysdate, '%s') as current_time FROM dual",$self->dateformat);
+  my $statement = sprintf("SELECT TO_CHAR(current_timestamp, '%s') as current_time FROM dual",$self->dateformat);
   my $ref       = $self->dbexec($statement);
 
   return $ref->[0]->[0];
-- 
1.7.3.4

From 22bbd8ff5c0c16e4208e86b9aa9fcce96f1c8482 Mon Sep 17 00:00:00 2001
From: Michael Calmer <m...@suse.de>
Date: Tue, 29 Nov 2011 17:56:21 +0100
Subject: [PATCH 2/4] replace synonyms with real table names

---
 monitoring/PerlModules/NP/OracleDB/CF_DB.pm |   20 ++++++++++----------
 1 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/monitoring/PerlModules/NP/OracleDB/CF_DB.pm b/monitoring/PerlModules/NP/OracleDB/CF_DB.pm
index 032c109..43a109b 100644
--- a/monitoring/PerlModules/NP/OracleDB/CF_DB.pm
+++ b/monitoring/PerlModules/NP/OracleDB/CF_DB.pm
@@ -80,7 +80,7 @@ sub CQ_Commands {
   my $bindvars      = shift || [];
   my $orderby       = shift || [];
 
-  my $table  = "COMMAND_QUEUE_COMMANDS";
+  my $table  = "RHN_COMMAND_QUEUE_COMMANDS";
   my $idseq  = "COMMAND_Q_COMMAND_RECID_SEQ.NEXTVAL";
   my $keycol = 'RECID';
   my @cols   = qw(RECID            DESCRIPTION
@@ -140,7 +140,7 @@ sub CQ_Instances {
   my $bindvars      = shift || [];
   my $orderby       = shift || [];
 
-  my $table  = "COMMAND_QUEUE_INSTANCES";
+  my $table  = "RHN_COMMAND_QUEUE_INSTANCES";
   my $idseq  = "COMMAND_Q_INSTANCE_RECID_SEQ.NEXTVAL";
   my $keycol = 'RECID';
   my @cols   = qw(RECID            COMMAND_ID          NOTES            
@@ -197,7 +197,7 @@ sub CQ_Execs {
   my $bindvars      = shift || [];
   my $orderby       = shift || [];
 
-  my $table  = "COMMAND_QUEUE_EXECS";
+  my $table  = "RHN_COMMAND_QUEUE_EXECS";
   my $keycol = 'INSTANCE_ID,NETSAINT_ID';
   my @cols   = qw(INSTANCE_ID      NETSAINT_ID       TARGET_TYPE
                   DATE_ACCEPTED    DATE_EXECUTED     
@@ -243,7 +243,7 @@ sub CQ_Params {
   my $bindvars      = shift || [];
   my $orderby       = shift || [];
 
-  my $table  = "COMMAND_QUEUE_PARAMS";
+  my $table  = "RHN_COMMAND_QUEUE_PARAMS";
   my $keycol = 'INSTANCE_ID,ORD';
   my @cols   = qw(INSTANCE_ID ORD VALUE);
 
@@ -278,7 +278,7 @@ sub CQ_Sessions {
   my $bindvars      = shift || [];
   my $orderby       = shift || [];
 
-  my $table  = "COMMAND_QUEUE_SESSIONS";
+  my $table  = "RHN_COMMAND_QUEUE_SESSIONS";
   my $keycol = 'CONTACT_ID';
   my @cols   = qw(CONTACT_ID SESSION_ID EXPIRATION_DATE
                   LAST_UPDATE_USER LAST_UPDATE_DATE);
@@ -329,7 +329,7 @@ sub Customer {
   my $bindvars      = shift || [];
   my $orderby       = shift || [];
 
-  my $table  = 'CUSTOMER';
+  my $table  = 'RHN_CUSTOMER_MONITORING';
   my $idseq  = 'CUSTOMER_RECID_SEQ.NEXTVAL';
   my $keycol = 'RECID';
 
@@ -390,7 +390,7 @@ sub Netsaint {
   my $bindvars      = shift || [];
   my $orderby       = shift || [];
 
-  my $table  = 'SAT_CLUSTER';
+  my $table  = 'RHN_SAT_CLUSTER';
   my $idseq  = 'COMMAND_TARGET_RECID_SEQ.NEXTVAL';
   my $keycol = 'RECID';
 
@@ -513,7 +513,7 @@ sub LL_Netsaint {
   my $bindvars      = shift || [];
   my $orderby       = shift || [];
 
-  my $table  = 'LL_NETSAINT';
+  my $table  = 'RHN_LL_NETSAINT';
   my $keycol = 'NETSAINT_ID';
   my @cols   = qw(NETSAINT_ID CITY);
   my $idnum;
@@ -551,7 +551,7 @@ sub Contact {
   my $bindvars      = shift || [];
   my $orderby       = shift || [];
 
-  my $table  = "CONTACT";
+  my $table  = "RHN_CONTACT_MONITORING";
   my $idseq  = "CONTACT_RECID_SEQ";
   my $keycol = 'RECID';
   my @cols   = qw( RECID                       CUSTOMER_ID
@@ -813,7 +813,7 @@ sub getUnexpiredCQ_Execs_by_instance_netsaint {
   my $nsid    = shift;
   my $orderby = shift;
 
-  my $tables   = "command_queue_instances ins,command_queue_execs exec";
+  my $tables   = "rhn_command_queue_instances ins,rhn_command_queue_execs exec";
 
   my @execcols = (map("exec.$_", $self->CQ_Execs('columns')));
 
-- 
1.7.3.4

From e18951f63e7f5df44ca0f6c5ee9ed39dfd3f300c Mon Sep 17 00:00:00 2001
From: Michael Calmer <m...@suse.de>
Date: Tue, 29 Nov 2011 15:51:10 +0100
Subject: [PATCH 4/4] replace synonyms with real table name

---
 .../SatConfig/SNMPAlerts/fetch_snmp_alerts.cgi     |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/monitoring/SatConfig/SNMPAlerts/fetch_snmp_alerts.cgi b/monitoring/SatConfig/SNMPAlerts/fetch_snmp_alerts.cgi
index fe851ec..fce191c 100755
--- a/monitoring/SatConfig/SNMPAlerts/fetch_snmp_alerts.cgi
+++ b/monitoring/SatConfig/SNMPAlerts/fetch_snmp_alerts.cgi
@@ -32,7 +32,7 @@ sub satellitemenu {
   my $menu = "<SELECT SIZE=10 NAME='$name'>\n";
 
   my $satref = SatClusterRecord->LoadFromSql(
-                                  "SELECT * FROM sat_cluster", 'RECID');
+                                  "SELECT * FROM rhn_sat_cluster", 'RECID');
   my $satsort = sub {
     $_[0]->{'CUSTOMER_ID'} <=> $_[1]->{'CUSTOMER_ID'} 
     or
-- 
1.7.3.4

From 91c2f24b688d5f14c11dacf383f18171d29c64c6 Mon Sep 17 00:00:00 2001
From: Michael Calmer <m...@suse.de>
Date: Tue, 29 Nov 2011 14:56:38 +0100
Subject: [PATCH 3/4] replace synonyms with real table names

---
 .../SputLite/html/cgi-bin/create_commands.cgi      |   82 ++++++++++----------
 1 files changed, 41 insertions(+), 41 deletions(-)

diff --git a/monitoring/SputLite/html/cgi-bin/create_commands.cgi b/monitoring/SputLite/html/cgi-bin/create_commands.cgi
index de88aec..4340fb3 100755
--- a/monitoring/SputLite/html/cgi-bin/create_commands.cgi
+++ b/monitoring/SputLite/html/cgi-bin/create_commands.cgi
@@ -936,31 +936,31 @@ sub show_history {
   my @order_selects1 = map { $count++; /sat_node/i ? "NULL as order$count" :  "$_ as order$count" } @order_selects;
   $count=0;
   @order_selects     = map { $count++; "$_ as order$count" } @order_selects;
-  my $iid_line       =  'command_queue_execs.INSTANCE_ID as iid';
+  my $iid_line       =  'rhn_command_queue_execs.INSTANCE_ID as iid';
   $select1 .= join(",\n",@selects1,$iid_line,@order_selects1);
   $select2 .= join(",\n",@selects,$iid_line,@order_selects);
 
   # from
-  my $from1 = "\nFROM\ncommand_queue_commands,\ncommand_queue_execs,\ncommand_queue_instances,\ncustomer,\nsat_cluster";
-  my $from2 = $from1 . ",\nsat_node\n";
+  my $from1 = "\nFROM\nrhn_command_queue_commands,\nrhn_command_queue_execs,\nrhn_command_queue_instances,\nrhn_customer_monitoring,\nrhn_sat_cluster";
+  my $from2 = $from1 . ",\nrhn_sat_node\n";
   $from1   .= "\n";
 
 # standard where clause
   my $where = "
-AND  sat_cluster.customer_id = customer.recid
-AND  command_queue_execs.instance_id = command_queue_instances.recid 
-AND  command_queue_instances.command_id = command_queue_commands.recid\n";
+AND  rhn_sat_cluster.customer_id = customer.recid
+AND  rhn_command_queue_execs.instance_id = rhn_command_queue_instances.recid
+AND  rhn_command_queue_instances.command_id = rhn_command_queue_commands.recid\n";
 
 # clusters
 my $where1 = 
-"AND  sat_cluster.recid = command_queue_execs.netsaint_id 
-AND command_queue_execs.target_type = 'cluster'\n";
+"AND  rhn_sat_cluster.recid = rhn_command_queue_execs.netsaint_id
+AND rhn_command_queue_execs.target_type = 'cluster'\n";
 
 # nodes
 my $where2 = 
-"AND sat_node.recid = command_queue_execs.netsaint_id 
-AND command_queue_execs.target_type = 'node'
-AND sat_node.sat_cluster_id = sat_cluster.recid\n";
+"AND rhn_sat_node.recid = rhn_command_queue_execs.netsaint_id
+AND rhn_command_queue_execs.target_type = 'node'
+AND rhn_sat_node.sat_cluster_id = rhn_sat_cluster.recid\n";
   
   # additional where clauses for user's search criteria
   foreach (1..5) {
@@ -1670,36 +1670,36 @@ sub exec_query_menu {
   my $blank = $params{'blank'};  #empty first field
 
   my %fields = ( 
-    'command line'            => 'command_queue_commands.COMMAND_LINE',
-    'command description'     => 'command_queue_commands.DESCRIPTION',
-    'command effective group' => 'command_queue_commands.EFFECTIVE_GROUP',
-    'command effective user'  => 'command_queue_commands.EFFECTIVE_USER',
-    'command notes'           => 'command_queue_commands.NOTES',
-    'command is permanent'    => 'command_queue_commands.PERMANENT',
-    'command id'              => 'command_queue_commands.RECID',
-    'date accepted'           => 'command_queue_execs.DATE_ACCEPTED',
-    'date executed'           => 'command_queue_execs.DATE_EXECUTED',
-    'execution time'          => 'command_queue_execs.EXECUTION_TIME',
-    'exit status'             => 'command_queue_execs.EXIT_STATUS',
-    'instance id'             => 'command_queue_execs.INSTANCE_ID',
-    'stderr'                  => 'command_queue_execs.STDERR',
-    'stdout'                  => 'command_queue_execs.STDOUT',
-    'target type'             => 'command_queue_execs.TARGET_TYPE',
-    'date submitted'          => 'command_queue_instances.DATE_SUBMITTED',
-    'expiration date'         => 'command_queue_instances.EXPIRATION_DATE',
-    'instance notes'          => 'command_queue_instances.NOTES',
-    'notify_email'            => 'command_queue_instances.NOTIFY_EMAIL',
-    'timeout'                 => 'command_queue_instances.TIMEOUT',
-    'customer is deleted'     => 'customer.DELETED',
-    'customer description'    => 'customer.DESCRIPTION',
-    'customer type'           => 'customer.TYPE',
-    'customer id'             => 'sat_cluster.CUSTOMER_ID',
-    'sat cluster description' => 'sat_cluster.DESCRIPTION',
-    'sat cluster id'          => 'sat_cluster.RECID',
-    'sat cluster is deployed' => 'sat_cluster.DEPLOYED',
-    'sat node ip'             => 'sat_node.IP',
-    'sat node mac'            => 'sat_node.MAC_ADDRESS',
-    'sat node recid'          => 'sat_node.RECID',
+    'command line'            => 'rhn_command_queue_commands.COMMAND_LINE',
+    'command description'     => 'rhn_command_queue_commands.DESCRIPTION',
+    'command effective group' => 'rhn_command_queue_commands.EFFECTIVE_GROUP',
+    'command effective user'  => 'rhn_command_queue_commands.EFFECTIVE_USER',
+    'command notes'           => 'rhn_command_queue_commands.NOTES',
+    'command is permanent'    => 'rhn_command_queue_commands.PERMANENT',
+    'command id'              => 'rhn_command_queue_commands.RECID',
+    'date accepted'           => 'rhn_command_queue_execs.DATE_ACCEPTED',
+    'date executed'           => 'rhn_command_queue_execs.DATE_EXECUTED',
+    'execution time'          => 'rhn_command_queue_execs.EXECUTION_TIME',
+    'exit status'             => 'rhn_command_queue_execs.EXIT_STATUS',
+    'instance id'             => 'rhn_command_queue_execs.INSTANCE_ID',
+    'stderr'                  => 'rhn_command_queue_execs.STDERR',
+    'stdout'                  => 'rhn_command_queue_execs.STDOUT',
+    'target type'             => 'rhn_command_queue_execs.TARGET_TYPE',
+    'date submitted'          => 'rhn_command_queue_instances.DATE_SUBMITTED',
+    'expiration date'         => 'rhn_command_queue_instances.EXPIRATION_DATE',
+    'instance notes'          => 'rhn_command_queue_instances.NOTES',
+    'notify_email'            => 'rhn_command_queue_instances.NOTIFY_EMAIL',
+    'timeout'                 => 'rhn_command_queue_instances.TIMEOUT',
+    'customer is deleted'     => 'rhn_customer_monitoring.DELETED',
+    'customer description'    => 'rhn_customer_monitoring.DESCRIPTION',
+    'customer type'           => 'rhn_customer_monitoring.TYPE',
+    'customer id'             => 'rhn_sat_cluster.CUSTOMER_ID',
+    'sat cluster description' => 'rhn_sat_cluster.DESCRIPTION',
+    'sat cluster id'          => 'rhn_sat_cluster.RECID',
+    'sat cluster is deployed' => 'rhn_sat_cluster.DEPLOYED',
+    'sat node ip'             => 'rhn_sat_node.IP',
+    'sat node mac'            => 'rhn_sat_node.MAC_ADDRESS',
+    'sat node recid'          => 'rhn_sat_node.RECID',
   );
 
   my $namekey = $name;
-- 
1.7.3.4

_______________________________________________
Spacewalk-devel mailing list
Spacewalk-devel@redhat.com
https://www.redhat.com/mailman/listinfo/spacewalk-devel

Reply via email to