Re: [Spacewalk-devel] PGPORT Initial porting guidelines.

2009-01-19 Thread Jeff Ortel



Jan Pazdziora wrote:

On Thu, Jan 15, 2009 at 03:36:55PM +0530, Gurjeet Singh wrote:


I am attaching the text file here. Lets discuss the issues here, and
finalize them, before going ahead with the actual modifications.


Thank you for the writeup. Here are my observations.


== Open questions relevant to porting efforts ==
1. Which versions of Oracle are to be supported by Spacewalk?


10g and later.


2. Which versions of Postgres are to be supported by Spacewalk?


8.1.11 (the one in RHEL 5) and later.


Yes, this was confirmed by Satellite Roadmap alignment.

It has been mentioned that there are advantages to using 8.2.  Are there 
differences from a porting standpoint?  Are there features that would 
make the porting easier/different?  Can you summarize the differences 
between 8.1 and 8.1 as it applies to the spacewalk schema/queries and 
our porting effort?





6. Oracle treats {quote}{quote} (empty string) as null, but PG does not.
 So either make the application aware of it, or attach a BEFORE EACH ROW 
trigger on every table which has a char/varchar column, and set 'if 
new.char_col = {quote}{quote}then new.char_col = null'.

 Triggers will not help in cases where app uses results of dynamically computed 
strings.

 occurrences in schema: 17; find ./ -name *.sql | xargs grep \'\' | grep -iv 
values | grep -v rhnFAQ_satdata.sql



Wouldn't it be better to create check that no varchar column in
PostgreSQL has value ''? That way both the application would not be
able to insert those.


Yeah, a trigger to correct this seems too heavy handed.
After running the above find, it seems that most of these (17) really 
don't seem to be affected by different handling of ('') by oracle and pg.


1) ./views/rhnChannelTreeView.sql: '' || c.name 
padded_name,
2) ./views/rhnUserChannelTreeView.sql: '' || c.name 
   padded_name,

3) ./views/rhnHistoryView.sql: '') ||
4) ./views/rhnHistoryView.sql: '' details,
5) ./views/rhnHistoryView.sql: '') ||
6) ./views/rhnHistoryView.sql: '' details,
7) ./views/rhnHistoryView.sql: '') ||
8) ./views/rhnHistoryView.sql: '' details,
9) ./views/rhnSharedChannelTreeView.sql:''||C.NAME AS PADDED_NAME,
10) ./views/rhnOrgChannelTreeView.sql:  '' || c.name 
padded_name,


(1-10) - contrived values and would be the same regardless of which DB, 
right?


11) ./views/rhnActionOverview.sql:(SELECT COUNT(*) FROM 
rhnServerAction WHERE action_id = A.id AND status = 2), -- XXX: don''t 
hard code status here :)
13) /tables/rhnChannel_triggers.sql:   -- this is a really bad way 
of saying if all we''re
14) ./tables/rhnPackage.sql:-- 
possible'' easier


(11-14) - This is just in a comment, doesn't matter.

15) ./procs/label_join.sql: ret := '';
16) ./procs/name_join.sql:  ret := '';
17) ./procs/id_join.sql:ret := '';
18) ./procs/channel_name_join.sql:  ret := '';

May need to look into these further but doesn't seem to be affected by 
pg having different handling of ''.





7. Convert DECODE calls to CASE expressions.
 Although Orafce provides DECODE support, suggestion here is again to modify 
the Oracle code to use CASE expressions for the reason mentioned in point 2.


-1. If Orafce supports this, let's not do more changes than necessary.


+1, let's not do more changes than necessary.




11. ROWID is not supported by Postgres.
 Fortunately, ROWID keyword is used in very few places across the code, so it 
can be easily ported to Postgres by using the result of expression 
'tableoid::varchar || ctid::varchar' as a row identifier. Better still, using a 
Primary or Unique Key instead is recommended.



+1 for the primary / unique keys instead of using rowid.


+1.




12. ROWNUM is not supported by Postgres.
 But LIMIT ... OFFSET clause can be used to achieve the same result.


