Re: Strange behavior

2020-10-10 Thread David G. Johnston
On Sat, Oct 10, 2020 at 9:13 AM Olivier Leprêtre wrote: This has nothing to do with pgAdmin, or any other client interface. In other words, a wrong query returns a valid result. This happens because > v1 is a column from test1, (select vx from test2) will return an error as > expected. >

Re: pgbouncer installation example (Step by step)

2020-10-14 Thread David G. Johnston
On Wed, Oct 14, 2020 at 10:08 AM Atul Kumar wrote: > Please share a clean example of installing, configuring and testing > pgBouncer. > > Your official links are not organized so I need an example of > PgBouncer with organized steps. > As I said on your exact same posting to the -admin list;

Re: passing linux user to PG server as a variable ?

2020-08-17 Thread David G. Johnston
On Mon, Aug 17, 2020 at 5:46 PM David Gauthier wrote: > Users will connect to the DB and then update a table using SQL at the > prompt. And I want a post update trigger to identify who (linux user on > the client side) just made that change.I was sort of hoping that this 8 > character

Re: passing linux user to PG server as a variable ?

2020-08-17 Thread David G. Johnston
On Mon, Aug 17, 2020 at 12:53 PM David Gauthier wrote: > Looking at psql command line options, I see "-v" (lowercase) which is > described as... > > -v assignment > --set=assignment > --variable=assignment > > Perform a variable assignment, like the \set meta-command. Note that you > must

Re: passing linux user to PG server as a variable ?

2020-08-17 Thread David G. Johnston
On Mon, Aug 17, 2020 at 5:46 PM David Gauthier wrote: > >> You lass in the $USER to you client software where it executes a > post-connect hook SQL script populating a temp table with that value, > usually via a function. > > A "post-connect hook SQF script" ? > My (limited) understanding of

Re: passing linux user to PG server as a variable ?

2020-08-17 Thread David G. Johnston
On Monday, August 17, 2020, David Gauthier wrote: > OK, trying to piece together something that might work but I don't see the > pieces falling into place. > From the link you provided... > > "The most fundamental way to set these parameters is to edit the file > postgresql.conf" > So I'm fine

Re: import XML

2020-08-18 Thread David G. Johnston
On Tue, Aug 18, 2020 at 8:27 AM PASCAL CROZET < pascal.cro...@qualis-consulting.com> wrote: > I want to import XML file into PG database table. > I've find functions to get the XML content of a cell after imported an XML > file with the pg_get_file function. > But, I want to explode the XML

Re: Inline count on a query

2020-08-19 Thread David G. Johnston
On Wednesday, August 19, 2020, Laura Smith < n5d9xq3ti233xiyif...@protonmail.ch> wrote: > Hi, > > Let's say we've got a fairly basic table : > > create table networks ( > lan_id text not null, > net_id text not null, > port_id text not null > ); > create index net_uniq on

Re: Inline count on a query

2020-08-19 Thread David G. Johnston
On Wed, Aug 19, 2020 at 8:19 AM Laura Smith < n5d9xq3ti233xiyif...@protonmail.ch> wrote: > On Wednesday, 19 August 2020 15:09, David G. Johnston < > david.g.johns...@gmail.com> wrote: > > > On Wednesday, August 19, 2020, Laura Smith < > n5d9xq3ti233xiyif...@p

Re: Interpolation problem - pg 12.4 - full correct version!

2020-08-19 Thread David G. Johnston
On Wed, Aug 19, 2020 at 11:51 AM Pól Ua Laoínecháin wrote: > > I think my *MAJOR* problem is that I've developed what is, > essentially, a totally brute force approach - and this simply won't > work at the scenario becomes more complex - take a look at the CASE > statement - it's horrible and

Re: Substitute Variable in select query

2020-08-24 Thread David G. Johnston
On Monday, August 24, 2020, harish supare wrote: > Hi Team, > > Would like to know what the substitute/input variable available in psql. > > > Oracle we use & - select a, b , c from table where a like > > Is there an alternative in psql? > > > Colon - read the documentation, psql section, for

Re: Substitute Variable in select query

2020-08-24 Thread David G. Johnston
On Mon, Aug 24, 2020 at 7:21 AM harish supare wrote: > thanks for the reply David. > > In case of Colon I need to set the variable first, my requirement is my > select query should prompt for the input. > > Please don't top-post. psql does not have a feature that will prompt users during the

Re: I'm surprised that this worked

2020-09-22 Thread David G. Johnston
On Tue, Sep 22, 2020 at 6:34 PM raf wrote: > Hi, > > I just wrote a query that I didn't expect to work but I > was pleasantly surprised that it did. It looked > something like this: > > select > a.aaa, > c.ccc, > d.ddd1, > d.ddd2 > from > tbla a, > tblb b, > tblc

