Re: Can user specification of a column value be required when querying a view ?

2023-11-25 Thread Peter J. Holzer
On 2023-11-25 10:49:56 -0500, Ron Johnson wrote: > On Sat, Nov 25, 2023 at 4:49 AM Peter J. Holzer wrote: > On 2023-11-24 13:06:45 -0500, Ron Johnson wrote: > > On Fri, Nov 24, 2023 at 1:01 PM Peter J. Holzer > wrote: > >     On 2023-11-20 22:03:06 -0500, Ron Johnson wrote: > > 

Re: Emitting JSON to file using COPY TO

2023-11-25 Thread Adrian Klaver
On 11/25/23 11:21, Davin Shearer wrote: Hello! I'm trying to emit a JSON aggregation of JSON rows to a file using COPY TO, but I'm running into problems with COPY TO double quoting the output.   Here is a minimal example that demonstrates the problem I'm having: I have tried to get COPY

Re: Emitting JSON to file using COPY TO

2023-11-25 Thread David G. Johnston
On Sat, Nov 25, 2023 at 12:22 PM Davin Shearer wrote: > > Is there a way to emit JSON results to file from within postgres? > Use psql to directly output query results to a file instead of using COPY to output structured output in a format you don't want. David J.

Emitting JSON to file using COPY TO

2023-11-25 Thread Davin Shearer
Hello! I'm trying to emit a JSON aggregation of JSON rows to a file using COPY TO, but I'm running into problems with COPY TO double quoting the output. Here is a minimal example that demonstrates the problem I'm having: create table public.tbl_json_test (id int, t_test text); -- insert text

Re: How to eliminate extra "NOT EXISTS"-query here?

2023-11-25 Thread Andreas Joseph Krogh
På lørdag 25. november 2023 kl. 17:08:28, skrev Tom Lane mailto:t...@sss.pgh.pa.us>>: Andreas Joseph Krogh writes: > -- This works, but I'd rather not do the extra EXISTS > select * from test t > WHERE (NOT ARRAY ['x', 'y', 'z', 't']::varchar[] <@ (select array_agg(s.v) from > stuffs WHERE

Re: How to eliminate extra "NOT EXISTS"-query here?

2023-11-25 Thread hector vass
Not sure you need to use array why not simple table joins, so a table with your criteria x y z t joined to stuff to give you candidates that do match, then left join with coalesce to add the 'd' select --a.id,b.test_id, coalesce(a.id,b.test_id) as finalresult from test a left join ( select

Re: How to eliminate extra "NOT EXISTS"-query here?

2023-11-25 Thread Tom Lane
Andreas Joseph Krogh writes: > -- This works, but I'd rather not do the extra EXISTS > select * from test t > WHERE (NOT ARRAY ['x', 'y', 'z', 't']::varchar[] <@ (select array_agg(s.v) > from > stuffs WHERE s.test_id = t.id) > OR NOT EXISTS ( > select * from stuff s where s.test_id = t.id > ) >

Re: Can user specification of a column value be required when querying a view ?

2023-11-25 Thread Ron Johnson
On Sat, Nov 25, 2023 at 4:49 AM Peter J. Holzer wrote: > On 2023-11-24 13:06:45 -0500, Ron Johnson wrote: > > On Fri, Nov 24, 2023 at 1:01 PM Peter J. Holzer > wrote: > > On 2023-11-20 22:03:06 -0500, Ron Johnson wrote: > > > Or row level security. > > > > Does that help here? AIUI

How to eliminate extra "NOT EXISTS"-query here?

2023-11-25 Thread Andreas Joseph Krogh
Hi, I'm testing if some dataset contains an array of elements and want to return all “not containing the specified array”, including entries in master table not being referenced. I have the following schema: drop table if exists stuff; drop table if exists test; CREATE TABLE test( id

RE: Odd Shortcut behaviour in PG14

2023-11-25 Thread Zahir Lalani
> -Original Message- > From: Tom Lane > Sent: Friday, November 24, 2023 6:44 PM > To: Zahir Lalani > Cc: Ron Johnson ; pgsql- > generallists.postgresql.org > Subject: Re: Odd Shortcut behaviour in PG14 > > OK, so if this is a plpgsql function and ekey is a function variable, the >

Re: Can user specification of a column value be required when querying a view ?

2023-11-25 Thread Peter J. Holzer
On 2023-11-24 13:06:45 -0500, Ron Johnson wrote: > On Fri, Nov 24, 2023 at 1:01 PM Peter J. Holzer wrote: > On 2023-11-20 22:03:06 -0500, Ron Johnson wrote: > > Or row level security. > > Does that help here? AIUI row level security can be used to limit access > to specific rows