That however will not work on Oracle. How do you propose handling
these situations where no common syntax exists?


13. Subquery in SET clause of UPDATE command which updates multiple columns is 
not supported in Postgres.
 Syntax supported:
{{{
UPDATE tbl SET col = (SELECT col from tbl2);
}}}

 Syntax not supported:
{{{
UPDATE tbl SET ( col1, col2 ) = (SELECT col1, col2 from tbl2);
}}}


How many occurences of these do we have in the schema?


14. TODO : Mention port from sysdate to CURRENT_TIMESTAMP, and research their 
differences (formatti etc.).


Well, sysdate and current_timestamp are completely different -- they
are of different types. Could you elaborate on the port from
suggestion? Do you want to remove the use of sysdate in the Oracle
code? Can't we just emulate sysdate on PostgreSQL?


The plan is to port the queries to be more ANSI SQL compliant so they 
will work on both databases.  We don't want to have a separate set of 
queries for each database.  However, for queries that can't be modified 
to work for either, we'll need to have a one off but we want these to 
be kept to a 

Re: [Spacewalk-devel] PGPORT Initial porting guidelines.

2009-01-19 Thread Jan Pazdziora
On Mon, Jan 19, 2009 at 12:12:20PM -0500, Jeff Ortel wrote:

 8.1.11 (the one in RHEL 5) and later.

 Yes, this was confirmed by Satellite Roadmap alignment.

 It has been mentioned that there are advantages to using 8.2.  Are there  

The target is 8.1, not 8.2. PostgreSQL in RHEL 5 won't be rebased. And
we do not want to ship our own version of PostgreSQL.

 Even easier, since the plan is to have a separate schema directory tree  
 containing manually maintained .sql files for managing the pg schema, we  
 can just strip syntax not applicable to pg in these files.

I still hope that we can reach a situation when source SQL files that
do not need to be different will not be duplicated in the repository.
Having two trees and remembering to do every change in both sounds
like a mantinenance nightmare to me.

 +1. Especially the monitoring schema makes heavy use of synonyms.
 Getting the schema cleaned up will be a big win.

 I didn't think we still used synonyms (even in the monitoring schema),  
 do we?

We do.

-- 
Jan Pazdziora | adelton at #satellite*, #brno
Satellite Engineering, Red Hat

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


Re: [Spacewalk-devel] PGPORT Initial porting guidelines.

2009-01-15 Thread Devan Goodwin
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On Thu, 15 Jan 2009 15:36:55 +0530
Gurjeet Singh gurjeet.si...@enterprisedb.com wrote:

 Hi All,
 
 Just finished Wikifying the initial guidelines on how to go about
 porting to Postgres. You can find it here:
 
 https://fedorahosted.org/spacewalk/wiki/PostgresPortingGuidelines
 
 These are my opinions on the issues I could see directly (in
 schema/ or through grepping). There are many places where some debate
 is needed, and then there are some places where core developers can
 help out making decisions based on their knowledge.
 
 I am attaching the text file here. Lets discuss the issues here,
 and finalize them, before going ahead with the actual modifications.
 
 Best regards,

Great guidelines Gurjeet,

We'll have to get Orafce packages into Fedora/EPEL, will we need some
work done to the code itself to run on PostgreSQL 8.1? I think we
discussed that it may require 8.2 currently in some past meetings but I
can't see this clearly indicated in the Orafce webpage.

I'm not really the best qualified to comment on some of the changes you
propose to the existing Oracle schema, but in general I like the idea
of making adjustments if it aids in portability provided they're not
too invasive and wide-sweeping.

The rest looks good to me, nice guidelines. Hopefully others on the
team with more schema background will be able to chime in with some
more feedback.

Thanks,

Devan
-BEGIN PGP SIGNATURE-
Version: GnuPG v2.0.9 (GNU/Linux)

iEYEARECAAYFAklvNWQACgkQAyHWaPV9my5C0QCdGAJoD7lJ5C1U/9yF2kSjtZ6k
AfgAoMnAHg413FtTUi3lE3psMposCx2U
=clUu
-END PGP SIGNATURE-

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