Re: pl/pgsql outside the DB, (i.e. on the terminal) possible ?

2024-03-07 Thread Karsten Hilbert
Am Thu, Mar 07, 2024 at 08:04:21PM +0200 schrieb Achilleas Mantzios: > > Python 3.11.2 (main, Mar 13 2023, 12:18:29) [GCC 12.2.0] on linux > > Type "help", "copyright", "credits" or "license" for more information. > > >>> for idx in [0,1,2,3]: print(idx) > > Dude this is like saying

Re: pl/pgsql outside the DB, (i.e. on the terminal) possible ?

2024-03-07 Thread Karsten Hilbert
Am Thu, Mar 07, 2024 at 04:56:18PM +0200 schrieb Achilleas Mantzios - cloud: > Python IMHO is too advanced, too rich, Python _is_ powerful but it needn't be difficult. > weird indentation rules A matter of taste IMO. > no simple for loop Really ? Python 3.11.2 (main, Mar 13 2023,

Re: "reverse" (?) UPSERT -- how to ?

2024-02-17 Thread Karsten Hilbert
Am Sat, Feb 17, 2024 at 07:25:11PM +0100 schrieb Karsten Hilbert: > +1 except that I've got use for both parts of the UNION on > their own (they are both views themselves involving a bunch > of joins with yet other tables, 4 or 5 each or so ;-) Just for kicks, attached find the S

Re: "reverse" (?) UPSERT -- how to ?

2024-02-17 Thread Karsten Hilbert
Am Sat, Feb 17, 2024 at 11:54:05AM -0500 schrieb Greg Sabino Mullane: > > There will be a view giving rows for > > each detail row enriched with master table data > > UNION ALL > > rows for each master row that does not have any detail row with > > detail table

Re: "reverse" (?) UPSERT -- how to ?

2024-02-17 Thread Karsten Hilbert
Am Sat, Feb 17, 2024 at 09:33:11AM -0700 schrieb Rob Sargent: > > So, is this doable within one SQL statement (short of > > creating and running the abovementioned function in > > one go ;-) ? > > > > Perhaps your pk_detail can be defined as generated always identity? Rob, I'm sure there's

Re: "reverse" (?) UPSERT -- how to ?

2024-02-17 Thread Karsten Hilbert
Am Sat, Feb 17, 2024 at 08:55:57AM -0800 schrieb Adrian Klaver: > >Dear list members, > > > > >So, is this doable within one SQL statement (short of > >creating and running the abovementioned function in > >one go ;-) ? > > Don't know what version of Postgres you are on, assuming 15+ then maybe?:

"reverse" (?) UPSERT -- how to ?

2024-02-17 Thread Karsten Hilbert
Dear list members, maybe I am overlooking something. PostgreSQL offers UPSERT functionality by way of INSERT INTO ... ON CONFLICT ... DO UPDATE ...; Consider this pseudo-code schema table master pk_master serial primary key value text ;

Re: Safest pgupgrade jump distance

2024-02-12 Thread Karsten Hilbert
Am Mon, Feb 12, 2024 at 09:31:50AM -0500 schrieb Ron Johnson: > https://www.postgresql.org/docs/16/pgupgrade.html > "pg_upgrade supports upgrades from 9.2.X and later to the current major > release of PostgreSQL, including snapshot and beta releases." Just to be sure: it should be stressed that

Re: How should we design our tables and indexes

2024-02-11 Thread Karsten Hilbert
Am Sun, Feb 11, 2024 at 12:53:10PM +0530 schrieb veem v: > >> Pagination is already a hard problem, and does not even make sense when > > combined with "a continuous stream of inserts". What should the user see > > when they click on page 2? > > > > When the user clicks to the second page , it

Aw: Nested-Internal Functions

2024-01-16 Thread Karsten Hilbert
> I am currently using PostgreSQL 15 and I am trying to create a nested > function with the following structure: ...   > However, I get an error What *is* the error ? Karsten

Re: How to redirect output from PostgreSQL pg_recvlogical to a file or a pipe?

2024-01-13 Thread Karsten Hilbert
Am Sat, Jan 13, 2024 at 05:53:14PM -0500 schrieb Ron Johnson: > *No,* that's a technology problem. What is the purpose of storing them > back in the database using psql? Or even the end goal to be achieved by that ? Karsten -- GPG 40BE 5B0E C98E 1713 AFA6 5BC0 3BEA AC80 7D4F C89B

Aw: Time zone offset in to_char()

2024-01-11 Thread Karsten Hilbert
> > In the above, I worked around the issue using a couple of user-defined > > functions in PG. That should give a reasonable idea of the desired > > functionality, but it's not an ideal solution to my problem: > > 1). The first function has as a drawback that it changes the time zone for > >

Aw: Time zone offset in to_char()

