From: | stan <stanb(at)panix(dot)com> |
---|---|
To: | "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com> |
Cc: | pgsql-general(at)lists(dot)postgresql(dot)org |
Subject: | Re: Determining the type of an obkect in plperl |
Date: | 2020-03-05 10:59:10 |
Message-ID: | 20200305105910.GA2832@panix.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On Wed, Mar 04, 2020 at 05:09:19PM -0700, David G. Johnston wrote:
> On Wed, Mar 4, 2020 at 4:21 PM stan <stanb(at)panix(dot)com> wrote:
>
> > Probably a bit off topic, but I suspect someone on this list knows how to
> > do
> > this.
> >
> > I am in the process of writing a plperl function. In this function I need
> > to compare the data in the NEW versus OLD structures. I am writing this as
> > a
> > generic subroutine, so I am looping through and comparing the 2 to see what
> > is different. Problem is, that I need to know whether to us n != or a ne
> > comparison.
> >
> > how can I determine what the data type of the value element is?
> >
>
> Not up to speed on Perl but you basically want everything to be done using
> string equality - can't you just use "ne" everywhere and not worry about
> comparing numbers using string comparison logic? Might want to disabled
> warnings...
>
> That would have to be faster than executing a type_of function on every
> single column.
>
> Then measure performance and decide whether a generic routine is performant
> enough. If not you might try creating custom function dynamically using
> the catalogs as input.
Since I am just looking for differences, this may work. Obviously comparing
numeric values as strings has issues.
Presently I am getting some warnings, so I think I need to deal with the
types. I already dealt with the columns that return NULL, these are
undefined in the Perl hash, so I have to test for their existence before
attempting the compare.
--
"They that would give up essential liberty for temporary safety deserve
neither liberty nor safety."
-- Benjamin Franklin
From | Date | Subject | |
---|---|---|---|
Next Message | stan | 2020-03-05 11:03:47 | Re: Determining the type of an obkect in plperl |
Previous Message | Alban Hertroys | 2020-03-05 08:17:41 | Re: Advice request : simultaneous function/data updates on many databases |