Re: Functionally dependent columns in SELECT DISTINCT

2024-09-13 Thread David G. Johnston
> > > > > or use a lateral subquery to surgically (fetch first 1) retrieve the > first row when sorted by recency descending. > > I'm not sure that I see how to apply this when I need top-k, not top-1. > Fetch first k It's just a modern limit clause. David J.

Re: Functionally dependent columns in SELECT DISTINCT

2024-09-13 Thread David G. Johnston
On Friday, September 13, 2024, Willow Chargin wrote: > In reality I really do want the ID columns of the > *most recent* items. > Use a window function to rank them and pull out rank=1, or use a lateral subquery to surgically (fetch first 1) retrieve the first row when sorted by recency descendi

Re: Backward compat issue with v16 around ROLEs

2024-09-12 Thread David G. Johnston
On Thursday, September 12, 2024, Robert Haas wrote: > On Thu, Sep 12, 2024 at 3:40 PM Dominique Devienne > wrote: > > > > Any existing ROLE graph which had "back-edges" (GRANTs) from a ROLE > > back to the ROLE that created it, valid in pre-v16, becomes invalid in > v16+. > > And there's no work

Re: Backward compat issue with v16 around ROLEs

2024-09-11 Thread David G. Johnston
On Wed, Sep 11, 2024, 12:17 Wolfgang Walther wrote: > Dominique Devienne: > > Hi David. I did as you suggested, and it fails the same way. Did I > > misunderstand you? --DD > > > > [..] > > > > ddevienne=> grant dd_owner to dd_admin with admin option; -- > > I think this needs to be the

Re: Backward compat issue with v16 around ROLEs

2024-09-11 Thread David G. Johnston
On Wednesday, September 11, 2024, Dominique Devienne wrote: > > on v16: > > D:\pdgm\trunk\psc2>psql service=pau16 > psql (17beta3, server 16.1) > Type "help" for help. > > ddevienne=> create role dd_owner createrole; > CREATE ROLE > ddevienne=> create role dd_admin noinherit; > CREATE ROLE > ddev

Re: Test mail for pgsql-general

2024-09-10 Thread David G. Johnston
On Tuesday, September 10, 2024, Chris Miller wrote: > Hi Folks, > > I am confused about authentication. I understand that in the local > connection case, I have choices of “peer”, and “md5” (password). > > > In pg_hba.conf, I have the lines: > > > local all all peer > > local all all md5 > > The

Re: Help with "gpg -d ... | pg_restore ..." with unimportant pg_restore errors

2024-09-03 Thread David G. Johnston
On Tuesday, September 3, 2024, raf wrote: > Hi, > > I need help! > > I'm upgrading an ancient (but still awesome) postgresql-9.6.24 (via > EnterpriseDB) > to (a no doubt even more awesome) postgresql-15.8 (via debian (stable) > packages) > but am unable to load database backups that were encrypte

Re: Partitioning and unique key

2024-08-31 Thread David G. Johnston
On Saturday, August 31, 2024, veem v wrote: > > 1) if it's technically possible to have a unique key on only the > transaction_id column having the partition key on the > transaction_timestamp, because the table is going to be queried/purged > based on the transaction_timestamp? > There is prese

Re: default privileges are npt working

2024-08-30 Thread David G. Johnston
On Friday, August 30, 2024, Atul Kumar wrote: > > > I have a postgres instance running on version 15 in centos7. > > I have created a custom database and revoked all public privileges from > that database. > Would be better to provide the actual psql script of what you’ve done instead of writing

Re: PgbackRest : Stanza creation fails on DB Server and Repo Server

2024-08-28 Thread David G. Johnston
On Wednesday, August 28, 2024, Amitabh Kant wrote: > On Wed, Aug 28, 2024 at 8:00 PM David G. Johnston < > david.g.johns...@gmail.com> wrote: > >> On Wednesday, August 28, 2024, KK CHN wrote: >> >>> >>> and I have .pgpass in DB server as >

Re: PgbackRest : Stanza creation fails on DB Server and Repo Server

2024-08-28 Thread David G. Johnston
On Wednesday, August 28, 2024, KK CHN wrote: > > and I have .pgpass in DB server as > You assumed this mattered but I see no mention that pgBackRest consults this file. It seems to require the local entry in pg_hba.conf to use peer authentication. David J.

Re: use of postgres reg* datatypes in user tables?

2024-08-19 Thread David G. Johnston
On Sunday, August 18, 2024, plsqlvids01 plsqlvids01 wrote: > > What kind of data does these data types store - numbers or text? > > https://www.postgresql.org/docs/current/datatype-oid.html They are aliases for oid. David J.

Re: Insert works but fails for merge

2024-08-10 Thread David G. Johnston
On Saturday, August 10, 2024, yudhi s wrote: > > In our case , we were using this merge query in application code(in Java) > as a framework to dynamically take these values as bind values and do the > merge of input data/message. > I’d do most anything before resorting to dynamic SQL. Usually o

