Re: Who am I? Where am I connected?

2022-05-18 Thread Erik Wienhold
Hi Dominique, you can use \conninfo in psql to show the database, user, host (or socket in my example), and port: ewie@desktop ~ $ psql test Null display is "". psql (14.3) Type "help" for help. test=# \conninfo You are connected to database "test" as user "ewie" via socket in "/run/postgresql

Re: Support for dates before 4713 BC

2022-08-23 Thread Erik Wienhold
> On 23/08/2022 14:38 CEST Peter J. Holzer wrote: > > > On 2022-08-23 10:25:12 +0100, Simon Riggs wrote: > > On Mon, 22 Aug 2022 at 11:14, stefan eichert > > wrote: > > > In order to deal with all dates, historical and prehistoric ones, in > > > a consistent way, the implementation of times

Re: 10.22 Windows binaries download? (zip "invalid" on Enterprisedb)

2022-09-21 Thread Erik Wienhold
> On 21/09/2022 15:34 CEST Thomas, Richard > wrote: > > I’m trying to download the Windows x64 binaries only for PostgreSQL 10.22 in > order to perform a minor upgrade. However, the download > (postgresql-10.22-1-windows-x64-binaries.zip) from my usual go-to place: > (https://www.enterprisedb

Re: Playing with pgcrypto

2022-10-10 Thread Erik Wienhold
Hi Howard, > On 11/10/2022 00:25 CEST howardn...@selestial.com wrote: > > I am trying out a few pgcrypto functions. I was expecting the final > select statement to return the row I just inserted - Can anyone tell me > what I am not understanding here? > > create table test (p1 bytea); > insert

Re: Exponentiation confusion

2022-10-13 Thread Erik Wienhold
> On 13/10/2022 18:20 CEST Adrian Klaver wrote: > > In trying to answer an SO question I ran across this: > > Postgres version 14.5 > > select 10^(-1 * 18); > ?column? > -- > 1e-18 > > select 10^(-1 * 18::numeric); >?column? > > 0.

Re: Exponentiation confusion

2022-10-13 Thread Erik Wienhold
> On 13/10/2022 19:16 CEST Tom Lane wrote: > > Erik Wienhold writes: > > On 13/10/2022 18:20 CEST Adrian Klaver wrote: > >> select power(10, -18::numeric); > >> power > >> > >> 0. > >> > &

Re: Cannot restore windows dump on linux

2022-10-19 Thread Erik Wienhold
> On 19/10/2022 17:43 CEST ertan.kucuko...@1nar.com.tr wrote: > > I am using PostgreSQL 14.5 > > I tried to move a Linux database to Windows. Both identical version. > Linux dump successfully loaded on Windows system. > Reason for changing system didn’t work out and now I am trying to move it back

Re: Column value derived from generated column in INSERT?

2022-10-19 Thread Erik Wienhold
> On 19/10/2022 23:51 CEST Adrian Klaver wrote: > > On 10/19/22 12:58 PM, Adrian Klaver wrote: > > On 10/19/22 12:48, Mark Raynsford wrote: > >> On 2022-10-19T12:43:31 -0700 > >> Adrian Klaver wrote: > >>> > >>> HINT:  There is an entry for table "t", but it cannot be referenced from > >>> this p

Re: How to remove the partition from table .

2022-10-25 Thread Erik Wienhold
> On 25/10/2022 12:47 CEST Rakesh Nashine wrote: > > We would like to remove the partition from one of the tables , although that > partition has some business data. Now business doesn't need that partition > any more .. How could we remove it? although they need the data . Detach the partition:

Re: How to add a variable to a timestamp.

2022-10-29 Thread Erik Wienhold
> On 29/10/2022 19:35 CEST Eagna wrote: > > I'm trying to do something like this. > > SELECT > d.i, > h.i, > > '2022-10-31 00:00:00'::TIMESTAMP + INTERVAL 'd.i DAY' > FROM > GENERATE_SERIES(0, 6) AS d(i), > GENERATE_SERIES(0, 23) AS h(i); > > where I add d.i days (and also h.i hours) to a timestam

Re: Off-topic? How to extract database statements from JPA?

2022-10-31 Thread Erik Wienhold
> On 31/10/2022 11:50 CET Gus Spier wrote: > > I apologize if this is off-topic, but I've become exceedingly frustrated and > need help. > > The assignment is to evaluate SQL code for an application that has been built > with Java Springer Persistence API and, if appropriate, offer suggestions to

Re: an difficult SQL

2022-11-06 Thread Erik Wienhold
> On 06/11/2022 13:48 CET Rafal Pietrak wrote: > > W dniu 5.11.2022 o 19:05, Thiemo Kellner pisze: > > > > You first could select the three users with the most recent entries with > > a windowing function > > (https://www.postgresql.org/docs/15/sql-expressions.html#SYNTAX-WINDOW-FUNCTIONS) > > sur

Re: Information to CVE-2022-42889

2022-11-08 Thread Erik Wienhold
> On 08/11/2022 11:50 CET Cedric Aaron Towstyka > wrote: > > the german bureau for IT-Security "BSI" (Bundesamt für Sicherheit in der > Informationstechnik) has issued a warning for CVE CVE-2022-42889with the name > commons-text. Insurance companies are obliged to analyse the installed > software

Re: copying json data and backslashes

2022-11-22 Thread Erik Wienhold
> On 22/11/2022 15:23 CET Alastair McKinley > wrote: > > Hi all, > > I have come across this apparently common issue COPY-ing json and wondering if > there is potentially a better solution. > > I am copying data into a jsonb column originating from a 3rd party API. The > data may have literal \r,

Re: copying json data and backslashes

2022-11-22 Thread Erik Wienhold
> On 22/11/2022 20:11 CET p...@cmicdo.com wrote: > > On Tuesday, November 22, 2022 at 01:16:02 PM EST, Peter J. Holzer > wrote: > > > On 2022-11-22 17:39:04 +, Alastair McKinley wrote: >  > > > \copy footable from 'input.json' (format csv, escape '^B', delimieter > '^C > ', quote '^E') >  >

Re: Get table catalog from pg_indexes

2022-11-27 Thread Erik Wienhold
> On 27/11/2022 18:22 CET Igor Korot wrote: > > Table pg_indexes does not contain a field for a catalog. > > So how do I get that? > > SELECT 1 FROM pg_indexes WHERE indexname = $1 AND tablename = $2 AND > schemaname = $3 Use SELECT current_database() if you need to know the catalog. pg_indexes o

Re: Views "missing" from information_schema.view_table_usage

2022-12-02 Thread Erik Wienhold
> On 02/12/2022 21:51 CET Jonathan Lemig wrote: > > Has anybody ever encountered this, and if so, did you find a resolution? > Or perhaps there other limitations with the VTU that I'm unaware of? Is the one view you cannot find in view_table_usage a materialized view? Because those are not covere

Re: Views "missing" from information_schema.view_table_usage

2022-12-02 Thread Erik Wienhold
> On 02/12/2022 22:33 CET Erik Wienhold wrote: > > > > On 02/12/2022 21:51 CET Jonathan Lemig wrote: > > > > Has anybody ever encountered this, and if so, did you find a resolution? > > Or perhaps there other limitations with the VTU that I'm unaware of

Re: Views "missing" from information_schema.view_table_usage

2022-12-02 Thread Erik Wienhold
> On 02/12/2022 22:55 CET Jonathan Lemig wrote: > > drps=> select viewowner, schemaname, viewname from pg_views where viewname = > 'platform_version_v'; >  viewowner | schemaname | viewname > ---++ >  drps | event | platform_version_v > (1 row) > > drps=> s

Re: Views "missing" from information_schema.view_table_usage

2022-12-02 Thread Erik Wienhold
gt; indeed the issue. The object that the view is querying is a materialized > > view. > > > > Thanks for the link. > > > > Jon > > > > > > On Fri, Dec 2, 2022 at 3:33 PM Erik Wienhold wrote: > > > > On 02/12/2022 21:51 CET Jonathan Lemig wrote:

Re: impact join syntax ?? and gist index ??

2023-01-07 Thread Erik Wienhold
> On 07/01/2023 20:46 CET Marc Millas wrote: > > Hi, > > postgres 12, postgis 3.0 > > I have a small table A, 11 rows with a varchar column x and a geometry column > y. > gist index on the geometry column. > the geometry do contains multipolygons (regions on a map) > I have a second table B , sam

Re: How do the Linux distributions create the Linux user/group "postgres"?

2023-01-09 Thread Erik Wienhold
> On 09/01/2023 13:41 CET Matthias Apitz wrote: > > Hello, > > Please note: I'm talking about the user and group "postgres" in the > Linux OS and not in the PostgreSQL server. > > We're compiling PostgreSQL from source (actually 14.1) and distribute that > to our customers. They're asked to setup

Re: Why is a Read-only Table Gets Autovacuumed "to prevent wraparound"

2023-01-16 Thread Erik Wienhold
> On 16/01/2023 13:48 CET Fred Habash wrote: > > This is a puzzle I have not been able to crack yet. > > We have a single-page table with 28 rows that is purely read-only. There isn't > a way in postgres to make a table RO, but I say this with confidence because > pg_stat_user_tables has always sh

Re: Interpreting postgres execution plan along with AND/OR precedence

2023-01-18 Thread Erik Wienhold
> On 18/01/2023 18:56 CET Tom Lane wrote: > > "Dirschel, Steve" writes: > > Filter: ... (alternatives: SubPlan 1 or hashed SubPlan 2) ... > > SubPlan 1 > >-> Index Scan using ix_lm_cc on lm_queue lmq2 > > (cost=0.40..177.93 rows=1 width=0) > > Ind

Re: Interpreting postgres execution plan along with AND/OR precedence

2023-01-18 Thread Erik Wienhold
> On 18/01/2023 18:03 CET Dirschel, Steve > wrote: > > The plan changes: > > Sort (cost=9382.94..9382.97 rows=12 width=169) > Sort Key: lmq1.priority DESC, lmq1.request_time > -> Bitmap Heap Scan on lm_queue lmq1 (cost=4572.59..9382.73 rows=12 width=169) > Recheck Cond: ((client_name)::text = 'WL

Re: Database size different on Primary and Standby?

2023-01-18 Thread Erik Wienhold
> On 19/01/2023 00:09 CET Hilbert, Karin wrote: > > I manage some PostgreSQL clusters on Linux. We have a Primary & two Standby > servers & for Production, there is also a DR server. We use repmgr for our HA > solution & the Standbys are cloned from the Primary using the repmgr standby > clone com

Re: Database size different on Primary and Standby?

2023-01-18 Thread Erik Wienhold
> On 19/01/2023 01:23 CET Ian Lawrence Barwick wrote: > > 2023年1月19日(木) 8:50 Erik Wienhold : > > > > > On 19/01/2023 00:09 CET Hilbert, Karin wrote: > > > > > > I manage some PostgreSQL clusters on Linux. We have a Primary & two > > > Sta

Re: Sequence vs UUID

2023-01-26 Thread Erik Wienhold
> On 26/01/2023 20:17 CET veem v wrote: > > Hello, We were trying to understand whether we should use UUID or Sequence in > general for primary keys. In many of the blogs (one is below) across multiple > databases, I saw over the internet and all are mostly stating the sequence is > better as comp

Re: Why is this SELECT evaluated?

2023-01-28 Thread Erik Wienhold
> On 28/01/2023 20:29 CET Miles Elam wrote: > > Postgres v15 > > Given this example of a conversion from a byte array to an int8 > masquerading as an "unsigned" int4 > > SELECT (get_byte(bytes, byte_offset)::int8 << 24) > | (get_byte(bytes, byte_offset + 1) << 16) >

Re: Sequence vs UUID

2023-01-28 Thread Erik Wienhold
> On 27/01/2023 01:48 CET Ron wrote: > > On 1/26/23 15:55, Erik Wienhold wrote: > > > > There are arguments against sequential PK, e.g. they give away too much > > info and > > allow attacks such as forced browsing[2]. The first I can understand: you > >

Re: Download file from COPY ... TO with pgadmin

2023-01-31 Thread Erik Wienhold
> On 31/01/2023 14:02 CET Marco Lechner wrote: > > Using COPY …TO it is possible to store e.g. the “value” of a bytea cell in a > directory on the server. E.g. by this: > > COPY (SELECT content FROM d_doc WHERE id = 'x123456') TO > CONCAT('/tmp/mydoc.pdf’) (FORMAT binary); > > As we do not have a

Re: How to create a new operator inpg for spec data type?

2023-01-31 Thread Erik Wienhold
> On 01/02/2023 06:40 CET jack...@gmail.com wrote: > > I need to create a new operator like '<->' and its syntax is that text1 <-> > text2, > for the usage like this: 'a' <-> 'b' = 'a1b1', so how could I realize this > one? > Can you give me some exmaples. https://www.postgresql.org/docs/curren

Re: database postgres not found

2023-02-01 Thread Erik Wienhold
> On 01/02/2023 11:33 CET Matthias Apitz wrote: > > Hello, > > I've a problem with a PostgreSQL 12.x server not setup or managed by me. that > the database 'postgres' is not found: > > $ psql -Upostgres postgres > psql: error: ERROR: no such database: postgres > > but the database is there as a S

Re: moving a database to a new 15.1 server

2023-02-01 Thread Erik Wienhold
> On 01/02/2023 13:24 CET Matthias Apitz wrote: > > The source database in the 12.11 server shows this: > > $ psql -Ulbs_lbsoclc01_dev_r1_dbo_u $DATABASE > psql (12.11) > Type "help" for help. > > lbs_lbsoclc01_dev_r1=> > lbs_lbsoclc01_dev_r1=> \d > List of relations

Re: From Clause Conditional

2023-02-02 Thread Erik Wienhold
> On 02/02/2023 13:54 CET Zahir Lalani wrote: > > Confidential > > Hello All > > We are testing a upgrade from pg11 to pg14 and have some issues to overcome. > One of these is that we have upgraded pgsodium to the latest and there is a > functional change – this question is not about sodium BTW. >

Switching identity column to serial

2023-02-03 Thread Erik Wienhold
I was wondering if it's possible to drop a column identity (not the column itself) while keeping the attached sequence. This would avoid recreating an identical sequence (especially with a correct start value and owner). Changing the sequence owner to NONE before dropping identity is not allowed.

Re: Switching identity column to serial

2023-02-03 Thread Erik Wienhold
> On 04/02/2023 01:54 CET Erik Wienhold wrote: > > I was wondering if it's possible to drop a column identity (not the column > itself) while keeping the attached sequence. This would avoid recreating > an identical sequence (especially with a correct start value and owne

Re: Switching identity column to serial

2023-02-04 Thread Erik Wienhold
> On 04/02/2023 05:41 CET Ron wrote: > > On 2/3/23 18:54, Erik Wienhold wrote: > > > I was wondering if it's possible to drop a column identity (not the column > > itself) while keeping the attached sequence. This would avoid recreating > > an identical sequen

Re: Slow down dev database transactions/second for testing?

2023-02-05 Thread Erik Wienhold
> On 05/02/2023 23:17 CET Richard Brockie wrote: > > I maintain a Django webapp that uses postgresql and can create inefficient > queries if I'm not careful. I'm looking for ways to mimic a congested db > server in development to expose these queries. pgbench is what your looking for: https://ww

Re: Understanding years part of Interval

2023-02-06 Thread Erik Wienhold
> On 06/02/2023 12:20 CET Marcos Pegoraro wrote: > > I was just playing with some random timestamps for a week, for a month, > for a year ... > > select distinct current_date+((random()::numeric)||'month')::interval from > generate_series(1,100) order by 1; > It´s with distinct clause because if

Re: Understanding years part of Interval

2023-02-06 Thread Erik Wienhold
> On 06/02/2023 18:33 CET Marcos Pegoraro wrote: > > Em seg., 6 de fev. de 2023 às 10:59, Erik Wienhold escreveu: > > > On 06/02/2023 12:20 CET Marcos Pegoraro wrote: > > > > > > I was just playing with some random timestamps for a week, for a month, > &

Re: How to create directory format backup

2023-02-08 Thread Erik Wienhold
> On 08/02/2023 21:59 CET Andrus wrote: > > How to create backup in format from which tables can selectively restored? Dump as custom-format archive (-F custom) and use that with pg_restore and options --table or --list/--use-list to select what should be restored. -- Erik

Re: How to create directory format backup

2023-02-08 Thread Erik Wienhold
> On 08/02/2023 22:37 CET Andrus wrote: > > > > How to create backup in format from which tables can selectively > > > restored? > > > > > Dump as custom-format archive (-F custom) and use that with pg_restore > > and options --table or --list/--use-list to select what should be > > restored. > >

Re: Multi-column index: Which column order

2023-02-14 Thread Erik Wienhold
> On 14/02/2023 18:53 CET Sebastien Flaesch wrote: > > Hello! > > When creating an index on multiple columns, does the order of the columns > matter? (I guess so) Maybe, depending on the queries. > It's mostly for SELECT statements using a condition that include ALL > columns of the index (pkey)

Re: DELETE trigger, direct or indirect?

2023-02-16 Thread Erik Wienhold
> On 16/02/2023 14:23 CET Dominique Devienne wrote: > > Hi. This is a bit unusual. We have a foreign key between two tables, with > ON DELETE CASCADE, to preserve referential integrity. But we apparently > also need to preserve the severed reference (by natural key, i.e. its name), > to later on r

Re: can't get psql authentication against Active Directory working

2023-02-18 Thread Erik Wienhold
> On 18/02/2023 15:02 CET Tomas Pospisek wrote: > > so I'm trying to authenticate psql (on Windows) -> postgres (on Linux) > via Active Directory. > > psql (Linux) -> postgres (Linux) with authentication against Active > Directory does work. > > However the same with psql.exe on Windows does not.

Re: ERROR: unsupported Unicode escape sequence - in JSON-type column

2023-02-27 Thread Erik Wienhold
> On 27/02/2023 13:13 CET Laurenz Albe wrote: > > I'd be curious to know how the customer managed to do that. > Perhaps there is a loophole in PostgreSQL that needs to be fixed. Probably via some data access layer and not directly via Postgres. It's easy to reproduce with psycopg: impor

Re: CREATE/DROP ROLE transactional? GRANT/REVOKE?

2023-03-06 Thread Erik Wienhold
> On 06/03/2023 14:19 CET Dominique Devienne wrote: > > Perhaps I missed it in the doc (e.g. [1]), but are DDLs around ROLEs and > GRANTs transactional? Have you tried? DDL is transactional unless stated otherwise (cf. CREATE DATABASE, CREATE INDEX CONCURRENTLY, CREATE TABLESPACE). Run the fol

Re: psql \conninfo in tabular form?

2023-03-07 Thread Erik Wienhold
> On 07/03/2023 18:58 CET Ron wrote: > > v13.10 > > Instead of a sentence like this: > You are connected to database "postgres" as user "postgres" via socket in > "/var/run/postgresql" at port "5433". > > I'd rather have something tabular like: >    keyword  |   value > +-

Re: Removing trailing zeros (decimal places) from a numeric (pre trim_scale()) with unexpected behaviour

2023-03-15 Thread Erik Wienhold
> On 15/03/2023 14:51 CET magog...@web.de wrote: > > I want to remove not needed decimal places / trailing zeros from a numeric. > I know this can be done starting PG >=13 with TRIM_SCALE(numeric) which would > solve my issue (with an additional CAST to TEXT at the end). Unfortunately > the produc

Re: NULL pg_database.datacl

2023-03-20 Thread Erik Wienhold
> On 20/03/2023 11:52 CET Dominique Devienne wrote: > > Hi. I'm surprised, I thought ACLs would never be empty for a database. > Does that mean nobody can connect to this database? > I guess SUPERUSER and/or its datDBA can? > What does a NULL AclItem[] mean exactly? It means that the object has d

Re: NULL pg_database.datacl

2023-03-20 Thread Erik Wienhold
> On 20/03/2023 13:50 CET Dominique Devienne wrote: > > On Mon, Mar 20, 2023 at 1:18 PM Erik Wienhold wrote: > > > On 20/03/2023 11:52 CET Dominique Devienne wrote: > > > What does a NULL AclItem[] mean exactly? > > > > It means that the object has

Re: Binding Postgres to port 0 for testing

2023-03-25 Thread Erik Wienhold
> On 25/03/2023 18:01 CET Markus Pilman wrote: > > I am building a simple integration test framework for an application that I > am building. For this project I am planning to use PostgreSQL. > > For testing purposes I'd like to always start with an empty database, > populate data, and, if the tes

Re: Binding Postgres to port 0 for testing

2023-03-25 Thread Erik Wienhold
> On 25/03/2023 20:10 CET Markus Pilman wrote: > > Thanks for the suggestions. I didn't know about pg_virtualenv, that's > interesting. Though it seems to achieve something similar as to containerize > the test (potentially in a more platform independent way). Though it seems > pg_virtualenv is mo

Re: ​jsonb @@ jsonpath operator doc: ​Only the first item of the result is taken into account

2023-04-02 Thread Erik Wienhold
> On 01/04/2023 08:02 CEST jian he wrote: > > Hi, > https://www.postgresql.org/docs/current/functions-json.html > > jsonb @@ jsonpath → boolean > > Returns the result of a JSON path predicate check for the specified JSON > > value. Only the first item of the result is taken into account. If the >

Re: DEFINER / INVOKER conundrum

2023-04-03 Thread Erik Wienhold
> On 03/04/2023 13:18 CEST Dominique Devienne wrote: > > My goal is to have clients connect to PostgreSQL, > and call a function that return a JWT token. > > The JWT is supposed to capture the user (login role), > and the current_role (which has meaning in our app), > and sign it using a secret co

Re: ​jsonb @@ jsonpath operator doc: ​Only the first item of the result is taken into account

2023-04-03 Thread Erik Wienhold
> On 02/04/2023 17:40 CEST Adrian Klaver wrote: > > That is a long way from: > > jsonb @@ jsonpath → boolean > > Returns the result of a JSON path predicate check for the specified JSON > value. Only the first item of the result is taken into account. If the > result is not Boolean, then NULL is r

Re: ​jsonb @@ jsonpath operator doc: ​Only the first item of the result is taken into account

2023-04-03 Thread Erik Wienhold
> On 03/04/2023 17:36 CEST Adrian Klaver wrote: > > On 4/3/23 08:11, Erik Wienhold wrote: > >> On 02/04/2023 17:40 CEST Adrian Klaver wrote: > >> > >> That is a long way from: > >> > >> jsonb @@ jsonpath → boolean > >> > >>

Re: ​jsonb @@ jsonpath operator doc: ​Only the first item of the result is taken into account

2023-04-03 Thread Erik Wienhold
> On 03/04/2023 18:37 CEST Adrian Klaver wrote: > > On 4/3/23 09:21, Erik Wienhold wrote: > >> On 03/04/2023 17:36 CEST Adrian Klaver wrote: > >> > >> On 4/3/23 08:11, Erik Wienhold wrote: > >>>> On 02/04/2023 17:40 CEST Adrian K

Re: DEFINER / INVOKER conundrum

2023-04-04 Thread Erik Wienhold
> On 04/04/2023 07:55 CEST walt...@technowledgy.de wrote: > > Erik Wienhold: > > A single DEFINER function works if you capture current_user with a parameter > > and default value. Let's call it claimed_role. Use pg_has_role[0] to check > > that session_user ha

Re: ​jsonb @@ jsonpath operator doc: ​Only the first item of the result is taken into account

2023-04-04 Thread Erik Wienhold
> On 04/04/2023 03:50 CEST jian he wrote: > > > "Returns true if any JSON value at the given path matches the predicate. > > Returns NULL when not a path predicate or comparing different types." > > in first sentence, should we add something "otherwise return false." ? I omitted the "otherwise f

Re: Possible old and fixed bug in Postgres?

2023-04-05 Thread Erik Wienhold
> On 05/04/2023 11:18 CEST Steve Rogerson > wrote: > > I was looking at perl CPAN Module (DateTime::Format::Pg) and saw that it did > something that seemed odd to me with time zones, based on the comment: > >     # For very early and late dates, PostgreSQL always returns times in >     # UTC a

Re: Call a Normal function inside a Trigger Function

2023-04-16 Thread Erik Wienhold
> On 16/04/2023 16:18 CEST FOUTE K. Jaurès wrote: > > Is it possible to call a function inside a trigger function ? > Any idea or link are welcome. Thanks in advance Depends on what you want to do with the return value. Use PERFORM to ignore the result. [0] Use SELECT INTO to handle a single-ro

Re: Suppress logging of "pg_hba.conf rejects connection for host"

2023-04-16 Thread Erik Wienhold
> On 16/04/2023 17:02 CEST ertan.kucuko...@1nar.com.tr wrote: > > One of the systems running PostgreSQL 14.7 receive a lot of lines like in > the subject. I have below pg_hba.conf line and that line causes these to be > logged. > > host all all 0.0.0.0/0 reject > > If possible, I do not want to see

Re: psql:t_mstr.sql:994: ERROR: function to_char(numeric) does not exist

2023-04-19 Thread Erik Wienhold
> On 19/04/2023 15:24 CEST gzh wrote: > > Hi, > > I upgraded the version of PostgreSQL from 12.10 to 12.13, Better upgrade to latest release 12.14. > when I insert data into the t_mstr table, the to_char function in the t_mstr's > trigger caused the following error. > > psql:t_mstr.sql:994: ERRO

Re: Question about accessing partitions whose name includes the schema name and a period - is this correct?

2023-04-19 Thread Erik Wienhold
> On 20/04/2023 00:50 CEST Jay Stanley wrote: > > postgres=# alter table my_schema.my_table drop partition > "my_schema"."my_schema.my_table_should_not_work"; > ERROR: syntax error at or near ""my_schema"" > LINE 1: alter table my_schema.my_table drop partition "my_schema"."m... >

Re: missing something about json syntax

2023-04-20 Thread Erik Wienhold
> On 20/04/2023 18:35 CEST Marc Millas wrote: > > Hi, > > postgres 15 > > looks Iike I am missing something, maybe obvious :-( > In a table with a json column (_data) if I ask psql to select _data from > mytable with a where clause to get only one line,, I get something beginning > by > {"time":"2

Re: FW: Error!

2023-04-24 Thread Erik Wienhold
> On 25/04/2023 01:34 CEST Adrian Klaver wrote: > > On 4/24/23 16:16, Arquimedes Aguirre wrote: > > I got question, because can’t you send a screenshots, with the image > > it’s much easier to identify the error or problem and you can also read > > the message, I don’t understand? > > Many folks o

Re: murmur3 hash binary data migration from Oracle to PostgreSQL

2023-04-24 Thread Erik Wienhold
> On 25/04/2023 03:21 CEST Jagmohan Kaintura wrote: > > We are doing Migration from Oracle to PostgreSQL. In SOurce database we have > Binary data stored using murmur3 hashing function. In Oracle this data is > being generated from the Java code and inserted into the Oracle database. Do you store

Re: murmur3 hash binary data migration from Oracle to PostgreSQL

2023-04-25 Thread Erik Wienhold
> On 25/04/2023 12:44 CEST Jagmohan Kaintura wrote: > > No we want to generate murmur3 format only. > > > On 25-Apr-2023, at 8:52 AM, Jeffrey Walton wrote: > > > > My apologies if I misparsed a couple of statements. I am having > > trouble determining if you are migrating away from Murmur3. > > >

Re: psql:t_mstr.sql:994: ERROR: function to_char(numeric) does not exist

2023-04-25 Thread Erik Wienhold
> On 25/04/2023 13:34 CEST gzh wrote: > > >The solution is the same whether you upgrade or not: you need > >to adjust your search_path to include the "oracle" schema, > >or else explicitly qualify references to orafce functions. > Thank you very much for your help. > > To use the to_date functions

Re: Differential Backups in Windows server

2023-04-27 Thread Erik Wienhold
> On 27/04/2023 13:24 CEST Rajmohan Masa wrote: > > Is it possible to take differential Backup inWindows Server ?If possible > please explain clearly? Not to my knowledge. Postgres itself only allows full backups via pg_basebackup or pg_dumpall. Barman[0] allows differential backup via rsync+ss

Re: Re:Re: psql:t_mstr.sql:994: ERROR: function to_char(numeric) does not exist

2023-04-27 Thread Erik Wienhold
> On 27/04/2023 13:20 CEST gzh wrote: > > When the return type is set to oracle.date, there are hours, minutes, and > seconds of the date value in the SQL execution result. > Why is there such a difference and how to solve it? orafce defines oracle.date as timestamp(0) [0] because Oracle's DATE t

Re: PL/pgSQL doesn't support variables in queries?

2023-05-03 Thread Erik Wienhold
> On 03/05/2023 14:25 CEST J.A. wrote: > > ms-sql person here migrating over to pgsql. One of the first thing's I noticed > with pgsql (or more specifically, PL/pgSQL) is that it doesn't support > "variables" in a query? > > for example, here's some T-SQL: > > DECLARE @fkId INTEGER > > SELECT @fkI

Re: PL/pgSQL doesn't support variables in queries?

2023-05-03 Thread Erik Wienhold
> On 03/05/2023 14:51 CEST J.A. wrote: > > Oh wow folks! I totally misunderstood the docs then. (I also tried to Read The > Manual before I posted here, too :blush:) > > I must admit, I did try doing something like you suggested Erik. I tried > things like: > > DO $$ > DECLARE > v_application_id

Re: Invoking SQL function while doing CREATE OR REPLACE on it

2023-05-03 Thread Erik Wienhold
> On 03/05/2023 20:17 CEST Nagendra Mahesh (namahesh) > wrote: > > I have a Postgres 14.4 cluster (AWS Aurora) to which I connect from my > application using JDBC. > > I use liquibase for schema management - not only tables, but also a bunch of > SQL stored procedures and functions. Basically, th

Re: The logfile stop upgrade after a vim write

2023-05-04 Thread Erik Wienhold
> On 04/05/2023 11:54 CEST lz ma wrote: > > 1. pg_ctl -D data -l MyLog > 2. vim MyLog : add some words, save and exit > 3. after vim operation, MyLog will never upgrade except restart server > I know it caused by file descripter only open once at the start by postgres, > and vim operation rename t

Re: Maintaining accents with "COPY" ?

2023-05-25 Thread Erik Wienhold
> On 25/05/2023 09:14 CEST Laura Smith > wrote: > > I'm currently doing a CSV export using COPY: > > COPY (select * from foo where bar='foo') TO '/tmp/bar.csv' DELIMITER ',' CSV > HEADER; > > This works great apart from accents are not preserved in the output, for > example é gets converted to r

Re: Maintaining accents with "COPY" ?

2023-05-25 Thread Erik Wienhold
> On 25/05/2023 13:26 CEST Peter J. Holzer wrote: > > On 2023-05-25 07:14:40 +, Laura Smith wrote: > > I'm currently doing a CSV export using COPY: > > > > COPY (select * from foo where bar='foo') TO '/tmp/bar.csv' DELIMITER ',' > > CSV HEADER; > > > > This works great apart from accents are

Re: Maintaining accents with "COPY" ?

2023-05-25 Thread Erik Wienhold
> On 25/05/2023 12:08 CEST Laura Smith > wrote: > > > Looks like an encoding issue and a mismatch between database encoding and > > client encoding. You can check both with: > > > > SHOW server_encoding; > > SHOW client_encoding; > > > > Then either set the client encoding or use COPY's encoding

Re: CREATE TEMPORARY TABLE LIKE

2023-05-25 Thread Erik Wienhold
> On 25/05/2023 15:06 CEST Jim Vanns wrote: > > When basing a temporary table of a source table, are triggers included > by default? I have this statement; > > CREATE TEMPORARY TABLE dev_main ( > LIKE prod_main > INCLUDING ALL > EXCLUDING INDEXES > EXCLUDING CONSTRAINTS > ) ON COMMIT DELETE ROWS;

Re: event trigger should provide more details

2023-05-30 Thread Erik Wienhold
> On 30/05/2023 22:23 CEST Lian Jiang wrote: > > I plan to create an event trigger to detect schema change (e.g. add/remove > a column, change column type), and write it into a separate table (e.g. > EVENTS). Then a process periodically reads this table to send schema change > notification. Howeve

Re: event trigger should provide more details

2023-05-30 Thread Erik Wienhold
> On 31/05/2023 00:28 CEST Lian Jiang wrote: > > The info useful for me is command_tag, object_type, object_identity. > classid, objid is not useful since object_identity is more explicit. > objsubid is not useful because I don't need comment > (https://www.postgresql.org/message-id/pine.lnx.4.33.

Re: How to remove user specific grant and revoke

2023-06-03 Thread Erik Wienhold
> On 03/06/2023 09:16 CEST Andrus wrote: > > User groups table is defined as > > CREATE TABLE IF NOT EXISTS public.kaspriv > ( > id serial primary key, > user character(10) NOT NULL, > group character(35) NOT NULL > ... > ) > > There are hundreds of users. Earlier time grant and revoke commands we

Re: How to remove user specific grant and revoke

2023-06-03 Thread Erik Wienhold
> On 03/06/2023 14:46 CEST Erik Wienhold wrote: > > > On 03/06/2023 09:16 CEST Andrus wrote: > > > > DROP REVOKE ALL ON TABLE public.kaspriv FROM all EXCEPT public; > > DROP GRANT SELECT ON TABLE public.kaspriv FROM all EXCEPT public; > > > > This will b

Re: How to remove user specific grant and revoke

2023-06-03 Thread Erik Wienhold
> On 03/06/2023 18:14 CEST Andrus wrote: > > > Or just execute those REVOKE ALL commands (except for PUBLIC) that pgAdmin > > already gives you. > pgAdmin gives > REVOKE ALL ON TABLE public.kaspriv FROM someuser; > I ran it but pgAdmin still gives this statement. What are the current table privil

Re: How to remove user specific grant and revoke

2023-06-03 Thread Erik Wienhold
> On 03/06/2023 22:33 CEST Andrus wrote: > > I tried > alter role alekspoluh reset all This only resets role-specific settings, not privileges. > After this command pgAdmin still shows revoke and grant commands for > alekspoluh role. > How to remove all grant and revoke assignments for role ? P

Re: How to remove user specific grant and revoke

2023-06-03 Thread Erik Wienhold
> On 03/06/2023 23:34 CEST Andrus wrote: > > psql (12.2 (Debian 12.2-2.pgdg100+1)) > Type "help" for help. > > sba=# REVOKE ALL ON public.kaspriv FROM alekspoluh; > REVOKE > sba=# \o result.txt > sba=# \dp public.kaspriv > > sba=# \q > #grep alekspoluh result.txt > Returns nothing. So output

Re: How to remove user specific grant and revoke

2023-06-03 Thread Erik Wienhold
> On 04/06/2023 00:08 CEST Andrus wrote: > > > Should I ran separate revoke commands for every user to remove those > > revokes ? > > How to remove user-spefic grants ? > After running revoke commands in psql, GRANT commands disappeared magically. > It looks like pgAdmin does not allow execute REV

Re: Drivers users by connections

2023-06-06 Thread Erik Wienhold
> On 06/06/2023 09:18 CEST Hrishikesh (Richie) Rode wrote: > > We are not able to find table which give session connection details about > drivers. In pg_stat_activity details information is not there. Please let us > know where we can find these information. Column pg_stat_activity.application_n

Re: How to securely isolate databases/users in a multi-tenant Postgresql?

2023-06-09 Thread Erik Wienhold
> On 09/06/2023 08:54 CEST Alex Lee wrote: > > I want to make a service that gives each of my users their own PG user and > database. I want to keep them isolated from each other. There are no special > extensions installed, it's a pretty vanilla PG cluster. > > Are there any considerations beyond

Re: How to store query result into another table using stored procedure

2023-06-09 Thread Erik Wienhold
> On 09/06/2023 07:51 CEST Rama Krishnan wrote: > > CREATE or REPLACE PROCEDURE deleted_cards_count_test(start_date TIMESTAMP, > end_date TIMESTAMP) AS $$ > DECLARE > current_date TIMESTAMP; > month_start_date TIMESTAMP; > month_end_date TIMESTAMP; > month24_end_date TIMESTAMP; > no_deleted_cards

Re: How To: A large [2D] matrix, 100,000+ rows/columns

2023-06-09 Thread Erik Wienhold
> On 09/06/2023 16:00 CEST Wim Bertels wrote: > > Joe Conway schreef op vr 09-06-2023 om 09:16 [-0400]: > > On 6/8/23 22:17, Pat Trainor wrote: > > > I need to have a very large matrix to maintain & query, and if not > > > (1,600 column limit), then how could such data be broken down to > > > work

Re: pg_service file questions

2023-06-20 Thread Erik Wienhold
> On 20/06/2023 08:11 CEST JUN ZHI wrote: > > I was scanning through the postgresql documentations when i came across this > webpage:PostgreSQL: Documentation: 15: 34.17. The Connection Service File > (https://www.postgresql.org/docs/current/libpq-pgservice.html). I am fairly > new to database and

Re: [Beginner Question] How to print the call link graph?

2023-07-01 Thread Erik Wienhold
> On 01/07/2023 09:10 CEST Wen Yi wrote: > > I use the gdb to track the postgres like this: > > ... > pq_getbyte () at pqcomm.c:980 > 980 in pqcomm.c > (gdb) next > 985 in pqcomm.c > (gdb) next > 986 in pqcomm.c > (gdb) next > SocketBackend (inBuf=0x7ffc8f7e1310) at postgres.c:372 > > 372 postg

Re: psql -c command parse "select $$hello$$" failed

2023-07-04 Thread Erik Wienhold
> On 04/07/2023 14:21 CEST jian he wrote: > > not sure this is the expected result. > > /home/jian/postgres/pg16_test/bin/psql -d test_dev -p 5455 -c "select > $$hello$$" > 2023-07-04 20:15:51.066 CST [1562050] ERROR: trailing junk after > numeric literal at or near "884070h" at character 8 > 20

Re: Strange behaviour on function

2023-07-05 Thread Erik Wienhold
> On 05/07/2023 14:23 CEST Lorusso Domenico wrote: > > Hello guys, > here a simple function > > CREATE OR REPLACE FUNCTION bind_action( > sqlstr text, > hrec hstore) > RETURNS text > LANGUAGE 'plpgsql' > COST 100 > immutable PARALLEL SAFE > AS $BODY$ > declare > _sqlstr text=sqlstr; > _k t

Re: Strange behaviour on function

2023-07-05 Thread Erik Wienhold
> On 05/07/2023 17:16 CEST Adrian Klaver wrote: > > https://www.postgresql.org/docs/current/plpgsql-trigger.html > > 1) > "A trigger function must return either NULL or a record/row value having > exactly the structure of the table the trigger was fired for." > > 2) I am not seeing where you use:

Re: function to_char(unknown) is not unique at character 8

2023-07-06 Thread Erik Wienhold
> On 06/07/2023 11:19 CEST gzh wrote: > > I upgraded the version of PostgreSQL from 12.6 to 12.13, > when I execute the sql below , the to_char function caused the following > error. > > ---SQL-- > select TO_CHAR('100'); > > ERROR: function to_char(unknown) is not

Re: INSERT UNIQUE row?

2023-07-10 Thread Erik Wienhold
> On 10/07/2023 04:25 CEST p...@pfortin.com wrote: > > On Sun, 9 Jul 2023 17:04:03 -0700 Adrian Klaver wrote: > > >On 7/9/23 15:58, p...@pfortin.com wrote: > >> Hi, > >> > >> Trying to figure out how to insert new property addresses into an > >> existing table. > >> > >> Can a UNIQUE constraint be

  1   2   3   >