Bug 809444 - spacewalk-hostname-rename @postrgesql fails (SQL syntax error)
Summary: spacewalk-hostname-rename @postrgesql fails (SQL syntax error)
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: Spacewalk
Classification: Community
Component: Clients
Version: 1.7
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Milan Zázrivec
QA Contact: Red Hat Satellite QA List
URL:
Whiteboard:
: 842153 (view as bug list)
Depends On:
Blocks: 820123 space18
TreeView+ depends on / blocked
 
Reported: 2012-04-03 11:54 UTC by Lukas Pramuk
Modified: 2012-11-01 16:18 UTC (History)
3 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
: 820123 (view as bug list)
Environment:
Last Closed: 2012-11-01 16:18:02 UTC
Embargoed:


Attachments (Terms of Use)

Description Lukas Pramuk 2012-04-03 11:54:05 UTC
Description of problem:
Against postgresql spacewalk the "spacewalk-hostname-rename" command fails with SQL syntax error. It seems that it uses same sql code for both oracle and postgres.


Version-Release number of selected component (if applicable):
spacewalk-utils-1.7.15-1.el6.noarch
spacewalk-schema-1.7.55-1.el6.noarch

How reproducible: always


Steps to Reproduce:
1.spacewalk-hostname-rename <ip>

  
Actual results:
spacewalk-hostname-rename fails, error msg printed

Expected results:
spacewalk-hostname-rename succeeds, no errors

Additional info:
spacewalk-hostname-rename x.x.x.x
Validating IP ... OK
=============================================
hostname: fqdn
ip: x.x.x.x
=============================================
Stopping rhn-satellite services ... OK
Testing DB connection ... Running: psql -U spaceuser -d spaceschema -v ON_ERROR_STOP=ON -f - -h localhost -p 5432
psql:<stdin>:1: ERROR:  syntax error at or near "off"
LINE 1: set feed off;
                 ^
FAILED
Your database isn't running.
Fix the problem and run /usr/bin/spacewalk-hostname-rename again

Comment 1 Milan Zázrivec 2012-04-03 14:25:58 UTC
spacewalk.git master: af92a3dd2101a0b9759ad63f8abfd138089d5c2f

Comment 3 Paul Robert Marino 2012-04-04 16:10:50 UTC
I ran into this too
Its the QUIT commands in the sql statments that break it.

This diff should break the script in the right so it will work for you.
copy the script into your home directory and apply this diff with the patch command

It disables the database running check and gets rid of the "QUIT" statements which is the only Oracle specific syntax in the functional portion of the code.
unfortunately it will produce errors about the client closing the connection unexpectedly however that's not a really serious problem however i wouldn't try to put it into the core repo because of it. 



--- spacewalk-hostname-rename.orig      2012-04-04 11:49:42.063065418 -0400
+++ spacewalk-hostname-rename   2012-04-04 11:57:35.000096385 -0400
@@ -331,7 +331,6 @@
 UPDATE rhn_sat_cluster SET vip = '$IP' WHERE public_key LIKE '${NOCPULSE_OLD_PUBLIC_KEY}%';
 UPDATE rhn_sat_node SET ip = '$IP' WHERE EXISTS (SELECT 1 FROM rhn_sat_cluster RSC WHERE RSC.public_key LIKE '${NOCPULSE_OLD_PUBLIC_KEY}%' AND sat_cluster_id = RSC.recid);
 COMMIT;
-QUIT
 EOS
 }

@@ -417,7 +416,7 @@
 "  | spacewalk-sql --select-mode -
 )
 # SQL_RET="${SQL_RET#"${SQL_RET%%[![:space:]]*}"}"
-print_status "${SQL_RET}" "Your database isn't running."
+#print_status "${SQL_RET}" "Your database isn't running."

 echo -n "Updating /etc/rhn/rhn.conf ... " | tee -a $LOG
 update_rhn_conf
@@ -450,7 +449,6 @@
 UPDATE rhn_config_macro SET definition='$HOSTNAME' WHERE name='RHN_SAT_HOSTNAME';
 UPDATE rhn_config_macro SET definition='$HOSTNAME' WHERE name='MDOM';
 COMMIT;
-QUIT
 EOS
     print_status 0  # just simulate end
 fi
@@ -479,7 +477,6 @@
 spacewalk-sql --select-mode - >>$LOG <<EOS
 UPDATE rhntemplatestring SET value='$HOSTNAME' WHERE label='hostname';
 COMMIT;
-QUIT
 EOS
 print_status 0  # just simulate end

@@ -493,7 +490,6 @@
 spacewalk-sql --select-mode - >>$LOG <<EOS
 DELETE FROM rhnPushDispatcher WHERE hostname != '$HOSTNAME';
 COMMIT;
-QUIT
 EOS

 for jabber_config_file in c2s.xml s2s.xml sm.xml

Comment 5 Jan Pazdziora 2012-07-22 20:41:45 UTC
*** Bug 842153 has been marked as a duplicate of this bug. ***

Comment 6 Jan Pazdziora 2012-10-30 19:22:59 UTC
Moving ON_QA. Packages that address this bugzilla should now be available in yum repos at http://yum.spacewalkproject.org/nightly/

Comment 7 Jan Pazdziora 2012-11-01 16:18:02 UTC
Spacewalk 1.8 has been released: https://fedorahosted.org/spacewalk/wiki/ReleaseNotes18


Note You need to log in before you can comment on or make changes to this bug.