MIN not defined for OID types
MIN not defined for OID types
От:
Roland Roberts <roberts@panix.com>
Дата:
-----BEGIN PGP SIGNED MESSAGE-----
select min(oid) from pg_class;
ERROR: function min(oid) does not exist
I got this surprise while trying to optimize a hack for the PostgreSQL
functions in Keystone (http://www.stonekeep.com/keystone).
roland
-----BEGIN PGP SIGNATURE-----
Version: 2.6.2
Comment: Processed by Mailcrypt 3.4, an Emacs/PGP interface
iQCVAwUBNfCGxuoW38lmvDvNAQGA5AP9FkTlbxQlr1jWUASnLPIG7A2/mk0U3eRa
9mSGts7EorIfqK3swSiU8DoTQ4TkfA7JKqe6SCG0MbLpkD9a8ZhsSO50LzbJuBdb
gURS3VFUH8ETuB1aKj67TgngNkO9gJkNOpv3HwD1BgdMBj2sb5aCMHsI5wkjKEC2
GIiOlcvk0Go=
=Et3z
-----END PGP SIGNATURE-----
--
Roland B. Roberts, PhD Custom Software Solutions
roberts@panix.com 101 West 15th St #4NN
New York, NY 10011
Re: [HACKERS] MIN not defined for OID types
От:
Bruce Momjian <maillist@candle.pha.pa.us>
Дата:
-- Start of PGP signed section. > > select min(oid) from pg_class; > ERROR: function min(oid) does not exist > > I got this surprise while trying to optimize a hack for the PostgreSQL > functions in Keystone (http://www.stonekeep.com/keystone). > Is this in 6.4 or 6.3.2? I think 6.4 may be able to do this, and if not, perhaps Thomas can add it. Sounds like a good use for binary-compatable operators. Thomas, can we delete the old operators now that the binary compatable stuff works? Just an idea, not sure if it is do-able. -- Bruce Momjian | 830 Blythe Avenue maillist@candle.pha.pa.us | Drexel Hill, Pennsylvania 19026 + If your life is a hard drive, | (610) 353-9879(w) + Christ can be your backup. | (610) 853-3000(h)
Re: [HACKERS] MIN not defined for OID types
От:
"Thomas G. Lockhart" <lockhart@alumni.caltech.edu>
Дата:
> > select min(oid) from pg_class;
> > ERROR: function min(oid) does not exist
> > I got this surprise while trying to optimize a hack for the
> > PostgreSQL functions in Keystone
> > (http://www.stonekeep.com/keystone).
> Is this in 6.4 or 6.3.2? I think 6.4 may be able to do this, and if
> not, perhaps Thomas can add it. Sounds like a good use for
> binary-compatable operators.
> Thomas, can we delete the old operators now that the binary compatable
> stuff works? Just an idea, not sure if it is do-able.
It is do-able, but I'm not sure it is desirable. If there is an exact
function or operator match, then that would be preferred, right? The
"binary-compatible" is a cheat to help performance and to allow us to
not have to define _every_ possible combination of functions and
operators. So it's helped on some things, but probably shouldn't become
the only mechanism. For one thing, if you change the underlying
implementation of a type, then it would not longer be binary compatible
with a second one, and you would need the explicit functions and
operators anyway.
I didn't change any of the type matching behavior of the aggregate
functions that I can recall. Maybe I should have; if I have time I'll
look at it. That would probably be better than bothering to implement
something explicitly for oids:
postgres=> select min(oid) from foo;
ERROR: No such function 'min' with the specified attributes
Also, it's a bit hard to get too excited about a missing feature to
allow someone to "optimize a hack" Isn't that like "patching a patch" or
"fixing a repair"? :)
- Tom
Re: [HACKERS] MIN not defined for OID types
От:
Bruce Momjian <maillist@candle.pha.pa.us>
Дата:
> It is do-able, but I'm not sure it is desirable. If there is an exact > function or operator match, then that would be preferred, right? The > "binary-compatible" is a cheat to help performance and to allow us to > not have to define _every_ possible combination of functions and > operators. So it's helped on some things, but probably shouldn't become > the only mechanism. For one thing, if you change the underlying > implementation of a type, then it would not longer be binary compatible > with a second one, and you would need the explicit functions and > operators anyway. > > I didn't change any of the type matching behavior of the aggregate > functions that I can recall. Maybe I should have; if I have time I'll > look at it. That would probably be better than bothering to implement > something explicitly for oids: > > postgres=> select min(oid) from foo; > ERROR: No such function 'min' with the specified attributes OK. A question. Aren't oid's unsigned int, while int4 is signed. How does binary compatable indexes handle this. Do oid's grater than 2gig work with the int4 indexes? Do negative integers work with oid indexes? -- Bruce Momjian | 830 Blythe Avenue maillist@candle.pha.pa.us | Drexel Hill, Pennsylvania 19026 + If your life is a hard drive, | (610) 353-9879(w) + Christ can be your backup. | (610) 853-3000(h)
Re: [HACKERS] MIN not defined for OID types
От:
"Thomas G. Lockhart" <lockhart@alumni.caltech.edu>
Дата:
> Aren't oid's unsigned int, while int4 is signed. How
> does binary compatable indexes handle this. Do oid's grater than 2gig
> work with the int4 indexes? Do negative integers work with oid indexes?
Good point. I have specified that OIDs are binary compatible with ints,
and in cases where the types mix and there are not explicit
operators/functions then the OIDs and ints are evaluated as signed
quantities.
At the moment, I don't see this as a _big_ problem, in that formerly the
_only_ way of specifying OIDs above 2^^31 in size was to use the
"stringified" syntax of
OID '4000000000'
or
'4000000000'::OID
and if one does that now one gets the right thing. All the platforms we
run on use twos-complement integers, so signed and unsigned quantities
below 2^^32-1 are binary equivalent.
But at the least it is sloppy. So perhaps in the future we should have
more explicit functions and operators on OIDs to avoid having to choose
between signed and unsigned evaluation. At that point, we should
probably no longer consider it equivalent to an integer, but rather have
explicit conversion.
When we have indices available for constant functions then the automatic
conversion will work better; I'd made OIDs and int4s equivalent to solve
the problem that
SELECT * FROM foo WHERE oid = 100;
did not use an index on oid even if it were available, but that
SELECT * FROM foo WHERE oid = '100'::oid
did.
- Tom
Re: [HACKERS] MIN not defined for OID types
От:
Roland Roberts <roberts@panix.com>
Дата:
-----BEGIN PGP SIGNED MESSAGE-----
>>>>> "Thomas" == Thomas G Lockhart writes:
Thomas> Also, it's a bit hard to get too excited about a missing
Thomas> feature to allow someone to "optimize a hack" Isn't that
Thomas> like "patching a patch" or "fixing a repair"? :)
Yes, well, in this case, it comes about as a result of trying to make
something database independent. Keystone has functions for both
PostgreSQL and MySQL, and the MySQL way of doing things seems to be
limitation. As a result, the DB-independent code does a "select *
from Re: [HACKERS] MIN not defined for OID types
От:
Roland Roberts <roberts@panix.com>
Дата:
-----BEGIN PGP SIGNED MESSAGE-----
>>>>> "Bruce" == Bruce Momjian writes:
>> select min(oid) from pg_class;
>> ERROR: function min(oid) does not exist
Bruce> Is this in 6.4 or 6.3.2? I think 6.4 may be able to do
Bruce> this, and if not, perhaps Thomas can add it. Sounds like a
Bruce> good use for binary-compatable operators.
This is in 6.3.2 (or rather, min(oid) is not in 6.3.2 :-)
roland
-----BEGIN PGP SIGNATURE-----
Version: 2.6.2
Comment: Processed by Mailcrypt 3.4, an Emacs/PGP interface
iQCVAwUBNfFaO+oW38lmvDvNAQEj0QP/XO4fM0ph1xJ8bMLOS5OpbqQ+CM1g8aua
Sd6QRjRNH2nPQ0lC3EQ+mFK9NoCa/+cA61ZACnhacPCMIwhHM22rxjb91bZstOZC
fhqh0eTrcZ+xcwVL73k7070gOBNQ3CTZHu0Pf74P+sFW3HMMPhUpCAPJrt7WZUbP
xAib5eRh94U=
=aOoU
-----END PGP SIGNATURE-----
--
Roland B. Roberts, PhD Custom Software Solutions
roberts@panix.com 101 West 15th St #4NN
New York, NY 10011
Re: [HACKERS] MIN not defined for OID types
От:
"Thomas G. Lockhart" <lockhart@alumni.caltech.edu>
Дата:
> Yes, well, in this case, it comes about as a result of trying to make > something database independent. Keystone has functions for both > PostgreSQL and MySQL, and the MySQL way of doing things seems to be > limitation. As a result, the DB-independent code does a "select * > from
Re: [HACKERS] MIN not defined for OID types
От:
Roland Roberts <roberts@panix.com>
Дата:
-----BEGIN PGP SIGNED MESSAGE-----
>>>>> "Thomas" == Thomas G Lockhart writes:
Thomas> Ah. Try another hack:
Thomas> SELECT * from