Re: Rows removed on child table when updating parent partitioned table.

2020-10-01 Thread David G. Johnston
The convention on these lists is to inline or bottom-post, please do not top-post. On Thu, Oct 1, 2020 at 10:41 AM Jonathan Strong wrote: > I've been away from coding for several years, but dusting off my chops and > getting back up to speed with PostgreSQL (love it!). So please forgive me > if

Re: temp table same name real table

2020-10-01 Thread David G. Johnston
On Wed, Sep 30, 2020 at 7:41 AM Tom Lane wrote: > If you really really need to do this, I'd counsel using EXECUTE to > ensure no caching happens. But I concur with Michael that it's > fundamentally a bad idea. > Agreed, though the documentation seems a bit loose here. The fact that the temp

Re: How to write such a query

2020-09-18 Thread David G. Johnston
On Fri, Sep 18, 2020 at 1:18 PM Igor Korot wrote: > As I said - Access does it without changing the query internally (I > presume). > > I want to do the same with PostgreSQL. > I suspect they basically do the equivalent of: UPDATE ... WHERE CURRENT OF ;

Re: Detecting which columns a query will modify in a function called by a trigger

2020-10-02 Thread David G. Johnston
On Tue, Mar 3, 2020 at 4:19 PM David G. Johnston wrote: > On Tue, Mar 3, 2020 at 4:11 PM Adrian Klaver > wrote: > >> On 3/3/20 3:06 PM, David G. Johnston wrote: >> > On Tue, Mar 3, 2020 at 3:48 PM Adrian Klaver > > <mailto:adrian.kla...@aklaver.co

Re: Profile Creation

2020-10-02 Thread David G. Johnston
On Fri, Oct 2, 2020 at 1:43 PM Brajendra Pratap Singh < singh.bpratap...@gmail.com> wrote: > How can we create a user profile in open postgresql db? > ? CREATE TABLE user_profile (...); INSERT INTO user_profile VALUES (...); David J.

Re: Rows removed on child table when updating parent partitioned table.

2020-10-02 Thread David G. Johnston
On Fri, Oct 2, 2020 at 9:11 AM Eduard Català wrote: > If no one else gives an opinion I will open a bug for at least, force an > update of the documentation. > It's been seen and begun to be discussed over on -hackers [1]. [1]

Re: suggestion the process to sync the data from PROD DB to Staging environment

2020-05-27 Thread David G. Johnston
On Wed, May 27, 2020 at 9:31 AM postgann2020 s wrote: > Thanks, David, > > Please find the environment details. > > Environment: > PROD: > OS: RHEL 7.1 > Postgres: 9.5.15 > > Staging: > OS: RHEL 7.1 > Postgres: 9.5.15 > Ok...not particularly helpful though I do see you are not keeping up with

Re: suggestion the process to sync the data from PROD DB to Staging environment

2020-05-27 Thread David G. Johnston
On Wed, May 27, 2020 at 8:56 AM postgann2020 s wrote: > Could someone please suggest the process to *sync the data from PROD DB > to the Staging environment* with minimal manual intervention or > automatically. > Read up on the general purpose "bash" scripting language, the PostgreSQL "pg_dump"

Re: SELECT query results are different depending on whether table statistics are available.

2020-05-27 Thread David G. Johnston
On Wed, May 27, 2020 at 8:09 PM James Brauman wrote: > -- Run select query (involving several CTEs). > SELECT ...; > > I haven't generated a minimal test case yet, but I did notice that if > all CTEs in the SELECT query are defined using AS NOT MATERIALIZED the > results are always the same

Re: Query returns no rows in pg_basebackup cluster

2020-05-25 Thread David G. Johnston
On Sunday, May 24, 2020, Andrus wrote: > Hi! > > Backup in created in Windows from Linux server using pg_receivewal and >>> pg_basebackup . >>> Can this backup used for PITR in Linux ? >>> >> No. Physical copies need to be based on the same platform. If you >> wish to replicate a cluster

Re: Query returns no rows in pg_basebackup cluster

2020-05-24 Thread David G. Johnston
On Sun, May 24, 2020 at 4:10 PM Michael Paquier wrote: > On Fri, May 22, 2020 at 09:53:37AM +0300, Andrus wrote: > > Backup in created in Windows from Linux server using pg_receivewal and > pg_basebackup . > > Can this backup used for PITR in Linux ? > > No. Physical copies need to be based on

Re: problem with self built postgres 9.0.9

