Commit 559a0768 authored by mose's avatar mose

Instant-Auto-Merge from BRANCH-1-9 to HEAD

parent 523f409d
......@@ -659,6 +659,14 @@ tiki/db/dbg_console.sql -text
tiki/db/fulltext.sql -text
tiki/db/index.php -text
tiki/db/local_multi.php -text
tiki/db/oracle/md5.sql -text
tiki/db/pgsql/MigratingFromMySQLtoPostgreSQL.htm -text
tiki/db/pgsql/mysql-functions.sql -text
tiki/db/pgsql/mysql2pgsql.pl -text
tiki/db/pgsql/mysql2pgsql.sh -text
tiki/db/pgsql/psql.log -text
tiki/db/pgsql/tiki_mysql.sql -text
tiki/db/pgsql/tiki_pgsql.sql -text
tiki/db/profiles/BasicEnabled.prf -text
tiki/db/profiles/_default.prf -text
tiki/db/profiles/default-inserts.sql -text
......@@ -719,6 +727,7 @@ tiki/doc/readme.txt -text
tiki/dump/.cvsignore -text
tiki/dump/index.php -text
tiki/favicon.png -text
tiki/function.js_maxlength.php -text
tiki/games/README -text
tiki/games/flash/README -text
tiki/games/flash/index.php -text
......@@ -1387,6 +1396,7 @@ tiki/img/avatars/576.gif -text
tiki/img/avatars/577.gif -text
tiki/img/avatars/578.gif -text
tiki/img/avatars/579.gif -text
tiki/img/avatars/README -text
tiki/img/avatars/index.php -text
tiki/img/background.png -text
tiki/img/clip.gif -text
......@@ -2378,6 +2388,7 @@ tiki/lib/charts/chartlib.php -text
tiki/lib/charts/index.php -text
tiki/lib/chat/chatlib.php -text
tiki/lib/chat/index.php -text
tiki/lib/class.ezpdf.php.exe -text
tiki/lib/class_calendar.php -text
tiki/lib/class_rdf_parser.php -text
tiki/lib/class_rss_parser.php -text
......@@ -2464,6 +2475,62 @@ tiki/lib/irc/index.php -text
tiki/lib/irc/irclib.php -text
tiki/lib/irc/split_logs.php -text
tiki/lib/irc/tikiwiki.php -text
tiki/lib/jHotDraw/ATEXT1.gif -text
tiki/lib/jHotDraw/ATEXT2.gif -text
tiki/lib/jHotDraw/ATEXT3.gif -text
tiki/lib/jHotDraw/BORDDEC1.gif -text
tiki/lib/jHotDraw/BORDDEC2.gif -text
tiki/lib/jHotDraw/BORDDEC3.gif -text
tiki/lib/jHotDraw/CONN1.gif -text
tiki/lib/jHotDraw/CONN2.gif -text
tiki/lib/jHotDraw/CONN3.gif -text
tiki/lib/jHotDraw/DIAMOND2.gif -text
tiki/lib/jHotDraw/DIAMOND3.gif -text
tiki/lib/jHotDraw/ELLIPSE1.gif -text
tiki/lib/jHotDraw/ELLIPSE2.gif -text
tiki/lib/jHotDraw/ELLIPSE3.gif -text
tiki/lib/jHotDraw/ERASER2.gif -text
tiki/lib/jHotDraw/ERASER3.gif -text
tiki/lib/jHotDraw/LINE1.gif -text
tiki/lib/jHotDraw/LINE2.gif -text
tiki/lib/jHotDraw/LINE3.gif -text
tiki/lib/jHotDraw/OCONN1.gif -text
tiki/lib/jHotDraw/OCONN2.gif -text
tiki/lib/jHotDraw/OCONN3.gif -text
tiki/lib/jHotDraw/PERT2.gif -text
tiki/lib/jHotDraw/PERT3.gif -text
tiki/lib/jHotDraw/POLYGON1.gif -text
tiki/lib/jHotDraw/POLYGON2.gif -text
tiki/lib/jHotDraw/POLYGON3.gif -text
tiki/lib/jHotDraw/RECT1.gif -text
tiki/lib/jHotDraw/RECT2.gif -text
tiki/lib/jHotDraw/RECT3.gif -text
tiki/lib/jHotDraw/RRECT1.gif -text
tiki/lib/jHotDraw/RRECT2.gif -text
tiki/lib/jHotDraw/RRECT3.gif -text
tiki/lib/jHotDraw/SCRIBBL1.gif -text
tiki/lib/jHotDraw/SCRIBBL2.gif -text
tiki/lib/jHotDraw/SCRIBBL3.gif -text
tiki/lib/jHotDraw/SEL1.gif -text
tiki/lib/jHotDraw/SEL2.gif -text
tiki/lib/jHotDraw/SEL3.gif -text
tiki/lib/jHotDraw/TEXT1.gif -text
tiki/lib/jHotDraw/TEXT2.gif -text
tiki/lib/jHotDraw/TEXT3.gif -text
tiki/lib/jHotDraw/TOBACK2.gif -text
tiki/lib/jHotDraw/TOBACK3.gif -text
tiki/lib/jHotDraw/TOFRONT2.gif -text
tiki/lib/jHotDraw/TOFRONT3.gif -text
tiki/lib/jHotDraw/TRIANGLE2.gif -text
tiki/lib/jHotDraw/TRIANGLE3.gif -text
tiki/lib/jHotDraw/URL1.gif -text
tiki/lib/jHotDraw/URL2.gif -text
tiki/lib/jHotDraw/URL3.gif -text
tiki/lib/jHotDraw/applettest.html -text
tiki/lib/jHotDraw/example.draw -text
tiki/lib/jHotDraw/example.gif -text
tiki/lib/jHotDraw/example.map -text
tiki/lib/jHotDraw/twikidraw.jar -text
tiki/lib/jgraphpad/index.php -text
tiki/lib/jgraphpad/jgraphpad.jar -text
tiki/lib/jukebox/index.php -text
......@@ -2749,6 +2816,17 @@ tiki/lib/structures/index.php -text
tiki/lib/structures/structlib.php -text
tiki/lib/surveys/index.php -text
tiki/lib/surveys/surveylib.php -text
tiki/lib/tabs/aqua-tab-active.png -text
tiki/lib/tabs/aqua-tab.png -text
tiki/lib/tabs/aqua.css -text svneol=unset#application/octet-stream
tiki/lib/tabs/cookie.js -text svneol=unset#application/octet-stream
tiki/lib/tabs/global.js -text svneol=unset#application/octet-stream
tiki/lib/tabs/index.php -text
tiki/lib/tabs/mozilla.css -text svneol=unset#application/octet-stream
tiki/lib/tabs/tabs.js -text svneol=unset#application/octet-stream
tiki/lib/tabs/utils.js -text svneol=unset#application/octet-stream
tiki/lib/tabs/viewport.js -text svneol=unset#application/octet-stream
tiki/lib/tabs/winxp.css -text svneol=unset#application/octet-stream
tiki/lib/taglines/index.php -text
tiki/lib/taglines/taglinelib.php -text
tiki/lib/tail/index.php -text
......@@ -3618,6 +3696,7 @@ tiki/templates/styles/smartiki/tiki-print_multi_pages.tpl -text
tiki/templates/styles/smartiki/tiki.tpl -text
tiki/templates/styles/specialsauce/tiki.tpl -text
tiki/templates/styles/tiki/error.tpl -text
tiki/templates/styles/tiki/header.tpl -text
tiki/templates/styles/tiki/index.php -text
tiki/templates/styles/tiki/modules/index.php -text
tiki/templates/styles/tiki/modules/mod-application_menu.tpl -text
......
<?php
// $Header: /cvsroot/tikiwiki/tiki/comments.php,v 1.33 2004-06-23 16:59:05 rlpowell Exp $
// $Header: /cvsroot/tikiwiki/tiki/comments.php,v 1.34 2004-06-23 22:33:53 mose Exp $
// Copyright (c) 2002-2004, Luis Argerich, Garland Foster, Eduardo Polidor, et. al.
// All Rights Reserved. See copyright.txt for details and a complete list of authors.
......@@ -103,16 +103,16 @@ $comments_complete_father = $comments_father;
*/
$comments_complete_father = $comments_father . $comments_t_query;
//print("Complete Father: $comments_complete_father<br/>");
//print("Father: $comments_father<br/>");
//print("Complete Father: $comments_complete_father<br />");
//print("Father: $comments_father<br />");
if (strstr($comments_complete_father, "?")) {
$comments_complete_father .= '&amp;';
} else {
$comments_complete_father .= '?';
}
//print("Father: $comments_father<br/>");
//print("Com: $comments_complete_father<br/>");
//print("Father: $comments_father<br />");
//print("Com: $comments_complete_father<br />");
$smarty->assign('comments_father', $comments_father);
$smarty->assign('comments_complete_father', $comments_complete_father);
......@@ -340,7 +340,7 @@ $smarty->assign('comments_style', $_REQUEST["comments_style"]);
$smarty->assign('comments_commentFind', $_REQUEST["comments_commentFind"]);
$smarty->assign('comments_show', $comments_show);
//print("Show: $comments_show<br/>");
//print("Show: $comments_show<br />");
// Offset setting for the list of comments
if (!isset($_REQUEST["comments_offset"])) {
$comments_offset = 0;
......
CREATE OR REPLACE FUNCTION md5(input_string IN VARCHAR2) RETURN VARCHAR2
IS
retval varchar2(32);
BEGIN
SELECT RAWTOHEX(DBMS_OBFUSCATION_TOOLKIT.MD5(INPUT_STRING => input_string)) INTO retval FROM dual;
RETURN retval;
END;
<head>
<title>Migrating from MySQL to PostgreSQL</title>
</head>
<body bgcolor=white text=black>
<table>
<tr>
<td><a
href="http://www.xach.com/photos/gallery/vj/2000-05-30-textures/rtexture07-med.html"><img
src="http://www.xach.com/photos/gallery/2000-05-30-textures/rtexture07-small.jpg"></a></td>
<td><h1>Migrating from MySQL to PostgreSQL</h1>
by <a href="/">Zach Beane</a></td>
</tr>
</table>
<hr>
<!-- <p>I'm <a href="index.html">moving from Apache to AOLserver</a>, and
part of that transition will involve converting my MySQL tables and
queries to something PostgreSQL likes. -->
<h3>The Most Important Thing</h3>
<p>Know SQL. If your only experience with SQL is through MySQL, many
things in PostgreSQL (and indeed, any other database system) will seem
alien and strange. The idioms you may have developed to work with
MySQL may not be the ideal approach when using PostgreSQL. In
particular, you have a set of new tools (views, triggers, stored
procedures, consistency checks, and more) that you should try to take
advantage of.
<p>Get a good book on SQL. <a
href="http://www.amazon.com/exec/obidos/ASIN/0201447878/gimpnews/">The
Practical SQL Handbook</a> is pretty handy. The free online book <a
href="http://www.arsdigita.com/books/sql/">SQL for Web Nerds</a>,
though Oracle-specific, will give you ideas for good idioms.
<h3>Converting Dumps</h3>
<p>So far I've written a <a href="mysql2psql.pl">Perl
script</a> that converts the data model pretty well. It handles enums
(it converts them to varchars with check constraints on the possible
values) and auto_increment fields. It also converts MySQL's integer
and time types to compatible PostgreSQL types.
<p>The script outputs SQL statements that seem to work with CVS
PostgreSQL. The CVS version will eventually become PostgreSQL 7.1.
<p>
<table bgcolor="#CCCCCC" cellspacing=1 cellpadding=3 border=0>
<tr>
<th>MySQL</th>
<th>PostgreSQL</th>
</tr>
<tr>
<td valign=top>
<pre>
create table foo (
id int not null auto_increment primary key,
state enum('enabled', 'disabled')
);
<i>foo's data</i>
</pre>
</td>
<td valign=top>
<pre>
create table foo (
id int not null primary key default nextval('foo_id_seq'),
state varchar(8) check (state in ('enabled', 'disabled'))
);
<i>foo's data</i>
create sequence foo_id_seq;
select setval('foo_id_seq', (select max(id) from foo));
</pre>
</td>
</tr>
</table>
<p>To be handled:
<ul>
<li> timestamp fields, instead of <tt>not null default now()</tt>,
could be handled by a trigger
<li> Secondary key definitions in MySQL to create indexes in
PostgreSQL
</ul>
<p><a href="http://www.rot13.org/~dpavlin/projects.html">Dobrica
Pavlinusic</a> has also written a <a
href="http://www.rot13.org/~dpavlin/projects/sql/mysql2pgsql">mysql2pgsql
Perl script</a>, but it seems to target an older version of
PostgreSQL.
<h3>'Legacy' Statements</h3>
<p>MySQL has some interesting functions that are either unavailable in
PostgreSQL, or supported by functions of slightly different
syntax. For example, <tt>ifnull()</tt> in MySQL is similar to
<tt>coalesce()</tt> in PostgreSQL.
<p>To ease the transition from the MySQL that's embedded in all my
pages, I've created a <a href="mysql-functions.sql">set of SQL
functions</a> that recreate the MySQL functions.
<p>Converted:
<ul>
<li> ifnull
<li> from_unixtime
<li> unix_timestamp
<li> date_format
<li> if
<li> to_days
<li> from_days
</ul>
<h3>Other Stuff</h3>
Some stuff looks like it just can't be handled by implementing MySQL
functions in PostgreSQL. Fundamental differences exist, mainly where
PostgreSQL adheres to the SQL standard and MySQL diverges.
<p>This list isn't an endorsement of MySQL; these examples mainly come
up because MySQL is much less conformant with SQL standards in general.
<ul>
<li> PostgreSQL won't let you use expression aliases in
HAVING in queries. In MySQL it's legal to have something
like this:
<pre>
select name, count(*) as score
from mytable
group by name
having score > 10
</pre>
<p>For PostgreSQL, you have to write out the expression again:
<pre>
select name, count(*) as score
from mytable
group by name
having count(*) > 10
</pre>
<p>It doesn't mind having aliases in ORDER BY, but you can't use it in
HAVING. <a href="mail/names-in-having.txt">Tom Lane explains</a>.
<p><li> PostgreSQL has a compile-time limit of 31 characters for names
(for tables, columns, sequences, functions, etc). If you get a bit
verbose when naming your tables, you have to either truncate them or
build PostgreSQL with a longer name limit.
<p><tt>NAMEDATALEN</tt> is defined in src/include/postgres_ext.h. The
name length is <tt>NAMEDATALEN - 1</tt>.
<p><li> PostgreSQL has something similar to MySQL's auto_increment;
this is in the <a
href="http://www.postgresql.org/docs/faq-english.html#4.16.1">FAQ
under SERIAL</a>.
</ul>
<p><hr>
<a href="mailto:[email protected]"><address>[email protected]</address></a>
--
-- Some functions to transition Mysql SQL to PostgreSQL
--
-- Created: 2000-11-01
-- Last updated: 2003-06-12
--
-- Zachary Beane <[email protected]>
--
-- This file is in the public domain.
--
drop function ifnull (text, text);
create function ifnull (text, text) returns text AS '
select coalesce($1, $2) as result
' language 'sql';
drop function ifnull (int4, int4);
create function ifnull (int4, int4) returns int4 as '
select coalesce($1, $2) as result
' language 'sql';
--
-- from_unixtime
--
-- Takes a seconds-since-the-epoch integer and returns a timestamp
--
drop function from_unixtime(integer);
create function from_unixtime(integer) returns timestamp as '
select abstime($1) as result
' language 'sql';
--
-- unix_timestamp
--
-- Takes a timestamp and returns the seconds-since-the-epoch for it
--
drop function unix_timestamp(timestamp);
create function unix_timestamp(timestamp) returns integer as '
select date_part(''epoch'', $1)::int4 as result
' language 'sql';
--
-- to_days
--
-- Convert a timestamp to an integer representing a day count
--
drop function to_days(timestamp);
create function to_days(timestamp) returns integer as '
select date_part(''day'', $1 - ''0000-01-01'')::int4 as result
' language 'sql';
--
-- from_days
--
-- Convert a day count returned from from_days to a timestamp
--
drop function from_days(integer);
create function from_days(integer) returns timestamp as '
select ''0000-01-02''::timestamp + ($1 || '' days'')::interval as result
' language 'SQL';
--
-- convert_date_format
--
-- Convert mysql's date_format string to a postgresql to_char compatible string
--
-- BE WARNED! If your date format string contains valid to_char
-- substitutions, you will get unexpected results. For example:
--
-- test=# select date_format(now(), '%Y-%m-%d is today.');
-- date_format
-- ----------------------------
-- 2001-04-10 is totuesday .
-- (1 row)
--
-- Since the string "day" is substituted by to_char, it puts today's
-- day name into the output string.
--
drop function convert_date_format(text);
create function convert_date_format(text)
returns text
as '
set old_format $1
array set substitutions {%% %
%M Month
%W Day
%D FMDDth
%Y YYYY
%y YY
%X ""
%x ""
%a Dy
%d DD
%e FMDD
%m MM
%c FMmm
%b Mon
%j DDD
%H HH24
%k FMHH24
%h HH12
%I HH12
%l FMHH12
%i MI
%r {HH12:MI:SS AM}
%T HH24:MI:SS
%S SS
%s SS
%p AM}
# Iterate through characters of $old_format and replace any % escapes.
set string_size [string length $old_format]
set i 0
set new_format ""
while { $i < $string_size } {
set fchar [string index $old_format $i]
if { $fchar == "%" } {
set code [string range $old_format $i [expr $i + 1]]
if [info exists substitutions($code)] {
append new_format $substitutions($code)
incr i
} else {
append new_format $fchar
}
} else {
append new_format $fchar
}
incr i
}
return $new_format
' language 'pltcl';
--
-- date_format
--
-- Produce pretty output for a timestamp
--
drop function date_format(timestamp, text);
create function date_format(timestamp, text)
returns text
as '
select to_char($1, convert_date_format($2))
' language 'sql';
#!/usr/bin/perl -w
# $Id: mysql2pgsql.pl,v 1.4 2004-06-23 22:33:54 mose Exp $
# see http://www.xach.com/aolserver/mysql-to-postgresql.html
# and http://www.xach.com/aolserver/mysql2psql.pl
use strict;
$| = 1;
my $oldfh = select(STDOUT);
select($oldfh);
my $outputfile = $ARGV[1] || "output.sql";
my $table_substitutions_re = "";
my %table_substitutions = ();
print "Reading '$ARGV[0]'\n";
open(IN, "<$ARGV[0]") || die("Can't open '$ARGV[0]': $!");
print "Creating '$outputfile'\n";
open(OUTPUT, ">$outputfile") || die("Can't create '$outputfile': $!");
print OUTPUT '--$' . 'Id$' . "\n";
print OUTPUT "-- Dump of $ARGV[0]\n";
my @sequences;
my %sequence_hash;
my %keys;
my %fields;
my $output_count = 0;
my $table_name;
while (my $sql = <IN>) {
if ($output_count++ % 50 == 0) {
# print ".";
}
if ($sql =~ /^INSERT/) {
print OUTPUT $sql;
next;
}
if ($sql =~ /^--/) {
print OUTPUT "\n";
next;
}
# Convert '#' comments to '--'
$sql =~ s/^#/--/mg;
if ($sql =~ /create table (\S+)/i) {
$table_name = $1;
print OUTPUT $sql;
next;
}
# Clean up the numeric types
$sql =~ s/\b(tiny|medium|big)?int\(\d+\)/integer/;
$sql =~ s/ZEROFILL//;
$sql =~ s/double\(\d+(,\d+)?\)/float8/;
# Clean up the date types
$sql =~ s/\bdate\b/datetime/;
$sql =~ s/\btime\b/datetime/;
$sql =~ s/\btimestamp\(\d+\)/datetime not null default now()/;
$sql =~ s/\bblob\b/text/;
$sql =~ s/\blongblob\b/text/;
$sql =~ s/\btinyblob\b/text/;
# Convert auto-increment primary keys to use sequences
if ($sql =~ /\b(\S+) integer .*auto_increment/i) {
my $column_name = $1;
my $sequence_name = substr($table_name, 0, 27) . '_seq';
my $sequence_save = $sequence_name;
my $i = 2;
while ($sequence_hash{$sequence_name}) {
$sequence_name = $sequence_save . $i++;
}
$sequence_hash{$sequence_name} = 1;
# $sql =~ s/auto_increment/serial/;
$sql =~ s/auto_increment/default nextval('$sequence_name') unique not null/;
push(@sequences, [$sequence_name, $table_name, $column_name]);
}
if ($sql =~ /^\s*(\S+)\s+(.*)/i) {
if ($sql !~ /KEY/ && $sql !~ /^\)/) {
$fields{$table_name}{$1} = $2;
$sql = '"' . $1 . '" ' . $2 . "\n";
}
}
# Convert enums
$sql =~ s/\S+ enum\([^\)]+\)/convert_enums($&)/e;
if ($sql =~ /(.*KEY.*\)),$/i) {
$sql = $1."\n";
}
if ($sql =~ /KEY/i) {
while ($sql =~ /(.*)\(\d+\)(.*)/) {
$sql = $1 . $2 . "\n";
}
}
if ($sql !~ /PRIMARY/ && $sql =~ /KEY\s+\S+\s+\((.*)\)/) {
my $key = $1;
while ($key =~ /(.*)\(\d+\)(.*)/) {
$key = $1 . $2;
}
my @k = split(',', $key);
if (@k) {