[Bucardo-general] Sync of fields with user-function as default, Sync of XML fields
Franz Dürr
info at fduerr.de
Wed Sep 1 13:05:15 UTC 2010
Dear list,
I'm new to Bucardo, so please have mercy..
I'm using Bucardo 4.4.0 and PostgreSQL 9.0B4 (problems are not related
to pg version, imho)
I'm trying to swap-sync the following table :
CREATE TABLE ado_event (
id SERIAL PRIMARY KEY,
usr_id CHAR(4) NOT NULL DEFAULT public.client_user_id(),
attr XML
)
I encountered 2 problems:
1. The user function 'client_user_id()' used for DEFAULT is seen by MCP
with schema for the master db, e.g. public.client_user_id() and without
schema for the remote db, e.g. public.client_user_id(), although the
same schema was used to generate them. I tried to create the table
without schema
'e.g. .. DEFAULT client_user_id()' too, no change.
log.bucardo:
[Tue Aug 31 19:59:59 2010] MCP Warning: Source database for sync
"ado_sync" has column "usr_id" of table "crm.ado_event" with a DEFAULT
of "public.client_user_id()", but target database "remote" has a DEFAULT
of "client_user_id()"
[Tue Aug 31 19:59:59 2010] MCP Validation of sync ado_sync FAILED
I got rid of this problem by stripping off the schema 'public.'
altogether in Bucardo.pm around line 2040:
## Fatal in strict mode: DEFAULT exists but does not match
if ($scol->{atthasdef} and $fcol->{atthasdef} and $scol->{def} ne
$fcol->{def}) {
## Make an exception for Postgres versions returning DEFAULT
parenthesized or not
## e.g. as "-5" in 8.2 or as "(-5)" in 8.3
my $scol_def = $scol->{def};
my $fcol_def = $fcol->{def};
for ($scol_def, $fcol_def) {
s/\A\(//;
s/\)\z//;*
s/\Apublic\.//; # Patch: strip off 'public'-schema*
}
While this is not perfect ($scol->{def} and $fcol->{def} shouldn't
differ in the first place), it fixes my problem
2. The attr - field crashes, as there is no equal-operator for XML.
This obviouly means, that you can't sync XML-fields..
log.bucardo:
[Tue Aug 31 20:34:23 2010] KID Kid exiting at cleanup_kid. Reason:
DBD::Pg::st execute failed: ERROR: could not identify an equality
operator for type xml
LINE 3: ...usr_id AS usr_id,attr AS at...
^ at
/usr/share/perl5/Bucardo.pm line 4433.
main error: none source error: 7 target error: none States:/42883/
[Tue Aug 31 20:34:23 2010] KID Removed pid file
"/var/run/bucardo/bucardo.kid.sync.ado_sync.local.pid"
[Tue Aug 31 20:34:32 2010] CTL Rows updated child 28179 to aborted in q: 1
[Tue Aug 31 20:34:32 2010] CTL Warning! Kid 28179 seems to have died.
Sync "ado_sync"
I tried to supply an equal operator for the xml-type in schemes 'public'
and 'bucardo', but to no avail:
CREATE OR REPLACE FUNCTION public.eq_xml_xml(XML, XML) RETURNS BOOLEAN AS
'SELECT CAST($1 AS TEXT)=CAST($2 AS TEXT);' LANGUAGE SQL IMMUTABLE;
DROP OPERATOR IF EXISTS public.= (XML,XML);
CREATE OPERATOR public.=
(LEFTARG=XML,RIGHTARG=XML,PROCEDURE=public.eq_xml_xml,COMMUTATOR= = );
DROP OPERATOR IF EXISTS bucardo.= (XML,XML);
CREATE OPERATOR bucardo.=
(LEFTARG=XML,RIGHTARG=XML,PROCEDURE=public.eq_xml_xml,COMMUTATOR= = );
Does DBD ignore user defined operators or am i using the wrong schema?
I'm stuck at this point and would greatly appreciate any help
Reagrds
-------------- next part --------------
An HTML attachment was scrubbed...
URL: https://mail.endcrypt.com/pipermail/bucardo-general/attachments/20100901/20f91caf/attachment.html
More information about the Bucardo-general
mailing list