GnuCash Daily Source Diff
Linas Vepstas
linas@linas.org
Fri, 19 Oct 2001 16:51:37 -0500
On Fri, Oct 19, 2001 at 02:04:34PM -0700, Dave Peticolas was heard to remark:
> > I think that you were trying to fix a bug related to changes to kvp
> > values in multi-user mode. Is this so?
>
> It actually turned up in single-user mode. When deleting a split
> in a transactoin, it would try to delete the kvp frame of the split.
> But the original sql command didn't specify the object type for the
> audit record of the kvp frame
It shouldn't need to, it should have been copied in ...
The INSERT INTO ... SELECT ... construction is essentially a copy
command. The objtype is supposed to be copied from what the
SELECT returned. Several fields, not just the objtype, are supposed
to be copied, including the value of 'data' , 'type', 'num', 'denom',
etc.
> and this
> was causing the query to fail, at least under Postgres 7.0.
Hmmm. Not good. I would hate to have to do the following:
#define CPY_KVP(TYPE) \
{ \
p = stpcpy (p, "INSERT INTO gncKVPValue" TYPE "Trail SELECT '"); \
p = stpcpy (p, sess_str); \
p = stpcpy (p, "' as sessionGuid, datetime('NOW') as date_changed, " \
"'d' as change, objtype as objtype, data as data, type as type, num as
num, denom as denom, "); \
p = stpcpy (p, "* from gncKVPValue" TYPE " WHERE iguid="); \
p = stpcpy (p, iguid_str); \
}
Maybe this is a postgres 7.0 bug ??
If you can reproduce the bug, maybe we should look at it more carefully,
since I can't beleive that its failing to copy the needed data ...
> at the list of object types in event.c and assumed it had to be one of
> those, presumably the type from which the kvp frame came from.
Nahh, the objtype is sort-of bogus, its there only to allow the SQL
equivalent of an object-oriented 'upcast'. SQL is only semi-object-oriented,
and while it allows inheritance, it looses track of the child class during
a downcast. So I store the the type of the child class by hand.
'classtype' might have been a better name.
> But this
> is easy to fix now.
Uhh, will you fix this, or should I ??
--linas
--
pub 1024D/01045933 2001-02-01 Linas Vepstas (Labas!) <linas@linas.org>
PGP Key fingerprint = 8305 2521 6000 0B5E 8984 3F54 64A9 9A82 0104 5933