Re: Insert works but fails for merge

2024-08-09 Thread David G. Johnston
On Fri, Aug 9, 2024 at 2:14 PM yudhi s wrote: > > Why so? > Because you stuck a CTE in between the column list of the insert - where types are known - and the values command - where types are unknown since you didn't specify them. As the row comes out of the CTE every column must have a known t

Re: How can I get a query-based subtotal in a select using group by rollup ?

2024-08-07 Thread David G. Johnston
On Wednesday, August 7, 2024, dfgpostgres wrote: > > (select > domain_name, > sum(total_tests) as total_tests, > sum(tests_completed) as tests_completed, > sum(tests_passed) as tests_passed, > sum(tests_failed) as tests_failed, > (select count(*) from dispatch_tracker wh

Re: UPDATE-FROM and INNER-JOIN

2024-08-05 Thread David G. Johnston
On Mon, Aug 5, 2024 at 7:36 AM Dominique Devienne wrote: > I'd rather SQLite and PostgreSQL continue to agree on this, > but not in a restrictive way. I.e., you want to support the SQL Server syntax; allow the table named in UPDATE to be repeated, without an alias, in which case it is taken to

Re: UPDATE-FROM and INNER-JOIN

2024-08-05 Thread David G. Johnston
On Monday, August 5, 2024, Dominique Devienne wrote: > In https://sqlite.org/forum/forumpost/df23d80682 > Richard Hipp (Mr SQLite) shows an example of something > that used to be supported by SQLite, but then wasn't, to be > compatible with PostgreSQL. > > Thus I'm curious as to why PostgreSQL re

Re: Some links to "previous version" seem wrong

2024-08-03 Thread David G. Johnston
On Saturday, August 3, 2024, Lele Gaifax wrote: > the page related to > 15.4[2] says > > Also, if you are upgrading from a version earlier than 15.1, see > Section E.7. > > Is that correct? > Yes, the wording and links are correct. If you are upgrading from 15.2 or 15.3 to 15.4 there is no

Re: PQconnect()

2024-07-31 Thread David G. Johnston
On Wed, Jul 31, 2024 at 9:28 AM Igor Korot wrote: > Hi, ALL, > In the https://www.postgresql.org/docs/8.1/libpq.html#LIBPQ-CONNECT > it gives the "options" parameter", but it doesn't specify what options > are available. > > You are looking at the 8.1 docs. Don't do that. Feel free to report ba

Re: Trigger usecase

2024-07-30 Thread David G. Johnston
On Tue, Jul 30, 2024 at 11:46 AM sud wrote: > > Not sure of the exact pros and cons, but we were following certain rules > like , if it's business logic which needs to be implemented in Database, > then it should not be done using triggers but rather should be done through > database procedure/fu

Re: Trigger usecase

2024-07-30 Thread David G. Johnston
On Tue, Jul 30, 2024 at 8:16 AM sud wrote: > > I understand, technically its possible bith the way, but want to > understand experts opinion on this and pros ans cons? > > Have client code call a function that performs the relevant work directly instead of having a trigger perform similar work.

Re: Understanding conflicts on publications and subscriptions

2024-07-30 Thread David G. Johnston
On Tue, Jul 30, 2024 at 7:16 AM Koen De Groote wrote: > And if my understanding is correct: if a table doesn't have a replica > identity, any UPDATE or DELETE statement that happens on the publisher, for > that table, will be refused. > > That is how I read the sentence "Otherwise those operatio

Re: Understanding conflicts on publications and subscriptions

2024-07-30 Thread David G. Johnston
On Tuesday, July 30, 2024, Koen De Groote wrote: > > If the subscriber gets a bit of logic to say "Something went wrong, so I'm > automatically stopping what I'm doing", it sounds logical to give the > publisher the same ability. > The wording for that option is: Specifies whether the subscripti

Re: Regarding vacuum freeze locking mechanism

2024-07-17 Thread David G. Johnston
On Wednesday, July 17, 2024, Durgamahesh Manne wrote: > > Could you please provide more clarity on this? Which lock triggers on the > tables are being used by freeze? > https://www.postgresql.org/docs/current/explicit-locking.html Share update exclusive David J.

Re: Regarding vacuum freeze locking mechanism

2024-07-17 Thread David G. Johnston
On Wednesday, July 17, 2024, Durgamahesh Manne wrote: > when autovacuum runs , it will freeze the transaction ID (TXID) of the > table it's working on. > This statement is incorrect. A table as a whole does not have a txid. Freezing makes it so individual tuples get assigned an always-in-the-pa

Re: Issue with configuration parameter "require_auth"

2024-07-17 Thread David G. Johnston
On Wednesday, July 17, 2024, Gaisford, Phillip wrote: > I am having trouble using require_auth (https://www.postgresql.org/ > docs/16/libpq-connect.html#LIBPQ-CONNECT-REQUIRE-AUTH). > > > > Using golang sqlx.Connect on the client side, the connection fails and my > Postgresql 16 server logs the f

Re: Code does Not Read in FY 2025 Data

2024-07-16 Thread David G. Johnston
On Tue, Jul 16, 2024 at 7:59 AM Anthony Apollis wrote: > I am using Postgres and SQL Server. > Can you test the data pls. > >> >> Well, this is a PostgreSQL community so you should target it with your communications. If you want someone to actually test things here you probably will need to prod

Re: Dropping column from big table

2024-07-15 Thread David G. Johnston
On Monday, July 15, 2024, sud wrote: > > Thank you for the confirmation. > And if someone wants to fully remove that column from the table , then the > only option is to create a new table with an exact set of active columns > and insert the data into that from the existing/old table and then ren

Re: Dropping column from big table

2024-07-15 Thread David G. Johnston
On Monday, July 15, 2024, David G. Johnston wrote: > On Monday, July 15, 2024, sud wrote: > >> >> However even with "vacuum full", the old rows will be removed completely >> from the storage , but the new rows will always be there with the 'dropped' &

Re: Dropping column from big table

2024-07-15 Thread David G. Johnston
On Monday, July 15, 2024, sud wrote: > > However even with "vacuum full", the old rows will be removed completely > from the storage , but the new rows will always be there with the 'dropped' > column still existing under the hood along with the table storage, with > just carrying "null" values

Re: PostgreSQL Active-Active Clustering

2024-07-15 Thread David G. Johnston
On Mon, Jul 15, 2024 at 12:06 PM Sarkar, Subhadeep wrote: > > We are evaluating features of the Community edition of PostgreSQL in > relation to a proposal for a prospective client and need help with the > queries below:- > > > >- Does the Community edition of PostgreSQL provide NATIVE >a

Re: Running psql in a docker container

2024-07-11 Thread David G. Johnston
On Thu, Jul 11, 2024 at 11:16 AM H wrote: > What is the proper syntax for pgsql 16 for this? I could not get the > example given in the docs to work... > The documentation says this still works: su - postgres -c "/usr/pgsql-16/bin/initdb -D /var/lib/pgsql/16/data/ -E 'UTF-8' --lc-collate='en_U

Re: Query on partitioned table needs memory n_partitions * work_mem

2024-07-11 Thread David G. Johnston
On Thursday, July 11, 2024, Dimitrios Apostolou wrote:I wonder how the postgres development community is > > tracking all these issues, I've even started forgetting the ones I have > found, and I'm sure I have previously reported (on this list) a couple of > should-be-easy issues that would be ide

Re: Finding error in long input file

2024-07-10 Thread David G. Johnston
On Wednesday, July 10, 2024, Rich Shepard wrote: > On Wed, 10 Jul 2024, David G. Johnston wrote: > > And what are the first few lines of the file? Use text, not screenshots. >> > > David, > > insert into locations (company_nbr,loc_nbr,loc_name, > addr1,city,state_c

Re: Finding error in long input file

2024-07-10 Thread David G. Johnston
On Wednesday, July 10, 2024, Rich Shepard wrote: > > Partial screenshot attached. And what are the first few lines of the file? Use text, not screenshots. David J.

Re: v16 roles, SET FALSE, INHERIT FALSE, ADMIN FALSE

2024-07-08 Thread David G. Johnston
On Mon, Jul 8, 2024 at 3:58 PM Tom Lane wrote: > I'd argue that INHERIT TRUE should be required. The point of SET TRUE > with INHERIT FALSE is that you must *explicitly* do SET ROLE or > equivalent in order to have access to the privileges of the referenced > role. I think that blast radius is

Re: v16 roles, SET FALSE, INHERIT FALSE, ADMIN FALSE

2024-07-08 Thread David G. Johnston
On Mon, Jul 8, 2024 at 3:08 PM Tom Lane wrote: > "David G. Johnston" writes: > > On Mon, Jul 8, 2024 at 2:16 PM Tom Lane wrote: > >> Pavel Luzanov writes: > > On 08.07.2024 22:22, Christophe Pettus wrote: > >>>> This is more curiosit

Re: v16 roles, SET FALSE, INHERIT FALSE, ADMIN FALSE

2024-07-08 Thread David G. Johnston
On Mon, Jul 8, 2024 at 2:16 PM Tom Lane wrote: > Pavel Luzanov writes: > > On 08.07.2024 22:22, Christophe Pettus wrote: > >> This is more curiosity than anything else. In the v16 role system, is > there actually any reason to grant membership in a role to a different > role, but with SET FALSE

Re: v16 roles, SET FALSE, INHERIT FALSE, ADMIN FALSE

2024-07-08 Thread David G. Johnston
On Monday, July 8, 2024, Christophe Pettus wrote: > > > > On Jul 8, 2024, at 13:29, Christophe Pettus wrote: > > > > > > > >> On Jul 8, 2024, at 13:25, Laurenz Albe > wrote: > >> I didn't test it, but doesn't that allow the member rule to drop > objects owned > >> be the role it is a member of?

Re: v16 roles, SET FALSE, INHERIT FALSE, ADMIN FALSE

2024-07-08 Thread David G. Johnston
On Mon, Jul 8, 2024 at 12:23 PM Christophe Pettus wrote: > > This is more curiosity than anything else. In the v16 role system, is > there actually any reason to grant membership in a role to a different > role, but with SET FALSE, INHERIT FALSE, and ADMIN FALSE? Does the role > granted members

Re: Declaring a field that is also an out parameter in a function

2024-07-07 Thread David G. Johnston
On Sunday, July 7, 2024, Michael Nolan wrote: > On Sun, Jul 7, 2024 at 4:13 AM Pavel Stehule > wrote: > > > > but looks so there are false alarms related to using an alias. It is > interesting so I have not any report about this issue, so probably using > aliases is not too common today. > > I'm

Re: Removing the default grant of EXECUTE on functions/procedures to PUBLIC

2024-07-05 Thread David G. Johnston
On Friday, July 5, 2024, Tefft, Michael J wrote: > I am trying to remove the default grant of EXECUTE on all > functions/procedures to PUBLIC. > > From my reading, there is no straightforward way to do this. For example, > > ALTER DEFAULT PRIVILEGES REVOKE EXECUTE ON FUNCTIONS FROM PUBLIC; > > Do

Re: Design strategy for table with many attributes

2024-07-04 Thread David G. Johnston
On Thursday, July 4, 2024, Lok P wrote: > > But do you also suggest keeping those table pieces related to each other > through the same primary key ? > > Yes, everyone row produced from the input data “row” should get the same ID associated with it - either as an entire PK or a component of a mul

Re: psql help

2024-07-04 Thread David G. Johnston
The convention here is to in-line replies, or bottom-post. Top-posting makes the archives more difficult to read. On Thursday, July 4, 2024, Murthy Nunna wrote: > pg_terminate_backend(pid) will not work as it expects only one pid at a > time. > > > Interesting…I wouldn’t expect the function cal

Re: psql help

2024-07-04 Thread David G. Johnston
On Thu, Jul 4, 2024 at 4:56 PM Murthy Nunna wrote: > > > How can I rewrite the above in psql > The only real trick is using a psql variable instead of the shell-injection of the environment variable. Use the --set CLI argument to assign the environment variable to a psql variable then refer to

Re: JSONPath operator and escaping values in query

2024-07-04 Thread David G. Johnston
On Thu, Jul 4, 2024 at 1:57 PM Vasu Nagendra wrote: > > > SELECT '{"n": {"a-b": 1, "@ab": 2, "ab": 3}}'::jsonb @? '$ ? (@.n.a\-b >= 3)'; > > Which is better written as: select '{"n": {"a-b": 1, "@ab": 2, "ab": 3}}'::jsonb @? '$ ? (@.n."a-b" >= 3)'; Using the same double-quotes you defined the k

Re: Design strategy for table with many attributes

2024-07-04 Thread David G. Johnston
On Thu, Jul 4, 2024 at 12:38 PM Lok P wrote: > > Should we break the single transaction into multiple tables like one main > table and other addenda tables with the same primary key to join and fetch > the results wherever necessary? > > I would say yes. Find a way to logically group sets of col

Re: Accommodating alternative column values

2024-07-03 Thread David G. Johnston
On Wed, Jul 3, 2024 at 7:13 AM Rich Shepard wrote: > On Wed, 3 Jul 2024, David G. Johnston wrote: > > > Yeah, the simply cast suggested will not work. You’d have to apply an > > expression that turns the current contents into an array. The current > > contents are n

Re: Accommodating alternative column values

2024-07-03 Thread David G. Johnston
On Wednesday, July 3, 2024, Rich Shepard wrote: > On Wed, 3 Jul 2024, Rich Shepard wrote: > > What I've tried: >> bustrac=# alter table people alter column email set data type varchar(64) >> []; >> ERROR: column "email" cannot be cast automatically to type character >> varying[] >> HINT: You mi

Re: Accommodating alternative column values

2024-07-03 Thread David G. Johnston
On Wednesday, July 3, 2024, Rich Shepard wrote: > > I'm not using the proper syntax and the postgres alter table doc has no > example in the alter column choices. Simpler syntax forms tend to get skipped over when doing examples. > > How do I incorporate the "USING email::..." string? > ALTE

Re: Logical replication with temporary tables

2024-07-02 Thread David G. Johnston
On Tuesday, July 2, 2024, Stuart Campbell wrote: > This is a question for AWS. Community PostgreSQL doesn't have any of >> these concepts, and this is all proprietary modifications to PostgreSQL by >> Amazon. > > > Maybe my question can be re-summarised as: do DDL operations on temporary > table

Re: dblink Future support vs FDW

2024-06-27 Thread David G. Johnston
On Thursday, June 27, 2024, Dhritman Roy wrote: > > This is my attempt to seek support at PostGreSQL.So, if I have broken any > protocols/rules or violated any code of conduct then please do forgive and > guide me. Thanks. > > The G is not capitalized. > I know we can use FDW but our teams are r

Re: A way to optimize sql about the last temporary-related row

2024-06-27 Thread David G. Johnston
On Thursday, June 27, 2024, aghart...@gmail.com wrote: > > Now the query: > explain (verbose, buffers, analyze) > with last_table_ids as materialized( > select xx from ( > select LAST_VALUE(pk_id) over (partition by integer_field_2 order by > datetime_field_1 RANGE BETWEEN UNBOUNDED PRECEDING

Re: current_role of caller of a DEFINER function

2024-06-26 Thread David G. Johnston
On Wednesday, June 26, 2024, Dominique Devienne wrote: > Only session_user > is representative of the caller, and reliable (modulo SUPERUSER and > SET AUTHORIZATION, but that's a different story and kinda normal) > Why can you not use session_user then? David J.

Re: Issue with pgstattuple on Sequences in PostgreSQL

2024-06-24 Thread David G. Johnston
On Monday, June 24, 2024, Ayush Vatsa wrote: > > I was recently exploring the pgstattuple code directory and found this > piece of code: https://github.com/postgres/postgres/blob/master/contrib/ > pgstattuple/pgstattuple.c#L255-L259. > > It indicates that pgstattuple supports relations, toast tabl

Re: Execute permission to function

2024-06-24 Thread David G. Johnston
On Monday, June 24, 2024, arun chirappurath wrote: > > However they can't execute functions > Community PG at least gives the public pseudo-role permission to execute all functions it can see (i.e., schema access permitted). But no, there is no predefined role that enables that function executi

Re: How to use createdb command with newly created user?

2024-06-23 Thread David G. Johnston
On Sun, Jun 23, 2024, 11:43 毛毛 wrote: > Hi, > > I tried to create a user with CREATEDB permission. > Then I wanted to run command line tool `createdb` with this newly created > user. > > So I ran SQL first to create a user: > > ``` > CREATE USER Baba WITH PASSWORD 'xxx' CREATEDB; > ``` > > Then I

Re: pg_dump restores as expected on some machines and reports duplicate keys on others

2024-06-22 Thread David G. Johnston
On Saturday, June 22, 2024, David G. Johnston wrote: > On Saturday, June 22, 2024, Shaheed Haque wrote: >> >> >>- The one difference I can think of between deployment pairs which >>work ok, and those which fail is that the logic VM (i.e. where the psql >&

Re: pg_dump restores as expected on some machines and reports duplicate keys on others

2024-06-22 Thread David G. Johnston
On Saturday, June 22, 2024, Shaheed Haque wrote: > > >- The one difference I can think of between deployment pairs which >work ok, and those which fail is that the logic VM (i.e. where the psql >client script runs) is the use of a standard AWS ubuntu image for the OK >case, versus

Re: RowDescription for a function does not include table OID

2024-06-21 Thread David G. Johnston
On Fri, Jun 21, 2024 at 8:51 AM Tom Lane wrote: > > The PG wire protocol specification [1] defines these fields thus: > > If the field can be identified as a column of a specific > table, the object ID of the table; otherwise zero. > > If the field can be identified as a c

Re: RowDescription for a function does not include table OID

2024-06-21 Thread David G. Johnston
On Fri, Jun 21, 2024 at 8:41 AM Maxwell Dreytser < maxwell.dreyt...@assistek.com> wrote: > On Friday, June 21, 2024 11:28 AM David G. Johnston < > david.g.johns...@gmail.com> wrote: > > > In short, the system doesn't generate the information you need, where &g

Re: RowDescription for a function does not include table OID

2024-06-21 Thread David G. Johnston
On Fri, Jun 21, 2024 at 8:04 AM Maxwell Dreytser < maxwell.dreyt...@assistek.com> wrote: > On Friday, June 21, 2024 10:48 AM David G. Johnston < > david.g.johns...@gmail.com>wrote: > > >Yes, but the bug is yours. The definition you want is: RETURNS SETOF > phy

Re: RowDescription for a function does not include table OID

2024-06-21 Thread David G. Johnston
On Fri, Jun 21, 2024 at 7:42 AM Maxwell Dreytser < maxwell.dreyt...@assistek.com> wrote: > I am working on a meta-programming use-case where I need to scrape some > detailed information about the results of a function that "RETURNS TABLE > (LIKE physical_table)" > Yes, but the bug is yours. The

Re: Transaction issue

2024-06-19 Thread David G. Johnston
On Wed, Jun 19, 2024 at 5:16 PM Adrian Klaver wrote: > > > > > You hallucinated a dash in front of the bustrac. psql bustract is a > > perfectly valid psql command. User gets inferred from the OS user. > > As in?: > > psql -d test -U postgres bustrac > Well no, that is the specification of -U

Re: Transaction issue

2024-06-19 Thread David G. Johnston
On Wednesday, June 19, 2024, Adrian Klaver wrote: > On 6/19/24 14:33, Rich Shepard wrote: > >> On Wed, 19 Jun 2024, Adrian Klaver wrote: >> >> I should have added to previous post: >>> What is the exact command string you are using to launch psql? >>> >> >> $ psql bustrac >> > > I find it difficu

Re: Transaction issue

2024-06-19 Thread David G. Johnston
On Wed, Jun 19, 2024, 11:38 Rich Shepard wrote: > On Wed, 19 Jun 2024, David G. Johnston wrote: > > > Simplest process, after rollback you fix the problem and start again from > > the top of the transaction. > > David, > > That's what I thought I was doing w

Re: Transaction issue

2024-06-19 Thread David G. Johnston
On Wed, Jun 19, 2024 at 10:56 AM Rich Shepard wrote: > I now insert rows using a transaction. Sometimes psql halts with an error: > ERROR: current transaction is aborted, commands ignored until end of > transaction block > > I issue a rollback; command but cannot continue processing. What is the

Re: Seeking Clarification on Function Definitions in PostgreSQL Extensions

2024-06-19 Thread David G. Johnston
On Wednesday, June 19, 2024, Ayush Vatsa wrote: > Hi David, > Thanks for clarification > > I prefer TABLE. Using setof is more useful when the returned type is > predefined > But in the table also isn't the returned type predefined? Example: > CREATE FUNCTION fun1(integer) > RETURNS TABLE( >

Re: Proper format for pg_dump file date

2024-06-19 Thread David G. Johnston
On Wed, Jun 19, 2024 at 8:55 AM Rich Shepard wrote: > Is the correct date format for pg_dump > -$(date +%Y-%m-%d).sql > or > --MM-DD.sql > or something else? > > If you are doing a custom format dump using .sql as the extension is objectively wrong. it is correct if you are d

Re: Seeking Clarification on Function Definitions in PostgreSQL Extensions

2024-06-18 Thread David G. Johnston
On Tuesday, June 18, 2024, Ron Johnson wrote: > On Tue, Jun 18, 2024 at 2:37 PM David G. Johnston < > david.g.johns...@gmail.com> wrote: > >> On Tuesday, June 18, 2024, Ron Johnson wrote: >> >>> On Tue, Jun 18, 2024 at 1:57 PM David G. Johnston <

Re: Seeking Clarification on Function Definitions in PostgreSQL Extensions

2024-06-18 Thread David G. Johnston
On Tuesday, June 18, 2024, Ron Johnson wrote: > On Tue, Jun 18, 2024 at 1:57 PM David G. Johnston < > david.g.johns...@gmail.com> wrote: > >> On Tuesday, June 18, 2024, Ron Johnson wrote: >> >>> >>> But I stand by returning OUT params and records at

Re: Seeking Clarification on Function Definitions in PostgreSQL Extensions

2024-06-18 Thread David G. Johnston
On Tuesday, June 18, 2024, Ron Johnson wrote: > > But I stand by returning OUT params and records at the same time. > You mean you dislike adding the optional returns clause when output parameters exist? Because the out parameters and the “record” represent the exact same thing. David J.

Re: Seeking Clarification on Function Definitions in PostgreSQL Extensions

2024-06-18 Thread David G. Johnston
On Tue, Jun 18, 2024 at 10:07 AM Ron Johnson wrote: > fun2 puzzles me. Why would you return parameters AND *a single record* > (unless > it's an error status). > You mis-understand what 2 is doing. You should go re-read the docs for create function again. Especially the description of rettyp

Re: Seeking Clarification on Function Definitions in PostgreSQL Extensions

2024-06-18 Thread David G. Johnston
On Tue, Jun 18, 2024 at 9:50 AM Ayush Vatsa wrote: > 1/ I wanted to know what's the difference between the above three > definitions. > As per my understanding, "fun1" and "fun2" look the same, taking one > integer and returning two columns with multiple rows. > Yes. > > Can the above definiti

Re: Is a VACUUM or ANALYZE necessary after logical replication?

2024-06-16 Thread David G. Johnston
On Saturday, June 15, 2024, Koen De Groote wrote: > I've gone over all of https://www.postgresql.org/docs/current/logical- > replication.html and the only mentions of the word "index" I could find > was in relation to replica identity and examples of table definitions > showing primary key indexe

Re: Reset sequence to current maximum value of rows

2024-06-13 Thread David G. Johnston
On Thu, Jun 13, 2024 at 3:13 PM Rich Shepard wrote: > Yes, I'm sure. Early yesterday I did get duplicate key errors. That's when > I > looked on stackexchange to learn how to reset the sequence's max value to > the value of the number of rows in the table. Not only did my attempt to > add > a sin

Re: Reset sequence to current maximum value of rows

2024-06-13 Thread David G. Johnston
On Thu, Jun 13, 2024 at 10:20 AM Rich Shepard wrote: > Two tables have a sequence for the PK. Over time I manually entered the PK > numbers not being aware of applying DEFAULT to generate the next number. > > I just tried to set one table's PK sequence to the current max(PK) value > using this ex

Re: Reset sequence to current maximum value of rows

2024-06-13 Thread David G. Johnston
On Thu, Jun 13, 2024 at 11:24 AM Rich Shepard wrote: > On Thu, 13 Jun 2024, David G. Johnston wrote: > > > You need to show your work here. As your PK is a number it cannot have a > > company name as a value and so this doesn't make sense. > > insert into compan

Re: Reset sequence to current maximum value of rows

2024-06-13 Thread David G. Johnston
On Thu, Jun 13, 2024 at 12:57 PM Rich Shepard wrote: > INSERT into companies (company_nbr,company_name,industry,status) VALUES > (DEFAULT,'A new company name', 'Manufacturing',DEFAULT); > > Yesterday, before learning to use DEFAULT for the company_nbr PK I entered > all rows using company_nbr 234

Re: Syntax on BEFORE Trigger - Cascade?

2024-06-13 Thread David G. Johnston
On Thursday, June 13, 2024, David Barbour wrote: > > When a record in *import_job* is deleted, the child records (file > records) in *import_file* need to be deleted first. > > The constraint in both Oracle and Postgres is similar (Postgres version): > *ALTER TABLE IF EXISTS idev.import_file* > >

Re: "permission denied to COPY to or from an external program" even with GRANT pg_execute_server_program

2024-06-12 Thread David G. Johnston
On Wednesday, June 12, 2024, Chema wrote: > > Create Role justintestin noinherit login password 'qwer'; > > > GRANT pg_execute_server_program TO justintestin; > > > Pretty sure since you choose not to allow justintestin to inherit stuff you will need to issue a “set role to pg_execute_server_prog

Re: PG16.1 security breach?

2024-06-12 Thread David G. Johnston
On Wed, Jun 12, 2024 at 3:57 PM Tom Lane wrote: > Ron Johnson writes: > > On Wed, Jun 12, 2024 at 4:36 PM David G. Johnston < > > david.g.johns...@gmail.com> wrote: > >> I think my point is that a paragraph like the following may be a useful > >> addition

Re: Definging columns for INSERT statements

2024-06-12 Thread David G. Johnston
On Wed, Jun 12, 2024 at 2:11 PM Rich Shepard wrote: > I have > 100 rows to add to a table using INSERT INTO statements. I want > the > PK to be the next value in the sequence. Would this be the appropriate > syntax for the columns to be entered? > The whole point of the server is to parse text a

Re: UPDATE with multiple WHERE conditions

2024-06-12 Thread David G. Johnston
On Wed, Jun 12, 2024 at 2:28 PM Rich Shepard wrote: > I have a table with 3492 rows. I want to update a boolean column from > 'false' to 'true' for 295 rows based on the value of another column. > > Is there a way to access a file with those condition values? > I'll often just use a spreadsheet

Re: PG16.1 security breach?

2024-06-12 Thread David G. Johnston
On Wed, Jun 12, 2024 at 2:37 PM Ron Johnson wrote: > On Wed, Jun 12, 2024 at 4:36 PM David G. Johnston < > david.g.johns...@gmail.com> wrote: > >> On Mon, Jun 10, 2024 at 2:21 AM Laurenz Albe >> wrote: >> >>> > How is it that the default privilege g

Re: PG16.1 security breach?

2024-06-12 Thread David G. Johnston
On Mon, Jun 10, 2024 at 2:21 AM Laurenz Albe wrote: > > How is it that the default privilege granted to public doesn’t seem to > care who the object creator > > is yet when revoking the grant one supposedly can only do so within the > scope of a single role? > > I don't understand what you wrote.

Re: Unexpected Backend PID reported by Notification

2024-06-11 Thread David G. Johnston
On Tuesday, June 11, 2024, Dominique Devienne wrote: > > Are Stored PROCs running in a different backend? > Are Triggers running in a different backend? > No to both. Whatever backend the SQL to invoke those was sent on is the backend that executes them. David J.

Re: Gaps in PK sequence numbers [RESOLVED]

2024-06-10 Thread David G. Johnston
On Monday, June 10, 2024, Rich Shepard wrote: > > Is there a way to reset the sequence to the maximum > number +1? I don't recall seeing this in the postgres docs but will look > again. > https://www.postgresql.org/docs/current/functions-sequence.html setval The bigint argument can be compute

Re: Gaps in PK sequence numbers

2024-06-10 Thread David G. Johnston
On Mon, Jun 10, 2024 at 3:57 PM Rich Shepard wrote: > > I found a web page that explains how to find the gaps in a sequence, yet I > want to understand why nextval() doesn't begin with the max(FK)+1 value. > For efficiency the only thing used to determine the next value of a sequence is the stor

Re: Multiple tables row insertions from single psql input file

2024-06-10 Thread David G. Johnston
On Mon, Jun 10, 2024 at 2:58 PM Rich Shepard wrote: > > INSERT into companies (company_nbr,company_name,industry,status) VALUES > nextval('companies_org_nbr_seq'),'Acme','Manufacturing','Opportunity'), > nextval('companies_org_nbr_seq'),'Baker','Livestock','Opportunity'); > > Running: > $ psql -U

Re: Multiple tables row insertions from single psql input file

2024-06-10 Thread David G. Johnston
> > On Mon, Jun 10, 2024 at 12:43 PM Ron Johnson > wrote: > Most useful to you will be some number of "ALTER TABLE DISABLE > TRIGGER ALL;" statements near the beginning of the file, and their "ALTER > TABLE ... ENABLE TRIGGER ALL;" counterparts near the end of the file. > > Have you just not he

Re: Escaping single quotes with backslash seems not to work

2024-06-10 Thread David G. Johnston
On Mon, Jun 10, 2024 at 8:19 AM Ron Johnson wrote: > > "set standard_encoding_strings = on" is at the top, and there's no other > reference to it. > > Well, if they are not using E-strings for escapes then you have the answer why v14 is broken. Does it really matter why v9.6 apparently worked ev

Re: Escaping single quotes with backslash seems not to work

2024-06-10 Thread David G. Johnston
On Monday, June 10, 2024, Ron Johnson wrote: > On Mon, Jun 10, 2024 at 10:08 AM David G. Johnston < > david.g.johns...@gmail.com> wrote: > >> On Mon, Jun 10, 2024 at 7:02 AM Ron Johnson >> wrote: >> >>> PG 9.6 and PG 14 >>> >>> https:/

Re: Escaping single quotes with backslash seems not to work

2024-06-10 Thread David G. Johnston
On Mon, Jun 10, 2024 at 7:07 AM David G. Johnston < david.g.johns...@gmail.com> wrote: > On Mon, Jun 10, 2024 at 7:02 AM Ron Johnson > wrote: > >> PG 9.6 and PG 14 >> >> >> https://www.postgresql.org/docs/14/sql-syntax-lexical.html#SQL-SYNTAX-CONSTAN

Re: Escaping single quotes with backslash seems not to work

2024-06-10 Thread David G. Johnston
On Mon, Jun 10, 2024 at 7:02 AM Ron Johnson wrote: > PG 9.6 and PG 14 > > > https://www.postgresql.org/docs/14/sql-syntax-lexical.html#SQL-SYNTAX-CONSTANTS > > [quote] > Any other character following a backslash is taken literally. Thus, to > include a backslash character, write two backslashes (

PG16.1 security breach?

2024-06-07 Thread David G. Johnston
On Friday, June 7, 2024, Laurenz Albe wrote: > On Fri, 2024-06-07 at 13:54 +, Zwettler Markus (OIZ) wrote: > > > Another point to keep in mind is that by default, execute privilege is > granted to > > > PUBLIC for newly created functions (see Section 5.7 for more > information). > > > > Argh.

Re: PG16.1 security breach?

2024-06-07 Thread David G. Johnston
On Friday, June 7, 2024, Zwettler Markus (OIZ) wrote: > > grant usage on schema oiz to public; > > > > The role is also able to execute the function even I revoke any execute > privilege explicitly: > > > > revoke execute on function oiz.f_set_dbowner (p_dbowner text, p_dbname > text) from testus

Re: PG 14 pg_basebackup accepts --compress=server-zst option

2024-06-06 Thread David G. Johnston
On Thursday, June 6, 2024, Kashif Zeeshan wrote: > Hi > > On Fri, Jun 7, 2024 at 6:54 AM Ron Johnson > wrote: > >> >> https://www.postgresql.org/docs/14/app-pgbasebackup.html doesn't mention >> "--compress=[{client|server}-]method". That first appears in the v15 >> docs. >> >> And yet pg_baseba

Re: Rules and Command Status - update/insert/delete rule with series of commands in action

2024-05-30 Thread David G. Johnston
On Thu, May 30, 2024, 12:32 johnlu...@hotmail.com wrote: > Any thoughts? > Very little interest exists in working on user-specified rules. They are practically deprecated. > > Any interest in perhaps providing a choice via a configuration > parameter? > Almost certainly not. Configuration

Re: Use of inefficient index in the presence of dead tuples

2024-05-28 Thread David G. Johnston
On Tue, May 28, 2024, 07:21 Alexander Staubo wrote: > > > I did explore a solution which is my “plan B” — adding a “done” column, > then using “UPDATE … SET done = true” rather than deleting the rows. This > causes dead tuples, of course, but then adding a new index with a “… WHERE > NOT done” fi

  1   2   3   4   5   6   7   8   9   10   >