diff --git a/contrib/dbmirror/DBMirror.pl b/contrib/dbmirror/DBMirror.pl
index 63b009b68fc2f3148dc6942fb280c90be2cc8170..11a4b29554be9c7a6429adfa1b960ffbc943135f 100755
--- a/contrib/dbmirror/DBMirror.pl
+++ b/contrib/dbmirror/DBMirror.pl
@@ -33,7 +33,7 @@
 # 
 #
 ##############################################################################
-# $PostgreSQL: pgsql/contrib/dbmirror/DBMirror.pl,v 1.10 2004/07/02 00:58:09 joe Exp $ 
+# $PostgreSQL: pgsql/contrib/dbmirror/DBMirror.pl,v 1.11 2006/05/19 02:38:47 momjian Exp $ 
 #
 ##############################################################################
 
@@ -437,7 +437,7 @@ sub mirrorInsert($$$$$) {
       if(defined $recordValues{$column}) {
 	my $quotedValue = $recordValues{$column};
 	$quotedValue =~ s/\\/\\\\/g;
-	$quotedValue =~ s/'/\\'/g;
+	$quotedValue =~ s/'/''/g;
 	$valuesQuery .= "'$quotedValue'";
       }
       else {
@@ -617,7 +617,7 @@ sub mirrorUpdate($$$$$) {
       if(defined $currentValue ) {
 	$quotedValue = $currentValue;
 	$quotedValue =~ s/\\/\\\\/g;
-	$quotedValue =~ s/'/\\'/g;
+	$quotedValue =~ s/'/''/g;
 	$updateQuery .= "'$quotedValue'";
 	}
       else {
@@ -639,7 +639,7 @@ sub mirrorUpdate($$$$$) {
       if(defined $currentValue) {
 	$quotedValue = $currentValue;
 	$quotedValue =~ s/\\/\\\\/g;
-        $quotedValue =~ s/'/\\'/g;
+        $quotedValue =~ s/'/''/g;
 	$updateQuery .= "'$quotedValue'";
       }
       else {
diff --git a/contrib/dbmirror/pending.c b/contrib/dbmirror/pending.c
index f0204f73aaa31ec08929a032e95830357cfa412b..3a405d12702ccbd2d7f8fa65411cf408a30a5178 100644
--- a/contrib/dbmirror/pending.c
+++ b/contrib/dbmirror/pending.c
@@ -1,7 +1,7 @@
 /****************************************************************************
  * pending.c
- * $Id: pending.c,v 1.23 2005/10/15 02:49:04 momjian Exp $
- * $PostgreSQL: pgsql/contrib/dbmirror/pending.c,v 1.23 2005/10/15 02:49:04 momjian Exp $
+ * $Id: pending.c,v 1.24 2006/05/19 02:38:47 momjian Exp $
+ * $PostgreSQL: pgsql/contrib/dbmirror/pending.c,v 1.24 2006/05/19 02:38:47 momjian Exp $
  *
  * This file contains a trigger for Postgresql-7.x to record changes to tables
  * to a pending table for mirroring.
@@ -541,7 +541,7 @@ packageData(HeapTuple tTupleData, TupleDesc tTupleDesc, Oid tableOid,
 			}
 			if (*cpUnFormatedPtr == '\\' || *cpUnFormatedPtr == '\'')
 			{
-				*cpFormatedPtr = '\\';
+				*cpFormatedPtr = *cpUnFormatedPtr;
 				cpFormatedPtr++;
 				iUsedDataBlock++;
 			}
diff --git a/contrib/tsearch2/query.c b/contrib/tsearch2/query.c
index 9be5f451fa8658e6dc92e8be029a0bd24915f492..8ed66460baa9a79ce944be4015e7c7ccd26a7fd3 100644
--- a/contrib/tsearch2/query.c
+++ b/contrib/tsearch2/query.c
@@ -748,7 +748,7 @@ infix(INFIX * in, bool first)
 		{
 			if ( t_iseq(op, '\'') )
 			{
-				*(in->cur) = '\\';
+				*(in->cur) = '\'';
 				in->cur++;
 			}
 			COPYCHAR(in->cur,op);
diff --git a/contrib/tsearch2/tsvector.c b/contrib/tsearch2/tsvector.c
index 0f369bdcb7e88b56b883d1355e4ba78d03030f79..d274f01256e1dad15b5b15c8e02ddd5481c42df2 100644
--- a/contrib/tsearch2/tsvector.c
+++ b/contrib/tsearch2/tsvector.c
@@ -529,7 +529,7 @@ tsvector_out(PG_FUNCTION_ARGS)
 
 				outbuf = (char *) repalloc((void *) outbuf, ++lenbuf);
 				curout = outbuf + pos;
-				*curout++ = '\\';
+				*curout++ = '\'';
 			}
 			while(len--)
 				*curout++ = *curin++;