2024-01-11 Thread Karsten Hilbert
> In the above, I worked around the issue using a couple of user-defined > functions in PG. That should give a reasonable idea of the desired > functionality, but it's not an ideal solution to my problem: > 1). The first function has as a drawback that it changes the time zone for > the entire

Aw: Role for just read the data + avoid CREATE / ALTER / DROP

2023-08-25 Thread Karsten Hilbert
set default_transaction_read_only can help   Karsten     Gesendet: Freitag, 25. August 2023 um 14:38 Uhr Von: "Durumdara" An: "Postgres General" Betreff: Role for just read the data + avoid CREATE / ALTER / DROP Dear Members!   Normally we use the "db owner" role for the connection, but

Aw: Re: Fatal Error : Invalid Memory alloc request size 1236252631

2023-08-17 Thread Karsten Hilbert
  Even I used postgreSQL Large Objects by referring this link to store and retrieve large files (As bytea not working) https://www.postgresql.org/docs/current/largeobjects.html   But even now I am unable to fetch the data at once from large objects   select lo_get(oid);   Here I'm getting the

Re: question on auto_explain

2023-08-04 Thread Karsten Hilbert
Am Fri, Aug 04, 2023 at 01:33:19PM +0800 schrieb Julien Rouhaud: > > explicit hint towards write query side effects. > > The docs says that it automatically shows the execution plans, not that it's > itself doing an EXPLAIN. Yep, so maybe _that_ point warrants being pointed out: that

Aw: Re: question on auto_explain

2023-08-03 Thread Karsten Hilbert
> > auto_explain automatically produces the explain output of a query that is > > running for reals.  The effect is identical to running explain analyze > > except your output > here is whatever the query would produce instead of > > the explain output, which instead goes into the log. > >

Aw: Re: question on auto_explain

2023-08-03 Thread Karsten Hilbert
> On Thu, Aug 3, 2023 at 9:29 AM Karsten Hilbert > mailto:karsten.hilb...@gmx.net]> wrote: >> >>   >>https://www.postgresql.org/docs/current/auto-explain.html[https://www.postgresql.org/docs/current/auto-explain.html] >> >> don't explicitely sta

question on auto_explain

