pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Aggregate binary AND
3+ messages / 3 participants
[nested] [flat]

* Aggregate binary AND
@ 2001-11-01 17:16  James Orr <james@lrgmail.com>
  0 siblings, 2 replies; 3+ messages in thread

From: James Orr @ 2001-11-01 17:16 UTC (permalink / raw)
  To: pgsql-sql

Hi,

Is there an aggregate binary AND function in postgres?  If not, is there a
way to write your own aggregate functions?  Examples?

- James




^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: Aggregate binary AND
@ 2001-11-01 18:09  Philip Hallstrom <philip@adhesivemedia.com>
  parent: James Orr <james@lrgmail.com>
  1 sibling, 0 replies; 3+ messages in thread

From: Philip Hallstrom @ 2001-11-01 18:09 UTC (permalink / raw)
  To: James Orr <james@lrgmail.com>; +Cc: pgsql-sql

This worked for us in 7.something (don't need it anymore, but it should
still work).

You'll want to create one for INT8, INT2, etc.. if you are going to use
those as well...

CREATE AGGREGATE aggr_bitand ( BASETYPE = INT4, SFUNC1 = int4and, STYPE1 =
INT4);

On Thu, 1 Nov 2001, James Orr wrote:

> Hi,
>
> Is there an aggregate binary AND function in postgres?  If not, is there a
> way to write your own aggregate functions?  Examples?
>
> - James
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 5: Have you checked our extensive FAQ?
>
> http://www.postgresql.org/users-lounge/docs/faq.html
>




^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: Aggregate binary AND
@ 2001-11-01 19:01  Tom Lane <tgl@sss.pgh.pa.us>
  parent: James Orr <james@lrgmail.com>
  1 sibling, 0 replies; 3+ messages in thread

From: Tom Lane @ 2001-11-01 19:01 UTC (permalink / raw)
  To: James Orr <james@lrgmail.com>; +Cc: pgsql-sql

"James Orr" <james@lrgmail.com> writes:
> Is there an aggregate binary AND function in postgres?  If not, is there a
> way to write your own aggregate functions?  Examples?

The aggregate would be trivial given an underlying two-argument AND
function to build it from:

regression=# create aggregate booland ( basetype = bool,
regression(# sfunc = booland, stype = bool,
regression(# initcond = 'true' );
ERROR:  AggregateCreate: function 'booland(bool, bool)' does not exist

Unfortunately, it seems no one has bothered to create a functional form
of AND (the keyword-AND operator isn't a function).  I'll leave that
part as an exercise for the student ...

			regards, tom lane



^ permalink  raw  reply  [nested|flat] 3+ messages in thread


end of thread, other threads:[~2001-11-01 19:01 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2001-11-01 17:16 Aggregate binary AND James Orr <james@lrgmail.com>
2001-11-01 18:09 ` Philip Hallstrom <philip@adhesivemedia.com>
2001-11-01 19:01 ` Tom Lane <tgl@sss.pgh.pa.us>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox