pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
plpgsql  and intarray extension;   int[] - int[]  operator does not exist ?
6+ messages / 3 participants
[nested] [flat]

* plpgsql  and intarray extension;   int[] - int[]  operator does not exist ?
@ 2018-11-19 17:12 Day, David <david.day@redcom.com>
  2018-11-19 17:56 ` Re: plpgsql and intarray extension; int[] - int[] operator does not exist ? Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 1 reply; 6+ messages in thread

From: Day, David @ 2018-11-19 17:12 UTC (permalink / raw)
  To: pgsql-general



I have installed the intarray extension installed in the public schema and am attempting to  use this in a plpgsql trigger function from another schema.
When the triggers executes this I get an exception to the effect 

{
    "hint": "No operator matches the given name and argument type(s). You might need to add explicit type casts.",
    "details": null,
    "code": "42883",
    "message": "operator does not exist: integer[] - integer[]"
}

However,  If I write a similar test function and attempt similar array arithmetic successfully from a different schema in a non-trigger function It recognizes the intarray methods.

CREATE OR REPLACE FUNCTION admin.djd_test()
  RETURNS integer[] AS
$BODY$
DECLARE
    _old_tag_ids INTEGER[];
    _new_tag_ids INTEGER[];
   

BEGIN
    _old_tag_ids := ARRAY[1,2,3];
    _new_tag_ids := ARRAY[3,4,5];

    RETURN _old_tag_ids - _new_tag_ids;

END;
$BODY$
  LANGUAGE plpgsql VOLATILE


Of course in the trigger function  the declared int[] arrays  the content is dynamically initialized.
Any suggestions as to why the int[] operations are not understood in the trigger context.?

.
Thanks


Dave Day






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

* Re: plpgsql and intarray extension; int[] - int[] operator does not exist ?
  2018-11-19 17:12 plpgsql  and intarray extension;   int[] - int[]  operator does not exist ? Day, David <david.day@redcom.com>
@ 2018-11-19 17:56 ` Tom Lane <tgl@sss.pgh.pa.us>
  2018-11-19 19:38   ` RE: plpgsql and intarray extension; int[] - int[] operator does not exist ? Day, David <david.day@redcom.com>
  2018-11-19 20:34   ` Re: plpgsql and intarray extension; int[] - int[] operator does not exist ? Merlin Moncure <mmoncure@gmail.com>
  0 siblings, 2 replies; 6+ messages in thread

From: Tom Lane @ 2018-11-19 17:56 UTC (permalink / raw)
  To: Day, David <david.day@redcom.com>; +Cc: pgsql-general

"Day, David" <david.day@redcom.com> writes:
> Any suggestions as to why the int[] operations are not understood in the trigger context.?

The search_path in the trigger probably doesn't include public.
You could add a "SET search_path = whatever" clause to the trigger
function definition to ensure it runs with a predictable path.

			regards, tom lane




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

* RE: plpgsql and intarray extension; int[] - int[] operator does not exist ?
  2018-11-19 17:12 plpgsql  and intarray extension;   int[] - int[]  operator does not exist ? Day, David <david.day@redcom.com>
  2018-11-19 17:56 ` Re: plpgsql and intarray extension; int[] - int[] operator does not exist ? Tom Lane <tgl@sss.pgh.pa.us>
@ 2018-11-19 19:38   ` Day, David <david.day@redcom.com>
  1 sibling, 0 replies; 6+ messages in thread

From: Day, David @ 2018-11-19 19:38 UTC (permalink / raw)
  To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: pgsql-general

Tom

I was thinking something similar after finding that my test function recreated in the problematic schema would execute correctly
As one user-role but not another and that they had different search_path settings.

After adding public to search patch for that role all was good.

The error message "no operator matches the given name and argument type....." does not make me easily come around to a search path issue.
In any event thanks much for the assistance.


Issue resolved.


Dave




-----Original Message-----
From: Tom Lane [mailto:tgl@sss.pgh.pa.us] 
Sent: Monday, November 19, 2018 12:56 PM
To: Day, David <david.day@redcom.com>
Cc: pgsql-general@postgresql.org
Subject: Re: plpgsql and intarray extension; int[] - int[] operator does not exist ?

"Day, David" <david.day@redcom.com> writes:
> Any suggestions as to why the int[] operations are not understood in the trigger context.?

The search_path in the trigger probably doesn't include public.
You could add a "SET search_path = whatever" clause to the trigger function definition to ensure it runs with a predictable path.

			regards, tom lane





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

* Re: plpgsql and intarray extension; int[] - int[] operator does not exist ?
  2018-11-19 17:12 plpgsql  and intarray extension;   int[] - int[]  operator does not exist ? Day, David <david.day@redcom.com>
  2018-11-19 17:56 ` Re: plpgsql and intarray extension; int[] - int[] operator does not exist ? Tom Lane <tgl@sss.pgh.pa.us>
@ 2018-11-19 20:34   ` Merlin Moncure <mmoncure@gmail.com>
  2018-11-19 22:36     ` Re: plpgsql and intarray extension; int[] - int[] operator does not exist ? Tom Lane <tgl@sss.pgh.pa.us>
  1 sibling, 1 reply; 6+ messages in thread

From: Merlin Moncure @ 2018-11-19 20:34 UTC (permalink / raw)
  To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: david.day@redcom.com; pgsql-general

On Mon, Nov 19, 2018 at 11:56 AM Tom Lane <tgl@sss.pgh.pa.us> wrote:
>
> "Day, David" <david.day@redcom.com> writes:
> > Any suggestions as to why the int[] operations are not understood in the trigger context.?
>
> The search_path in the trigger probably doesn't include public.
> You could add a "SET search_path = whatever" clause to the trigger
> function definition to ensure it runs with a predictable path.

Might be worth considering:
SET LOCAL search_path = whatever

So that LOCAL makes the change local to the transaction.

merlin




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

* Re: plpgsql and intarray extension; int[] - int[] operator does not exist ?
  2018-11-19 17:12 plpgsql  and intarray extension;   int[] - int[]  operator does not exist ? Day, David <david.day@redcom.com>
  2018-11-19 17:56 ` Re: plpgsql and intarray extension; int[] - int[] operator does not exist ? Tom Lane <tgl@sss.pgh.pa.us>
  2018-11-19 20:34   ` Re: plpgsql and intarray extension; int[] - int[] operator does not exist ? Merlin Moncure <mmoncure@gmail.com>
@ 2018-11-19 22:36     ` Tom Lane <tgl@sss.pgh.pa.us>
  2018-11-19 23:06       ` Re: plpgsql and intarray extension; int[] - int[] operator does not exist ? Merlin Moncure <mmoncure@gmail.com>
  0 siblings, 1 reply; 6+ messages in thread

From: Tom Lane @ 2018-11-19 22:36 UTC (permalink / raw)
  To: Merlin Moncure <mmoncure@gmail.com>; +Cc: david.day@redcom.com; pgsql-general

Merlin Moncure <mmoncure@gmail.com> writes:
> On Mon, Nov 19, 2018 at 11:56 AM Tom Lane <tgl@sss.pgh.pa.us> wrote:
>> The search_path in the trigger probably doesn't include public.
>> You could add a "SET search_path = whatever" clause to the trigger
>> function definition to ensure it runs with a predictable path.

> Might be worth considering:
> SET LOCAL search_path = whatever
> So that LOCAL makes the change local to the transaction.

What I was suggesting was to create the trigger function using

create function ... as $$ ...body... $$ set search_path = whatever;

That makes the setting local to each function call.

			regards, tom lane




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

* Re: plpgsql and intarray extension; int[] - int[] operator does not exist ?
  2018-11-19 17:12 plpgsql  and intarray extension;   int[] - int[]  operator does not exist ? Day, David <david.day@redcom.com>
  2018-11-19 17:56 ` Re: plpgsql and intarray extension; int[] - int[] operator does not exist ? Tom Lane <tgl@sss.pgh.pa.us>
  2018-11-19 20:34   ` Re: plpgsql and intarray extension; int[] - int[] operator does not exist ? Merlin Moncure <mmoncure@gmail.com>
  2018-11-19 22:36     ` Re: plpgsql and intarray extension; int[] - int[] operator does not exist ? Tom Lane <tgl@sss.pgh.pa.us>
@ 2018-11-19 23:06       ` Merlin Moncure <mmoncure@gmail.com>
  0 siblings, 0 replies; 6+ messages in thread

From: Merlin Moncure @ 2018-11-19 23:06 UTC (permalink / raw)
  To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: david.day@redcom.com; pgsql-general

On Mon, Nov 19, 2018 at 4:36 PM Tom Lane <tgl@sss.pgh.pa.us> wrote:
>
> Merlin Moncure <mmoncure@gmail.com> writes:
> > On Mon, Nov 19, 2018 at 11:56 AM Tom Lane <tgl@sss.pgh.pa.us> wrote:
> >> The search_path in the trigger probably doesn't include public.
> >> You could add a "SET search_path = whatever" clause to the trigger
> >> function definition to ensure it runs with a predictable path.
>
> > Might be worth considering:
> > SET LOCAL search_path = whatever
> > So that LOCAL makes the change local to the transaction.
>
> What I was suggesting was to create the trigger function using
>
> create function ... as $$ ...body... $$ set search_path = whatever;
>
> That makes the setting local to each function call.

Oh, I see.  Yes, that's even better.

merlin




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


end of thread, other threads:[~2018-11-19 23:06 UTC | newest]

Thread overview: 6+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2018-11-19 17:12 plpgsql  and intarray extension;   int[] - int[]  operator does not exist ? Day, David <david.day@redcom.com>
2018-11-19 17:56 ` Re: plpgsql and intarray extension; int[] - int[] operator does not exist ? Tom Lane <tgl@sss.pgh.pa.us>
2018-11-19 19:38   ` RE: plpgsql and intarray extension; int[] - int[] operator does not exist ? Day, David <david.day@redcom.com>
2018-11-19 20:34   ` Re: plpgsql and intarray extension; int[] - int[] operator does not exist ? Merlin Moncure <mmoncure@gmail.com>
2018-11-19 22:36     ` Re: plpgsql and intarray extension; int[] - int[] operator does not exist ? Tom Lane <tgl@sss.pgh.pa.us>
2018-11-19 23:06       ` Re: plpgsql and intarray extension; int[] - int[] operator does not exist ? Merlin Moncure <mmoncure@gmail.com>

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