2023-08-03 Thread Karsten Hilbert
Dear list, when debugging slow queries in a larger application (https://www.gnumed.de) I started to use auto_explain. The "normal" EXPLAIN warns https://www.postgresql.org/docs/current/sql-explain.html that ANALYZE on INSERT/UPDATE/DELETE will (of course, in hindsight) modify rows. Now,

Aw: When will trusted PL/Python be supported?

2023-06-27 Thread Karsten Hilbert
> It seems to me that we have untrusted PL/Python for a long time, but > till now we still do not support trusted plpython. > > I'd like to know is supporting trusted PL/Python still in the > schedule? What is the reason for the current lack of support, and do > we have any relevant email

Re: Reproducing incorrect order with order by in a subquery

2023-06-15 Thread Karsten Hilbert
Am Thu, Jun 15, 2023 at 12:58:55AM +0300 schrieb Ruslan Zakirov: e.g. > https://mariadb.com/kb/en/why-is-order-by-in-a-from-subquery-ignored/ ... > My goal was to find a small dataset that demonstrates this ordering > mismatch. I attempted to think it through whether it is even *possible* to

Re: Reproducing incorrect order with order by in a subquery

2023-06-14 Thread Karsten Hilbert
Am Wed, Jun 14, 2023 at 01:03:06PM +0300 schrieb Ruslan Zakirov: > > This is a too complex query to build a test on. Tried simpler scenarios > > and failed. > > > > First of all I want to apologize. We work with multiple RDBMS systems. This > particular user is using mysql. ... > Anyway,

Re: Guidance on INSERT RETURNING order

2023-04-14 Thread Karsten Hilbert
Am Fri, Apr 14, 2023 at 10:44:19PM +0100 schrieb John Howroyd: > The problem is that SQLAlchemy is an ORM [...] ... > [...] as the majority of the python world will use this ORM for > their database needs. I wouldn't be so sure on this count ... Karsten -- GPG 40BE 5B0E C98E 1713 AFA6 5BC0

Re: [EXTERNAL]: Re: [EXTERNAL]: Re: UPSERT in Postgres

2023-04-10 Thread Karsten Hilbert
Am Mon, Apr 10, 2023 at 01:33:41PM +0200 schrieb Francisco Olarte: > > > > This the part that's always eluded me: How does the client, the > > > > UPSERTer, come to hold an id and not know whether or not it's already in > > > > the database. > > > > > > This is extremely easy to do if you have

Re: [EXTERNAL]: Re: [EXTERNAL]: Re: UPSERT in Postgres

2023-04-10 Thread Karsten Hilbert
Am Mon, Apr 10, 2023 at 09:41:15AM +0200 schrieb Francisco Olarte: > On Mon, 10 Apr 2023 at 04:16, Rob Sargent wrote: > > > An UPSERT checks whether a row exists, if so, it does an update, if not > > > it does an insert. This is the literal definition. > > This the part that's always eluded me:

Aw: Re: Thanks! Re: Who adds the "start transaction" and "commit" to the intended SQL statement in "autocommit" mode?

2023-02-21 Thread Karsten Hilbert
> >> b...@yugabyte.com wrote: > >> > >> I’ve no idea how I might have found this without human help. > > > > x...@thebuild.com wrote: > > > > That sounds like an excellent documentation patch! > > Well, it’s already documented clearly enough. The question is how to find > it—especially if you

Aw: Re: REINDEX vs VACUUM

2023-01-05 Thread Karsten Hilbert
> Von: "Peter J. Holzer" > On 2023-01-04 09:34:42 -0600, Ron wrote: > > I don't think VACUUM FULL (copy the table, create new indices and other > > metadata all in one command) actually vacuums tables.  It's a misleading > > name. > > Move all the stuff from the living room to the bedroom and

Re: dropped default locale

2022-12-21 Thread Karsten Hilbert
Am Wed, Dec 21, 2022 at 03:46:48PM +0100 schrieb Karsten Hilbert: > I wasn't so sure whether inserting appropriate > rows would be equivalent to create collation... For that matter, is DELETE FROM pg_collation ... equivalent to DROP COLLATION ? Thanks, Karsten -- GPG 40BE 5B0E C98E 171

Re: dropped default locale

2022-12-21 Thread Karsten Hilbert
Am Wed, Dec 21, 2022 at 03:41:24PM +0100 schrieb Laurenz Albe: > I would definitely go for the backup, but here is how you can > create these three rows in PostgreSQL v15: > > INSERT INTO pg_collation > (oid, collname, collnamespace, collowner, collprovider, > collisdeterministic,

dropped default locale

2022-12-21 Thread Karsten Hilbert
Dear all, I managed to drop the "special" collations default, C, and POSIX with OIDs 100, 950, 951. Is there a way to recreate them (short of restoring a backup) ? Naive attempts with create collation do not seem to work out. Thanks, Karsten -- GPG 40BE 5B0E C98E 1713 AFA6 5BC0 3BEA AC80 7D4F

Re: plpgsql_check_function issue after upgrade

2022-12-05 Thread Karsten Hilbert
Am Mon, Dec 05, 2022 at 03:54:28PM +0530 schrieb shashidhar Reddy: > Is there any way to get the older version 1.1 of plpgsql_check to install > it? Is there any way to get you to respect the kind requests to follow this list's posting customs as expressed by the very people you want to help you

Re: Q: error on updating collation version information

2022-12-04 Thread Karsten Hilbert
Is this to be expected ? PG 15.1 on Debian: gnumed_v22=# select *, pg_collation_actual_version(oid), pg_encoding_to_char(collencoding) from pg_collation where collname = 'zh_TW'; -[ RECORD 1 ]---+ oid | 12985

Re: Stored procedure code no longer stored in v14 and v15, changed behaviour

2022-12-04 Thread Karsten Hilbert
Am Sun, Dec 04, 2022 at 06:05:30PM +0100 schrieb Alban Hertroys: > > I mean, pg_get_functiondef output being a server runtime artifact it might > > well change between server versions, no ? > > I meant to write: “I would also generate new diffs right > _before and_ after…”, precisely for that

Re: Q: error on updating collation version information

2022-12-04 Thread Karsten Hilbert
Am Sun, Dec 04, 2022 at 10:09:47AM -0800 schrieb Adrian Klaver: > >>following an ICU upgrade, collations in a stock Debian PG 15.1 > >>cluster now have divergent version information in pg_collations. > > > >Correction: this is following a libc upgrade 2.35 -> 2.36 > > So to be clear this database

Re: Q: error on updating collation version information

2022-12-04 Thread Karsten Hilbert
Am Sun, Dec 04, 2022 at 01:22:02PM +0100 schrieb Karsten Hilbert: > following an ICU upgrade, collations in a stock Debian PG 15.1 > cluster now have divergent version information in pg_collations. Correction: this is following a libc upgrade 2.35 -> 2.36 Karsten -- GPG 40BE 5B0E

Re: Q: error on updating collation version information

2022-12-04 Thread Karsten Hilbert
Am Sun, Dec 04, 2022 at 01:22:02PM +0100 schrieb Karsten Hilbert: > gnumed_v22=> ALTER COLLATION pg_catalog."br_FR@euro" REFRESH VERSION; > ERROR: collation "pg_catalog.br_FR@euro" for encoding "UTF8" does not > exist The OS (libc) does see

Q: error on updating collation version information

2022-12-04 Thread Karsten Hilbert
Dear all, following an ICU upgrade, collations in a stock Debian PG 15.1 cluster now have divergent version information in pg_collations. Now gnumed_v22=> ALTER COLLATION pg_catalog."br_FR@euro" REFRESH VERSION; ERROR: collation "pg_catalog.br_FR@euro" for encoding "UTF8" does

Aw: Re: Stored procedure code no longer stored in v14 and v15, changed behaviour

2022-12-03 Thread Karsten Hilbert
> You would need to wrap the function creation calls into some automation to > generate and store those diffs, comparing it back, etc, but that may be > doable. I would also generate new diffs right after major version updates of > the database (a before and after of the output of

Re: Getting PSQL in Windows to support TAB/Autocomplete via modified readline...

2022-11-23 Thread Karsten Hilbert
Am Tue, Nov 22, 2022 at 11:59:59PM -0500 schrieb Kirk Wolak: > > It's OK to post a work-in-progress patch to pgsql-hackers, even if it > > doesn't work right yet. With any luck, people will show up to help > > with problems. I am 100% sure that our Windows user community would > > love this

Re: Q: fixing collation version mismatches

2022-11-14 Thread Karsten Hilbert
Am Mon, Nov 14, 2022 at 05:42:16PM +0100 schrieb Daniel Verite: > > Which is why my question still stands: does the above > > three-strikes operation safely take care of any collation > > issues that may currently exist in a database ? > > For the indexes, yes, but theorically, all constraints

Re: Q: fixing collation version mismatches

2022-11-13 Thread Karsten Hilbert
Am Sun, Nov 13, 2022 at 12:46:53PM -0800 schrieb Christophe Pettus: > > On Nov 13, 2022, at 12:45, Karsten Hilbert wrote: > > REINDEX DATABASE db_in_question; > > ALTER DATABASE db_in_question REFRESH COLLATION VERSION; > > ALTER COLLATION every_collation_f

Q: fixing collation version mismatches

2022-11-13 Thread Karsten Hilbert
Dear all, just to confirm my understanding: Is it correct to say that the following sequence will "fix" all current collation version issues in a given database ? REINDEX DATABASE db_in_question; ALTER DATABASE db_in_question REFRESH COLLATION VERSION; ALTER COLLATION

Aw: Re: Q: documentation improvement re collation version mismatch

2022-11-10 Thread Karsten Hilbert
> > The comment above the query in the official documentation is rather > > assertive > > (even if may true to the letter) and may warrant some more cautionary > > wording ? Added, perhaps, some variation of this: > > > > > For now, the only safe way to go is either reindex everything, or > >

Aw: Re: Q: documentation improvement re collation version mismatch

2022-11-10 Thread Karsten Hilbert
Thanks, Julien, for your explanation. > > regarding changed collation versions this > > > > https://www.postgresql.org/docs/devel/sql-altercollation.html > > > > says: > > > > The following query can be used to identify all > > collations in the current database that need to be > >

Q: documentation improvement re collation version mismatch

2022-11-09 Thread Karsten Hilbert
Dear all, regarding changed collation versions this https://www.postgresql.org/docs/devel/sql-altercollation.html says: The following query can be used to identify all collations in the current database that need to be refreshed and the objects that depend on

Aw: Information to CVE-2022-42889

2022-11-08 Thread Karsten Hilbert
> the german bureau for IT-Security "BSI" (Bundesamt für Sicherheit in der > Informationstechnik) has issued a warning for CVE CVE-2022-42889 with the > name commons-text. Insurance companies are obliged to analyse the installed > software for vulnerabilities of this type. As the Barmenia is

Aw: Re: Putting the O/S user for "local" "peer" authentication in the "postgres" group vs chmod'ing the "pg*.conf" files to be readable by "all"

2022-11-01 Thread Karsten Hilbert
> The client user should *never* read the PostgreSQL configuration files, so if > changing > the permissions (which you should *never* do) has an effect, you must be > doing something > very strange, like trying to start the database server with the wrong user. It smells of trying to *embed*

Re: "peer" authentication: cannot make "pg_ident.conf" work as I believe that the doc says that it should

2022-10-30 Thread Karsten Hilbert
Am Sat, Oct 29, 2022 at 09:15:08PM -0700 schrieb Adrian Klaver: > >*# MAPNAME    SYSTEM-USERNAME   PG-USERNAME* > >*# ---    ---   --- > >   bllewell   mary              mary > >* > > > > > >As has been said numerous times, it is utterly pointless to define

Re: "peer" authentication: cannot make "pg_ident.conf" work as I believe that the doc says that it should

2022-10-30 Thread Karsten Hilbert
Am Sat, Oct 29, 2022 at 08:20:50PM -0700 schrieb Bryn Llewellyn: > For the purpose of the tests that follow, I set up the O/S users "bob" and > "mary" so that "id bob mary postgres" shows this: > > id=1002(bob) gid=1001(postgres) groups=1001(postgres) > uid=1003(mary)

Aw: Re: How to store "blobs" efficiently for small and large sizes, with random access

2022-10-20 Thread Karsten Hilbert
> I don't know what exactly they are, but I suspect that they are just > files (segments?) in Oracle's "file system" (tablespaces/datafiles). > So pretty much what we recommend. Maybe so, but if those large segments are presented "seamlessly" in the form of a table integrated with PGs

Aw: Re: ('dog$house' = quote_ident('dog$house')) is surprisingly FALSE

2022-10-06 Thread Karsten Hilbert
What we deal with in our ordinary professional work is SQL texts, program source texts, within these, SQL identifier texts, and then the conventional display of the results of SQL and program execution. To emphasize the point about resulst display, try "\d s.*" in "\t off" mode. You'll see

Aw: Re: I slipped up so that no existing role allows connection. Is rescue possible?

2022-09-20 Thread Karsten Hilbert
> Yes, after Tom's hint, a search for "single-user" took me to that page. But, > beginner as I am, > I didn't know that single-user mode was the thing that I needed. I need a > remedial class. > Something like "PostgreSQL for those whose mental model has been conditioned > by decades of working

Re: Is it possible to stop sessions killing eachother when they all authorize as the same role?

2022-09-14 Thread Karsten Hilbert
Am Wed, Sep 14, 2022 at 10:10:30AM +0200 schrieb Karsten Hilbert: > Am Tue, Sep 13, 2022 at 05:10:58PM -0400 schrieb Tom Lane: > > > (I recall that somewhere we have some code that warns about no-op > > grants. I wonder if issuing a warning for no-op revokes would be > &

Re: Is it possible to stop sessions killing eachother when they all authorize as the same role?

2022-09-14 Thread Karsten Hilbert
Am Tue, Sep 13, 2022 at 05:10:58PM -0400 schrieb Tom Lane: > (I recall that somewhere we have some code that warns about no-op > grants. I wonder if issuing a warning for no-op revokes would be > helpful.) Surely, in the light of security a no-op revoke is potentially more dangerous than a

Aw: Re: toast useless

2022-09-13 Thread Karsten Hilbert
Gesendet: Dienstag, 13. September 2022 um 19:13 Uhr Von: "Ron" An: pgsql-general@lists.postgresql.org Betreff: Re: toast useless On 9/13/22 08:18, Simon Riggs wrote: On Tue, 13 Sept 2022 at 13:29, Marcos Pegoraro wrote: What problem do they cause you? They don't cause any problem, I

Aw: Re: Surprising results from current_role in a "security invoker" trigger function in a "cascade delete via FK" scenario

2022-08-11 Thread Karsten Hilbert
I'll be happy to make a smaller example. It will, however, need to create users, a database, schemas, and some number of triggers. Because the triggers, their functions, and everything else about them follow a pattern, I can use "format()" and dynamic SQL to generate them. I'll still need those

Re: Concurrent INSERT statements with RETURNING clause resetting SERIAL sequence

2022-07-20 Thread Karsten Hilbert
Am Wed, Jul 20, 2022 at 09:15:29AM + schrieb Sebastien Flaesch: > Thomas, we already have a similar solution. > The idea is to use the native PostgreSQL SERIAL type. Which does not guarantuee gaplessness. Karsten -- GPG 40BE 5B0E C98E 1713 AFA6 5BC0 3BEA AC80 7D4F C89B

Re: lifetime of the old CTID

2022-07-06 Thread Karsten Hilbert
> Said this, we can end this thread. Re-think the data model is not an > option. Why not ? - add a primary key to each table, say db01buch.pk - rename tables, say db01buch -> db01buch__real_table - add views, say db01buch over db1buch__real_table with "pk AS ctid"

Re: lifetime of the old CTID

2022-07-06 Thread Karsten Hilbert
Am Wed, Jul 06, 2022 at 08:41:58AM +0200 schrieb Laurenz Albe: > Using the primary key is the proper solution. To be safe from concurrent > modifications, use a logic like in this pseudo-code: > > FOR b IN SELECT pk, other_columns FROM books WHERE condition >UPDATE books SET ... WHERE pk =

Re: lifetime of the old CTID

2022-07-06 Thread Karsten Hilbert
Am Wed, Jul 06, 2022 at 08:18:42AM +0200 schrieb Matthias Apitz: > > On first glance, it appears that you are using the ctid as a primary key > > for a row, and that's highly not-recommended. The ctid is never intended > > to be stable in the database, as you have discovered. There are really

Aw: How to set password in psql -h -d -U command line?

2022-04-28 Thread Karsten Hilbert
> I tried various ways to set password in psql command line, but got no luck. Have you tried all the methods that you showed in your mail or did you try others as well ? Best regards, Karsten

Re: PG14: "is of" vs pg_typeof

2022-04-23 Thread Karsten Hilbert
Am Sat, Apr 23, 2022 at 01:43:52PM -0700 schrieb Adrian Klaver: > > select pg_typeof('a'::text) = any(ARRAY[pg_typeof(''::text), > > pg_typeof(''::name)]); > > > >Is there anything obvious I am missing for easily > >resurrecting the above "is of" use ? > > Actually it can be done as: > >

Re: PG14: "is of" vs pg_typeof

2022-04-23 Thread Karsten Hilbert
Am Sat, Apr 23, 2022 at 10:14:03PM +0200 schrieb Karsten Hilbert: > I can't find anything in the changelog saying that "is of" > was removed. For what it's worth, nothing in the docs ever > said it existed either (though it did, as per real life). Oh, wait, https:/

PG14: "is of" vs pg_typeof

2022-04-23 Thread Karsten Hilbert
PostgreSQL 14.2-1 Dear readers, it used to be possible to say (inside plpgsql): if _value is of (text, char, varchar, name) then val_type := ''string''; elsif _value is of (smallint, integer, bigint, numeric, boolean) then val_type := ''numeric'';

Re: Transaction and SQL errors

2022-04-04 Thread Karsten Hilbert
Am Mon, Apr 04, 2022 at 11:33:14AM + schrieb Sebastien Flaesch: > Is there any plan to have an equivalent of psql's > > set ON_ERROR_ROLLBACK on > > in the DB engine? That is already what happens. SQL fails, transaction rolls back. Karsten -- GPG 40BE 5B0E C98E 1713 AFA6 5BC0 3BEA AC80

Aw: Re: How long does iteration over 4-5 million rows usually take?

2022-04-02 Thread Karsten Hilbert
> > On Apr 1, 2022, at 10:18 PM, Ron wrote: > > > >  On 4/1/22 20:34, Shaozhong SHI wrote: > >> > >> I have a script running to iterate over 4-5 million rows. It keeps > >> showing up in red in PgAdmin. It remains active. > >> > >> How long does iteration over 4-5 million rows usually

Aw: Additional accessors via the Extension API ?

2022-02-20 Thread Karsten Hilbert
> Suppose I have defined an additional type in a PG extension. > > Is it possible to add custom accessors to that type -much like jsonb does- > but use an API/hook without touching the core PG grammar & parser? > > Hypothetical Examples: > > Assuming I have a TextFile type I’d like to

Re: Is there a way to automatically scan a table and determine the format of data

2022-02-16 Thread Karsten Hilbert
Am Wed, Feb 16, 2022 at 01:27:56AM + schrieb Shaozhong SHI: > Is there a way to automatically scan a table and report the format of data > for each column? pg_class But you may want to rethink the approach given that you use Python. Karsten -- GPG 40BE 5B0E C98E 1713 AFA6 5BC0 3BEA AC80

Aw: Operator % and its meaning and use

2022-02-15 Thread Karsten Hilbert
Dear David, > Can anyone remind me of the meaning and use of operator %.   I can gladly report that I remember having seen relevant documentation on that operator while Reading up in The Fine Manual on json_to_row following the hint Ion kindly provided. It was amazing ! Reading up on that

Re: Proposed German Translation of Code of Conduct Policy

2022-02-10 Thread Karsten Hilbert
Am Thu, Feb 10, 2022 at 03:24:54PM +0500 schrieb Umair Shahid: > > What happens if all members of the committee are impeached at once ? > > > > That is one reason to strive for diversity in the CoC Committee - the > chances of this happening are reduced to near-zero. It may be near-zero for

Re: Can we go beyond the standard to make Postgres radically better?

2022-02-10 Thread Karsten Hilbert
Am Wed, Feb 09, 2022 at 09:14:39PM -0800 schrieb Guyren Howe: > There are huge developer benefits available to focusing > more on making a great relational programming environment, > well outside the SQL standard. There's a seemingly small but conceptually rather significant difference between

Re: Counting the number of repeated phrases in a column

2022-02-01 Thread Karsten Hilbert
Am Tue, Feb 01, 2022 at 11:29:50PM + schrieb Shaozhong SHI: > How about knock unique words into discrete joint up strings? Then check > whether there is any repeated words? Does it work when you try ? Karsten -- GPG 40BE 5B0E C98E 1713 AFA6 5BC0 3BEA AC80 7D4F C89B

Re: Counting the number of repeated phrases in a column

2022-01-26 Thread Karsten Hilbert
Am Wed, Jan 26, 2022 at 08:35:06PM + schrieb Shaozhong SHI: > Whatever. Can we try to build a regex for 'The City of London London > Great London UK ' ? Would you be so kind as do be more specific about that "we" ? Best, Karsten -- GPG 40BE 5B0E C98E 1713 AFA6 5BC0 3BEA AC80 7D4F C89B

Aw: Re: Counting the number of repeated phrases in a column

2022-01-25 Thread Karsten Hilbert
> How about split up the value into individual words and keep their orders? > add words up to form individual phrase and ensure that each phrase only > consists unique/distinct words > count repeated phrases afterward >   > How about this? Sure, if that serves your purpose ? So far, we (I?)

Aw: Counting the number of repeated phrases in a column

2022-01-25 Thread Karsten Hilbert
> There is a short of a function in the standard Postgres to do the following: >   > it is easy to count the number of occurrence of words, but it is rather > difficult to count the number of occurrence of phrases. >   > For instance: >   > A cell of value:  'Hello World' means 1 occurrence a

Re: Proposed German Translation of Code of Conduct Policy

2022-01-24 Thread Karsten Hilbert
t, mit der Ausnahme, dass die > Person, die in die Beschwerde involviert ist, in ihrer > Funktion im Komitee oder dem Core-Team vom Verfahren > ausgeschlossen wird. What happens if all members of the committee are impeached at once ? > Die Komitee kann feststellen, dass ein Verstoß gegen

Re: a very naive question about table names in Postgres

2021-12-31 Thread Karsten Hilbert
Am Fri, Dec 31, 2021 at 08:27:59PM + schrieb Martin Mueller: > I much prefer Postgres to Mysql for a variety of reasons, > but mostly for its elegant string functions. But in Mysql it > seems to be much easier to keep track of tables. May I ask for the context of "keep track of tables" ?

Re: How to allow null as an option when using regexp_matches?

2021-12-08 Thread Karsten Hilbert
Am Wed, Dec 08, 2021 at 12:07:13PM + schrieb Shaozhong SHI: > We can do this: > select count(*) from regexp_matches('Great London', 'Great > London|Information Centre|Department for Transport', 'g'); > > Is it possible to allow null as an option? something like this > select count(*) from

Re: check scripts after database code change

2021-11-18 Thread Karsten Hilbert
Am Thu, Nov 18, 2021 at 05:45:37PM +0300 schrieb Dennis: > Are there any scripts that we can check after the changes we made in the > database code? > In summary, are there any automatic post-development scripts before they > come to the beta stage? What do you want those script to do ? Karsten

Re: Fault with initcap

2021-10-12 Thread Karsten Hilbert
Am Tue, Oct 12, 2021 at 09:50:16PM +0100 schrieb Shaozhong SHI: > There must be a way to do the following. > > [...] Only the first letter of each word should be capitalised. Indeed, there is. It is called "human brain in cultural context". "AI" is close nowadays, but, hopefully, not quite there

Aw: Re: Re: Fault with initcap

2021-10-12 Thread Karsten Hilbert
> Only the first letter of each word to be capitalised/uppercased. The next step is to not top-post. Then to keep the list involved if you wish further help. Then, if you are intent on using regular expressions, look at the PostgreSQL docs for regexp_replace. Karsten  

Aw: Re: Fault with initcap

2021-10-12 Thread Karsten Hilbert
Hi David, >Expected are as follows: >Notemachine >Sainsbury's bank. Now, step two: generalize that exemplary definition. Karsten

Re: PostgreSQL CHECK Constraint

2021-10-03 Thread Karsten Hilbert
GPG 40BE 5B0E C98E 1713 AFA6 5BC0 3BEA AC80 7D4F C89B -- Karsten Sure, they are just a search engine's use away. > Are there any examples on the web these days? > That sounds brilliant. :Am Sun, Oct 03, 2021 at 07:44:41PM +0100 schrieb Shaozhong SHI

Re: PostgreSQL CHECK Constraint

2021-10-03 Thread Karsten Hilbert
Am Sun, Oct 03, 2021 at 07:16:32PM +0100 schrieb Shaozhong SHI: > That is interesting. Can errors be captured and saved as data with > scripting? Depends on what the script does. If the script runs (or is written in) Python the canonical PG driver (psycopg2/3) will give you such data. Karsten

Re: pg_dump save command in output

2021-10-03 Thread Karsten Hilbert
Am Sun, Oct 03, 2021 at 06:15:54PM +0100 schrieb Joao Miguel Ferreira: > I just wanted to save the command inside the SQL file to be able to > "remember" it later. ideally I would open the file on some text editor and > see the original pg_dump command on the few first lines, as a comment > > --

Re: PostgreSQL - Ordering Table based of Foreign Key

2021-10-03 Thread Karsten Hilbert
Am Sun, Oct 03, 2021 at 08:48:13AM +0100 schrieb FOUTE K. Jaurès: > I want to order tables based on the foreign key so that I can delete tables > one by one without facing "ERROR: update or delete on table "table" > violates foreign key constraint. DETAIL: Key is still referenced from table"

Re: Timestamp with vs without time zone.

2021-09-22 Thread Karsten Hilbert
Am Wed, Sep 22, 2021 at 08:11:50PM +1200 schrieb Tim Uckun: > A korean user will fetch you single page app as static HTML from S3 > with cloudfront. It will hit your japanese API server, which will > fetch the data from your japanese read only replica with the master > being in Australia. > >

Aw: Re: Re: Timestamp with vs without time zone.

2021-09-21 Thread Karsten Hilbert
> It's just that the phrase > "timestamp with time zone" would seem to indicate the time zone is > stored somewhere in there. Now, I can fully agree with _that_ :-) Karsten

Aw: Re: Re: Timestamp with vs without time zone.

2021-09-21 Thread Karsten Hilbert
> > > It seems like it would be so much more useful if the timestamp with > > > time zone type actually stored the time zone in the record. > > > > Which one ? > > > One specified by the user. Many date formats carry either an offset > or the time zone information. What would that TZ mean,

Aw: Re: Timestamp with vs without time zone.

2021-09-21 Thread Karsten Hilbert
> > It seems like it would be so much more useful if the timestamp with > > time zone type actually stored the time zone in the record. > > This has been requested before, and it would be closer to the intention > of the SQL standard, but I guess it won't happen. > > For one, it would change

Aw: Re: Timestamp with vs without time zone.

2021-09-21 Thread Karsten Hilbert
> It seems like it would be so much more useful if the timestamp with > time zone type actually stored the time zone in the record. Which one ? Karsten

Re: Issue with a query while running on a remote host

2021-08-27 Thread Karsten Hilbert
Deep packet inspection naively scanning for potential fragments of bash scripts being transferred ? Karsten Am Fri, Aug 27, 2021 at 12:32:09PM +0530 schrieb Ninad Shah: > Date: Fri, 27 Aug 2021 12:32:09 +0530 > From: Ninad Shah > To: pgsql-general > Subject: Issue with a query while running on

Re: PostgreSQL reference coffee mug

2021-08-07 Thread Karsten Hilbert
Am Fri, Aug 06, 2021 at 08:09:03PM +0200 schrieb Matthias Apitz: > The prototype is ready. Nice. Now the elephant needs to fade into the background. Karsten -- GPG 40BE 5B0E C98E 1713 AFA6 5BC0 3BEA AC80 7D4F C89B

Re: pg_dump/pg_restore vs default_transaction_read_only under PG 13.2

2021-06-25 Thread Karsten Hilbert
Am Fri, Jun 25, 2021 at 11:39:46AM +0200 schrieb Karsten Hilbert: > I would be happy to hope that pg_dump might ... > gain a --do-not-alter-database-to-read-only or even a --(pre|post)-dump-sql=(pre|post).sql allowing for (here) temporarily altering a role to default_transaction_read_on

Re: pg_dump/pg_restore vs default_transaction_read_only under PG 13.2

2021-06-25 Thread Karsten Hilbert
> >And this is the restore: > > > sudo -u postgres psql -d postgres -f create_database.sql > > sudo -u postgres pg_restore --verbose --create --dbname=template1 > > --exit-on-error -p ${GM_PORT} ${BACKUP}.dir/ > Remove --create and change dbname to the database name from >

Re: pg_dump/pg_restore vs default_transaction_read_only under PG 13.2

2021-06-20 Thread Karsten Hilbert
Am Sun, Jun 20, 2021 at 01:14:06PM -0700 schrieb Adrian Klaver: > >Any chance pg_dump (and/or pg_restore) might gain an option > >--ignore-read-only ? That way, PostgreSQL need not decide > >for users. > > How about: > > 1) pg_dump -Fc -d read_only_db -U postgres -f read_only.out > > 2) In new

Re: pg_dump/pg_restore vs default_transaction_read_only under PG 13.2

2021-06-20 Thread Karsten Hilbert
Am Sun, Jun 20, 2021 at 09:34:45PM +0200 schrieb Karsten Hilbert: > Any chance pg_dump (and/or pg_restore) might gain an option > --ignore-read-only ? That way, PostgreSQL need not decide > for users. Or, options --pre-dump-sql and -post-dump-sql ? Users could then run setup/tea

Re: pg_dump/pg_restore vs default_transaction_read_only under PG 13.2

2021-06-20 Thread Karsten Hilbert
Am Sun, Jun 20, 2021 at 01:47:47PM -0400 schrieb Tom Lane: > Hence, the only way to make this scenario work would be for the > restore script to explicitly override default_transaction_read_only. [...] > Also, doing so would result in ignoring default_transaction_read_only > no matter what the

Re: pg_dump/pg_restore vs default_transaction_read_only under PG 13.2

2021-06-20 Thread Karsten Hilbert
Dear Jain, > Did I simulate your concern correctly ? Nearly so, to my understanding. What you did (and thanks for the followup) was ... > postgres@db:~/playground/logical_replication$ rm -rf example > postgres@db:~/playground/logical_replication$ initdb -D example 2>/dev/null > >/dev/null >

pg_dump/pg_restore vs default_transaction_read_only under PG 13.2

2021-06-20 Thread Karsten Hilbert
Dear all, I am testing the pg_restore of a database with default_transaction_read_only=on. The following issue ensues sudo -u postgres pg_restore --verbose --create --dbname=template1 --exit-on-error -p 5432

  1   2   >