2020-05-29 Thread David G. Johnston
On Fri, May 29, 2020 at 7:08 AM Gabriele Bulfon wrote: > Amazing! Rebuilt without -O and it worked like a charm! > Thanks, at the moment I need to stick to 9.0.9 on this machine to be able > to reuse the same database files. > > Just to be thorough. You can update to 9.0.23 (i.e., build against

Re: GPG signing

2020-05-26 Thread David G. Johnston
On Tuesday, May 26, 2020, Marc Munro wrote: > I need to be able to cryptographically sign objects in my database > using a public key scheme. > > Any other options? Am I missing something? > This feels like it should be an application (middleware...) concern, not the database proper. i.e.,

Re: How to get the OID of a view

2020-05-22 Thread David G. Johnston
On Fri, May 22, 2020 at 9:15 AM stan wrote: > I am trying to write a query to return the names, and data types of all the > columns in a view. It has been pointed out to me that the best approach > would be using pg_catalog. OK, so I found pg_view, which I can get the > names > of a the views

Re: query, probably needs window functions

2020-05-22 Thread David G. Johnston
On Fri, May 22, 2020 at 12:38 PM Michael Lewis wrote: > I believe something like this is what you want. You might be able to do it > without a sub-query by comparing the current name value to the lag value > and null it out if it's the same. > This. I misread the question. You might also

Re: query, probably needs window functions

2020-05-22 Thread David G. Johnston
On Friday, May 22, 2020, Scott Ribe wrote: > given, let's say: > > create table person (id int not null, name varchar); > create table phone (id int not null, person_id int not null, number > varchar); > > select person.*, phone.number from person join phone on (person.id = > phone.person_id)

Re: Suggestion on index creation for TEXT data field

2020-05-21 Thread David G. Johnston
On Thu, May 21, 2020 at 7:45 AM postgann2020 s wrote: > >And what type of data exactly are we talking about. ==> Column is > stroing GIS data. > GIS data isn't really TEXT and isn't a core datatype of PostgreSQL so this is maybe better posted to the PostGIS community directly... David J.

Re: Suggestion on index creation for TEXT data field

2020-05-21 Thread David G. Johnston
On Thu, May 21, 2020 at 7:28 AM postgann2020 s wrote: > which is having an avg width of 149bytes. > The average is meaningless if your maximum value exceeds a limit. 2. What type of index is the best suited for this type of data?. > And what type of data exactly are we talking about. "TEXT"

Re: When to use PARTITION BY HASH?

2020-06-02 Thread David G. Johnston
On Tue, Jun 2, 2020 at 10:17 AM Oleksandr Shulgin < oleksandr.shul...@zalando.de> wrote: > That *might* turn out to be the case with a small number of distinct > values in the partitioning column(s), but then why rely on hash > assignment instead of using PARTITION BY LIST in the first place? > >

Re: split_part for the last element

2020-10-23 Thread David G. Johnston
On Fri, Oct 23, 2020 at 8:47 AM Nikhil Benesch wrote: > Is there another option I'm missing? Would there be interest in > extending split part so that negative indices counted from the end, as > in: > > split_part('foo bar baz', ' ', -1) -> 'baz' > Some thoughts: I'm torn here because this

Re: Copy json from couchbase to postgres

2020-10-26 Thread David G. Johnston
On Mon, Oct 26, 2020 at 1:10 PM Rushikesh socha wrote: > Any suggestions on copying .json which is exported from couchbase > using cbexport json. I used copy command but most of them are throwing > error. > > pgdocstore=# copy schaname.tablename from 'path/filename.json'; > ERROR: invalid input

Re: Certficates

2020-08-10 Thread David G. Johnston
The convention on these lists is to inline or bottom-post. On Mon, Aug 10, 2020 at 11:11 AM Martin Gainty wrote: > cant you use keytool ? > That wasn't the question, the OP already indicated they can do this successfully in JDBC. David J.

Re: Bytea Example

2020-08-13 Thread David G. Johnston
On Thursday, August 13, 2020, Naveen Kumar wrote: > Can someone please give me an example on byteA data type. > > 1. How to import a image/text file into Bytea data type.? > 2. How to export the same? > At a simple level its no different than importing and exporting character data using a

Re: Certficates

2020-08-10 Thread David G. Johnston
On Mon, Aug 10, 2020 at 10:54 AM Shankar Bhaskaran wrote: > How does psql import the server certificate? > See: https://www.postgresql.org/docs/12/libpq-envars.html Namely the "PGSSL*" prefixed environment variables. It works by default because both the server and client are usually

Re: Can't seem to mix an inner and outer join in a query and get it to work right.

2020-06-29 Thread David G. Johnston
On Monday, June 29, 2020, David Gauthier wrote: > >sqf_id | sqf_sl | as_cl | > wa_id | type > > +--- > --+-+---+--- > > *

Re: Different results from identical matviews

2020-07-02 Thread David G. Johnston
On Thu, Jul 2, 2020 at 8:06 AM Anders Steinlein wrote: > On Thu, Jul 2, 2020 at 3:55 PM David G. Johnston < > david.g.johns...@gmail.com> wrote: > >> On Thursday, July 2, 2020, Anders Steinlein wrote: >>> >>> >>> I just wanted to add th

Re: Different results from identical matviews

2020-07-02 Thread David G. Johnston
On Thursday, July 2, 2020, Anders Steinlein wrote: > > >> Thanks for the tip, but I'm having a hard time thinking that's the case, >> seeing as I'm unable to trigger the wrong result no matter how hard I try >> with a new definition/manual query. I've introduced random ordering to the >> first

Re: Different results from identical matviews

2020-07-02 Thread David G. Johnston
On Thu, Jul 2, 2020 at 8:44 AM Tom Lane wrote: > A plausible explanation for how things got that way is that citext's > equality operator wasn't in your search_path when you created the original > matview, but it is in view when you make the new one, allowing that > equality operator to capture

Re: Can't seem to mix an inner and outer join in a query and get it to work right.

2020-07-01 Thread David G. Johnston
The convention here is to bottom post or inline responses. On Wed, Jul 1, 2020 at 9:51 AM David Gauthier wrote: > Actually, I want the outer join first. If it finds something, then move > on to the inner join and filter out all those that don't join to a rec with > 'autosmoke'. But if the

Re: BigSerial and txid issuance

2020-07-08 Thread David G. Johnston
On Wed, Jul 8, 2020 at 8:18 AM Yorwerth, Adam wrote: > Is it possible for two transactions to interleave their issuance of these > two variables? > > > > Is it possible for transaction 1 to be issued txid 1001 and offset 12 and > transaction 2 to be issued txid 1002 and offset 11? > Given all

Re: Basic question about structuring SQL

2020-07-07 Thread David G. Johnston
On Tue, Jul 7, 2020 at 4:41 AM Robert Inder wrote: > So how should I structure my chunks of SQL so that I can have "safe" > (all-or-nothing) blocks, > AND use them from within one another? > While there are more advanced constructs that may aid here I would suggest just following two rules:

Re: Both side privileges

2020-07-13 Thread David G. Johnston
On Mon, Jul 13, 2020 at 4:42 PM Jean-Philippe Chenel wrote: > Hi, > > I try to give userA privileges on userB objects and same thing to the > userB, giving privileges on userA objects. > > Grant userB to userA; —ok > Grant userA to userB; —error: role userB is already member of role userA >

Re: some random() clarification needed

2020-07-14 Thread David G. Johnston
On Tue, Jul 14, 2020 at 8:15 AM Marc Millas wrote: > select id, prenom from prenoms where id=ceiling(random()*2582); > > expecting to get, allways, one line. > But its not the case. > around 15% of time I get 0 lines which is already quite strange to me. > but 10% of time, I get a random number

Re: some random() clarification needed

2020-07-14 Thread David G. Johnston
Please don't top-post. Inline (with trim) is better but at minimum bottom-post. On Tue, Jul 14, 2020 at 9:01 AM Marc Millas wrote: > Hi, > your answer helps me understand my first problem. > so, I rewrote a simple loop so as to avoid the "volatile" behaviour. > (at least I was thinking I

Re: Surprising connection issue

2020-07-14 Thread David G. Johnston
On Tue, Jul 14, 2020 at 8:25 AM David Gasa i Castell wrote: > And my surprise went when I see the connection done while there is no user > granted to connect the database... > https://www.postgresql.org/docs/12/ddl-priv.html """ PostgreSQL grants privileges on some types of objects to PUBLIC

Re: Convert hot_standby 9.4 postgresql into standalone server

2020-07-14 Thread David G. Johnston
On Tuesday, July 14, 2020, Julie Nishimura wrote: > Hello, we currently have 9.4 hot_standby master-slave pair. Going forward, > we can keep only one server. How can I convert the system properly? > If you are keeping the primary you shouldn’t have to do anything. The absence of a secondary

Re: survey: psql syntax errors abort my transactions

2020-07-02 Thread David G. Johnston
On Thu, Jul 2, 2020 at 8:54 AM Jeremy Schneider wrote: > > https://www.postgresql.org/message-id/flat/CABTbUpiAOKZ405uArt8cJFtC72RhzthmvWETQK_6Qw0Ad-HquQ%40mail.gmail.com > > This thread on hackers actually seemed kindof short to me. Not nearly > enough bike-shedding to call it a closed case. >

Re: Feature suggestion: auto-prefixing SELECT query column names with table/alias names

2020-06-22 Thread David G. Johnston
On Sunday, June 21, 2020, Guy Burgess wrote: > > a.id, a.title, b.id, b.title You are missing some double-quotes there. Of course, this can be achieved by avoiding the (often frowned-upon) SELECT > * syntax in the first place and using explicit column names, Or choose better,

Re: scram-sha-256 encrypted password in pgpass

2020-06-22 Thread David G. Johnston
On Mon, Jun 22, 2020 at 3:32 PM Pavan Kumar wrote: > Adrian, David, > > Thank you so much for the quick response. > > What would be the point of storing the encrypted password instead of the > plaintext one? > As per our organization security policies, we can 't keep any passwords > in plain

Re: Can the current session be notified and refreshed with a new credentials context?

2020-06-22 Thread David G. Johnston
On Mon, Jun 22, 2020 at 2:21 PM Ron wrote: > On 6/22/20 4:07 PM, AC Gomez wrote: > > Suppose you have the following scenario: > > 1: Call some function with a certain user and password > 2: From inside that function, have several calls using DBLink > 3: At some point during the running of that

Re: scram-sha-256 encrypted password in pgpass

2020-06-22 Thread David G. Johnston
Please don't cross-post. On Mon, Jun 22, 2020 at 1:35 PM Pavan Kumar wrote: > scram-sha-256 encrypted passwords are supported in .pgpass file ? If yes > kindly provide us an example. > > I am using below format and it is not working for me > >

Re: create batch script to import into postgres tables

2020-06-19 Thread David G. Johnston
On Fri, Jun 19, 2020 at 7:33 AM Adrian Klaver wrote: > On 6/19/20 7:17 AM, pepevo wrote: > > I understand your post about "password does not take an argument, it is > > meant to be used as is. The purpose is to force a password prompt." When > > I used -W and --password=. That's what I said I

Re: create batch script to import into postgres tables

2020-06-19 Thread David G. Johnston
On Fri, Jun 19, 2020 at 6:58 AM Adrian Klaver wrote: > On 6/19/20 6:53 AM, Pepe TD Vo wrote: > > Thank you sir and I am sorry for the typo not having "--" on password. > > I did spelling out with --password=mypassword > > Please go back and read my post again. > To be clear, there is no way to

Re: Can the current session be notified and refreshed with a new credentials context?

2020-06-22 Thread David G. Johnston
On Mon, Jun 22, 2020 at 5:41 PM AC Gomez wrote: > But what I understand you to say is that, one can start running a function > in PG, change all security context from under it, and it will still work > under the original login context, despite the changes. >

Re: Persistent Connections

2020-06-23 Thread David G. Johnston
Why is there now a second thread for this topic? On Tue, Jun 23, 2020 at 3:21 PM Bee.Lists wrote: > > > > On Jun 23, 2020, at 4:51 PM, Michael Lewis wrote: > > > > Do you see anything in pg_stat_activity that stays idle for a while and > then *does* disappear on its own? Perhaps some types of

Re: EXTERNAL: Re: Netapp SnapCenter

2020-06-25 Thread David G. Johnston
On Thu, Jun 25, 2020 at 8:24 AM Paul Förster wrote: > Archived WAL is another thing, but PGDATA and pg_wal should IMHO always be > located on the same volume, along with tablespaces, if any. > My understanding that having such a setup (single volume) eases administration at the cost of

Re: libpq pipelineing

2020-06-27 Thread David G. Johnston
On Friday, June 26, 2020, Samuel Williams wrote: > > What about, as it says, sending multiple statements in a single > sendQuery and then polling for multiple results? > > I tried this, and even in single row streaming mode, I found that > there are cases where the results would not be streamed

Re: libpq pipelineing

2020-06-26 Thread David G. Johnston
On Friday, June 26, 2020, Samuel Williams wrote: > Hello, > > Using the asynchronous interface of libpq, is it possible to pipeline > multiple queries? > > i.e. > > PQsendQuery(query1) > PQsendQuery(query2) > > followed by > > query1_results = PQgetResult(...) > query2_results = PQgetResult(...)

Re: libpq pipelineing

2020-06-26 Thread David G. Johnston
On Friday, June 26, 2020, Samuel Williams wrote: > Thanks David, > > You are correct. > > I was giving an example of what I was hoping to achieve, not what I > expected to work with the current interface. > What about, as it says, sending multiple statements in a single sendQuery and then

Re: Unable to execute pg_dump

2020-06-14 Thread David G. Johnston
On Sunday, June 14, 2020, Joseph Maruca wrote: > > '''sudo -u postgres -H --psql -px -d db_name''' > > If I enter the following syntax from the RHEL command line: > > '''sudo su postgres''' > > I end up in the bash-4.1 shell. When executing the following command from > within the shell:

Re: create batch script to import into postgres tables

2020-06-19 Thread David G. Johnston
On Friday, June 19, 2020, pepevo wrote: > But everything can run by script on the server, right? > Separation of concerns. The server with the database cluster should probably not be running application code. Application code can be run other machine, “admin” machine is one label. Though for

Re: create batch script to import into postgres tables

2020-06-19 Thread David G. Johnston
On Friday, June 19, 2020, pepevo wrote: > We can't just install any softwares without Goverment's approval. Also, > they might ask Oracle/mysql/sql can run batch script, why not Postgres? I > wonder myself and just realize today from this email. > PostreSQL isn’t the issue here, you are. To

Re: Need help with PITR for PostgreSQL 9.4.5

2020-06-24 Thread David G. Johnston
The version you are running is neither up-to-date for its major version (9.4) nor is the major version being supported. https://www.postgresql.org/support/versioning/ Thoug a functioning backup is good to have before upgrading, especially major versions. On Wednesday, June 24, 2020, Sri Linux

Re: gdal, proj and other postgis dependencies missing in postgres repos

2020-06-07 Thread David G. Johnston
On Sunday, June 7, 2020, Rene Romero Benavides wrote: > On Sun, Jun 7, 2020 at 5:37 PM Rene Romero Benavides < > rene.romer...@gmail.com> wrote: > >> Hi everybody, do you know what happened to gdal and other postgis >> dependencies like proj in the official postgres repos? >> they appear to be

Re: Can we get SQL Server-like cross database queries

2020-06-04 Thread David G. Johnston
On Wednesday, June 3, 2020, Laurenz Albe wrote: > On Thu, 2020-06-04 at 16:41 +1200, Thomas Munro wrote: > > There's no doubt it's useful, and it's also part of the SQL spec, > > which says you can do catalog.schema.table. I would guess that we > > might get that as a byproduct of any project

Re: checking existence of a table before updating its SERIAL

2020-06-08 Thread David G. Johnston
On Monday, June 8, 2020, Matthias Apitz wrote: > > Can some kind soul help me with doing a test for the existence of the > table to avoid the error message about non existing relation? > https://www.postgresql.org/docs/12/catalogs-overview.html David J.

Re: Is it possible to use keywords (date units) in a function definition?

2020-06-08 Thread David G. Johnston
On Mon, Jun 8, 2020 at 2:57 PM Alistair Johnson wrote: > > RETURN EXTRACT(datepart FROM end - start); > Any ideas? Is this even possible? > Use the "date_part" function. David J.

Re: A parsing question

2020-06-03 Thread David G. Johnston
On Wed, Jun 3, 2020 at 3:41 PM Michael Nolan wrote: > Recently I was typing in a query in PG 10.4. > > What I MEANT to type was: Where xyz >= 2400 > > What I actually typed was: Where xyz >- 2400 > > The latter was interpreted as 'where xyz > -2400', but I'm wondering if it > shouldn't have

Re: suggestion: psql configs in .config

2020-06-11 Thread David G. Johnston
On Thursday, June 11, 2020, Caleb Cushing wrote: > would it be possible to allow psql config files to reside in > ~/.config/psql to help unclutter ~ obviously this should be some kind of > cascading lookup > > first look for... e.g > .config/psql/psqlrc > .psqlrC > libpq consults environment

Re: Returning SELECTed rows immediately instead of all at the end?

2020-06-12 Thread David G. Johnston
On Friday, June 12, 2020, Ron wrote: > > I'm running amcheck on a set of indices (test machine, not prod) and want > to track the progress. Is there a SELECT clause that makes rows display as > they are created, No > or do I have to explicitly call bt_index_check() from a shell script or >

Re: Is it possible to use keywords (date units) in a function definition?

2020-06-08 Thread David G. Johnston
On Mon, Jun 8, 2020 at 5:06 PM Martin Gainty wrote: > CREATE OR REPLACE FUNCTION DATETIME_DIFF(end TIMESTAMP(3), start > TIMESTAMP(3), datepart UNIT) RETURNS DOUBLE PRECISION AS $$ > Duplicate email from account (same sender) - already answered on the original/correct thread. David J.

Re: Is it possible to use keywords (date units) in a function definition?

2020-06-08 Thread David G. Johnston
On Mon, Jun 8, 2020 at 2:57 PM Alistair Johnson wrote: > Hello, > > I recently tried to write a wrapper function to calculate the difference > between two dates, mainly as a convenience. I'd essentially be emulating > EXTRACT( FROM date1 - date2), in various ways. I got a bit stuck > on allowing

Re: pg_service.conf and client support

2020-06-13 Thread David G. Johnston
On Saturday, June 13, 2020, Niels Jespersen wrote: > Can anyone shed som light on the ubiquitousness of support for > pg_service.conf? > AFAIK same non-support for JDBC and Node.js > Are there any other mechanisms with broader support, that can be used > instead of pg_service.conf (if support

Re: CASCADE/fkey order

2020-07-22 Thread David G. Johnston
On Wed, Jul 22, 2020 at 9:03 AM Samuel Nelson wrote: > seems to fix it to work as we were expecting. Is that particularly > costly? Should I only set the constraint to be deferred when we really > need it? Would it be more efficient to perform the deletes explicitly > within a transaction

Re: psql \r changed behavior in pg10

2020-07-22 Thread David G. Johnston
On Wednesday, July 22, 2020, Emanuel Araújo wrote: > > \r > \e > -> Open temp file with the same last command "select 1;" > is it right? > > Documentation since v10: Or, if the current query buffer is empty, the most recently executed query is copied to a temporary file and edited in the same

Re: How to create function returning numeric from string containing percent character

2020-07-22 Thread David G. Johnston
On Wed, Jul 22, 2020 at 3:50 AM Andrus wrote: > val function should return numeric value from string up to first non-digit > character, considering first decimal point also: > > val('1,2TEST') should return 1.2 > val('1,2,3') should return 1.2 > val('-1,2,3') should return -1.2 >

Re: psql \r changed behavior in pg10

2020-07-22 Thread David G. Johnston
On Wednesday, July 22, 2020, David G. Johnston wrote: > On Wednesday, July 22, 2020, Emanuel Araújo wrote: > >> >> \r >> \e >> -> Open temp file with the same last command "select 1;" >> is it right? >> >> > Documentation s

Re: About compress in pg_dump

2020-07-17 Thread David G. Johnston
On Fri, Jul 17, 2020 at 7:49 AM Edmundo Robles wrote: > To backup a database I do: > nice -n +19 pg_dump -Fc database | nice -n +19 gzip --rsyncable -nc > > database.dump > > If -Fc option is compressed by default I dont need gzip the backup, > but I need pass --rsyncable and -n

Re: PostgreSQL make too long to start.

2020-07-17 Thread David G. Johnston
On Fri, Jul 17, 2020 at 9:16 AM FOUTE K. Jaurès wrote: > It is make sense that PostgreSQL make too long to start, About 20 > minutes. I'm using PostgreSQL 12 intalling on Ubuntu Server 18.04 and my > database is about 25 GO of data. > Every time? How are you shutting down the server?

Re: Is upper_inc ever true for dateranges?

2020-07-28 Thread David G. Johnston
On Tue, Jul 28, 2020 at 2:19 PM Ken Tanzer wrote: > So here's my question. Will the upper_inc function always return false > for a non-null daterange? And if so, what's the point of the function? > And/or is it different for other kinds of ranges? > Ranges over discrete types are always

Re: Re: PG 9.5.5 cores on AIX 7.1

2020-07-19 Thread David G. Johnston
On Sun, Jul 19, 2020 at 11:04 AM Abraham, Danny wrote: > > Customer is using 10.4 , not 9.5.5. > > Does the same argument apply for upgrading to 10.12 ? > Running the current minor release of PostgreSQL is a pre-req when reporting problems; moreso when it's largely impractical for someone else

Re: Problem with pg_service.conf

2020-07-23 Thread David G. Johnston
On Thu, Jul 23, 2020 at 6:12 AM Michał Lis wrote: > Hello, > > The server is located in the lan and runs on Windows 7x64 Ultimate. > On this server I created pg_service.conf file and set the environment > variable of PGSERVICEFILE. > The server software (postgres) doesn't use PGSERVICEFILE,

Re: CASCADE/fkey order

2020-07-22 Thread David G. Johnston
On Wed, Jul 22, 2020 at 8:24 AM Samuel Nelson wrote: > Is there a way to force the delete to cascade to tables in a specific > order? > No really, but you can defer constraint checking. https://www.postgresql.org/docs/12/sql-set-constraints.html David J.

Re: Fwd: How to connect PostgreSQL (9.6.17) database from Macbook Pro Terminal using JumpCloud password?

2020-07-16 Thread David G. Johnston
On Thu, Jul 16, 2020 at 1:24 PM Adrian Klaver wrote: > On 7/16/20 1:17 PM, Devraj B wrote: > > Please reply to list also. > Ccing list. > > Thanks Adrian, > > > > I had granted LOGIN to PostgreSQL user firstname.lastname but do Not > > want to provide a database password, > > rather I wanna

Re: Is postgres able to share sorts required by common partition window functions?

2020-07-06 Thread David G. Johnston
On Monday, July 6, 2020, Michael Lewis wrote: > Did you say you have an index on c1? > [...] > I don't know the data, but I assume there may be many rows with the same > c1 value, so then you would likely benefit from getting that distinct set > first like below as your FROM table. > Re-reading

Re: Is postgres able to share sorts required by common partition window functions?

2020-07-06 Thread David G. Johnston
On Monday, July 6, 2020, Sebastien Arod wrote: > I would have expected postgresql to "share" a preliminary sort on c1 that > would then be useful to reduce the work on all window functions but it > doesn't. > The plan shown does share - the output of one sort goes into another. Subsequent sorts

Re: Bytea Example

2020-08-16 Thread David G. Johnston
On Sun, Aug 16, 2020 at 10:11 AM Naveen Kumar wrote: > *"PostgreSQL 12.3, compiled by Visual C++ build 1914, 64-bit"* > > I am just trying to practice LOB objects, like byteA data type, in > PostgreSQL. Unfortunately, I didn't find good links regarding this so I > raised the issue. Nothing else

Re: CASE WHEN idiomatic for functions with side-effect?

2021-01-12 Thread David G. Johnston
On Tue, Jan 12, 2021 at 1:14 AM Joel Jacobson wrote: > Is it idiomatic and safe to use > > SELECT > CASE boolean_expression WHEN TRUE THEN function_with_side_effects() END > As long as function_with_side_effects() is defined volatile it is forced to be executed at runtime, once per row. That

Re: How to convert escaped text column - force E prefix

2021-01-07 Thread David G. Johnston
On Thursday, January 7, 2021, Pavel Stehule wrote: > > > The vulnerability is almost the same although it is a little bit harder to > create attack strings. > Would making the function run as “security definer” and setting up a minimal permissions user/owner help with mitigation? David J.

Re: How to keep format of views source code as entered?

2021-01-07 Thread David G. Johnston
On Thu, Jan 7, 2021 at 4:38 PM raf wrote: > > Hi, I've only used stored functions (not views or > triggers), Extrapolating to these other types of objects based upon experiences with functions isn't all that helpful. and Postgres has never altered > the code that it stores, Right, you use

Re: Problem with pg_notify / listen

2020-11-27 Thread David G. Johnston
On Friday, November 27, 2020, Gustavsson Mikael wrote: > Hi. > > After applying the latest patch we have encountered a problem with the > pg_notify queue. > > The queue is filling up and starts issuing warnings like > WARNING: NOTIFY queue is 87% full > DETAIL: The server process with PID

Re: postgres_fdw insert extremely slow

2020-11-27 Thread David G. Johnston
On Fri, Nov 27, 2020 at 2:00 PM pabloa98 wrote: > I would like to suggest for postgres_fdw: If the foreign database is > PostgreSQL, > Just to be clear, the "postgres" part of the name means the remote database must be a PostgreSQL database, there is no "if". Likewise, for the extension

Re: INSERT Trigger to check for existing records

2020-11-21 Thread David G. Johnston
On Saturday, November 21, 2020, David G. Johnston < david.g.johns...@gmail.com> wrote: > On Saturday, November 21, 2020, Hagen Finley wrote: > >> David, >> >> That's an interesting idea. I WOULD like to retain the OLD records that >> are the same an

Re: limit of data type character varying

2020-11-25 Thread David G. Johnston
On Wed, Nov 25, 2020 at 1:43 PM Mark Phillips wrote: > The actual maximum length supported by postgresql 12 is 10,485,760. We dug > into the postgres code and found a limit in the config with a comment > dating it to the pg 8.5 era. Being the simple folk that we are, we changed > the setting to

Re: error on connecting port 5432

2020-12-01 Thread David G. Johnston
On Tuesday, December 1, 2020, Atul Kumar wrote: > > There is no directory of postgresql in /var/run. Wasn’t expecting there to be, that’s what you get the error. > Please help me out. > Since “su - postgres” works for psql just do that for createuser. Or do what Tom said and specify -h /tmp

Re: The hidden cost of limit-offset

2020-12-06 Thread David G. Johnston
On Sunday, December 6, 2020, 孙冰 wrote: > The skipped rows by an OFFSET clause have to be computed nevertheless. I > am wondering if there could be any chance to improve, since the computation > is on the *entire* rows rather than on the *criterial* columns. > > [...] > > I don't understand the

Re: Using a boolean column with IF / THEN

2020-12-05 Thread David G. Johnston
On Saturday, December 5, 2020, Alexander Farber wrote: > Good evening, > > hopefully my question is not too stupid, but - > > in a 13.1 database I have a words_users table with a boolean column: > > -- the user is not allowed to chat or change the motto > muted boolean

<    1   2   3   4   5   6   7   8   9   10   >