问:
PostgreSQL 15 with plperl: lc_monetary problem (works with Postgresql 9.5)
I was trying to import a Postgres 9.5 dump into a Postgres 15 database and found that creating the plperl extension changes the behavior with lc_monetary: inserts with columns of type money fail when in the dump: ERROR: invalid input syntax for type money
When I run the same inserts in the console after importing the dump, they are fine.
The dump works with Postgres 9.5 but not with Postgres 15.

I reduced the dump to the relevant lines:

SET statement_timeout = 0;
SET lock_timeout = 0;
SET client_encoding = 'UTF8';
SET standard_conforming_strings = on;
SELECT pg_catalog.set_config('search_path', '', false);
SET check_function_bodies = false;
SET xmloption = content;
SET client_min_messages = warning;
SET row_security = off;

show lc_monetary;

CREATE EXTENSION IF NOT EXISTS plperl WITH SCHEMA pg_catalog;

CREATE EXTENSION IF NOT EXISTS plpgsql WITH SCHEMA pg_catalog;

CREATE EXTENSION IF NOT EXISTS btree_gist WITH SCHEMA public;

show lc_monetary;

CREATE DOMAIN public.nonnegmoney AS money
    CONSTRAINT nonnegmoney_check CHECK ((VALUE >= (0)::money));

ALTER DOMAIN public.nonnegmoney OWNER TO vms_test;

CREATE TABLE public.vms_test (
     id integer,
     money1 public.nonnegmoney,
     money2 money
);

ALTER TABLE public.vms_test OWNER TO vms_test;

insert into public.vms_test (id, money1, money2) values (1, '€ 0,00', '€ 0,00'); -- <=== fails here
insert into public.vms_test (id, money1, money2) values (2, '€ 625,00', '€ 625,00');

REVOKE ALL ON TABLE public.vms_test FROM PUBLIC;
REVOKE ALL ON TABLE public.vms_test FROM vms_test;
GRANT ALL ON TABLE public.vms_test TO vms_test;
```
<p>If I disable the plperl extension creation line, the dump works.
If I enable the line with plperl extension creation and disable the inserts, the dump works too - and - as I said - if I run those inserts afterwards, they work.
Also, it doesn't matter if I use <code>--column-inserts</code> for the dump or not.
(Changing the database is not an option)</p>
<p>Maybe it's a problem how I create the docker container.</p>
<p>Dockerfile:</p>
```FROM postgres:15
USER root
RUN localedef -i de_AT -c -f UTF-8 -A /usr/share/locale/locale.alias de_AT.UTF-8
RUN apt-get update
RUN apt-get -y install perl
RUN apt-get -y install postgresql-plperl-15
ENV LANG de_AT.utf8
```
<p>docker-compose:</p>
```version: '2'

services:

  vmspostgres:
    build:
      context: .
      dockerfile: postgres/Dockerfile
    container_name: vms-postgres-15
    ports:
      - "5439:5432"
    volumes:
      - ./_postgresdata:/var/lib/postgresql/data
      - ./postgres/15-create-dbs.sh:/docker-entrypoint-initdb.d/15-create-dbs.sh
      - ./postgres/17-monetary-test.sql:/17-monetary-test.sql
      - ./postgres/18-monetary-test.sql.gz:/18-monetary-test.sql.gz
    environment:
      - POSTGRES_USER=vms
      - POSTGRES_PASSWORD=xxx
      - POSTGRES_DB=postgres
    command: ["postgres", "-c", "log_statement=all"]
```
<p>This is the database log with enabled <code>CREATE EXTENSION plperl</code> line (Sorry it's in German but I hope you can get an idea of what it means):</p>
```2023-01-09 10:11:55 /usr/local/bin/docker-entrypoint.sh: sourcing /docker-entrypoint-initdb.d/15-create-dbs.sh
2023-01-09 10:11:55 === 17-monetary-test.sql ===
2023-01-09 10:11:55 2023-01-09 09:11:55.189 UTC [61] LOG:  Anweisung: CREATE ROLE vms_test LOGIN
2023-01-09 10:11:55   PASSWORD 'vms_test'
2023-01-09 10:11:55   NOSUPERUSER INHERIT NOCREATEDB NOCREATEROLE NOREPLICATION;
2023-01-09 10:11:55 CREATE ROLE
2023-01-09 10:11:55 2023-01-09 09:11:55.206 UTC [61] LOG:  Anweisung: create database vms_test with owner vms_test LC_COLLATE = 'de_AT.UTF-8' LC_CTYPE = 'de_AT.UTF-8' TEMPLATE template0;
2023-01-09 10:11:55 CREATE DATABASE
2023-01-09 10:11:55 2023-01-09 09:11:55.436 UTC [61] LOG:  Anweisung: set datestyle = 'iso, ymd';
2023-01-09 10:11:55 SET
2023-01-09 10:11:55 2023-01-09 09:11:55.436 UTC [61] LOG:  Anweisung: set lc_messages = 'en_US.UTF-8';
2023-01-09 10:11:55 SET
2023-01-09 10:11:55 2023-01-09 09:11:55.436 UTC [61] LOG:  statement: set lc_monetary = 'de_AT.UTF-8';
2023-01-09 10:11:55 SET
2023-01-09 10:11:55 2023-01-09 09:11:55.436 UTC [61] LOG:  statement: set lc_numeric = 'de_AT.UTF-8';
2023-01-09 10:11:55 SET
2023-01-09 10:11:55 2023-01-09 09:11:55.437 UTC [61] LOG:  statement: set lc_time = 'de_AT.UTF-8';
2023-01-09 10:11:55 SET
2023-01-09 10:11:55 2023-01-09 09:11:55.437 UTC [61] LOG:  statement: set default_text_search_config = 'pg_catalog.german';
2023-01-09 10:11:55 SET
2023-01-09 10:11:55 2023-01-09 09:11:55.438 UTC [61] LOG:  statement: GRANT ALL PRIVILEGES ON DATABASE vms_test TO vms_test;
2023-01-09 10:11:55 GRANT
2023-01-09 10:11:55
2023-01-09 10:11:55 === 18-monetry-test.sql.gz ===
2023-01-09 10:11:55 2023-01-09 09:11:55.522 UTC [64] LOG:  Anweisung: SET statement_timeout = 0;
2023-01-09 10:11:55 SET
2023-01-09 10:11:55 2023-01-09 09:11:55.523 UTC [64] LOG:  Anweisung: SET lock_timeout = 0;
2023-01-09 10:11:55 SET
2023-01-09 10:11:55 2023-01-09 09:11:55.523 UTC [64] LOG:  Anweisung: SET client_encoding = 'UTF8';
2023-01-09 10:11:55 SET
2023-01-09 10:11:55 2023-01-09 09:11:55.523 UTC [64] LOG:  Anweisung: SET standard_conforming_strings = on;
2023-01-09 10:11:55 SET
2023-01-09 10:11:55 2023-01-09 09:11:55.523 UTC [64] LOG:  Anweisung: SELECT pg_catalog.set_config('search_path', '', false);
2023-01-09 10:11:55  set_config
2023-01-09 10:11:55 ------------
2023-01-09 10:11:55
2023-01-09 10:11:55 (1 Zeile)
2023-01-09 10:11:55
2023-01-09 10:11:55 2023-01-09 09:11:55.524 UTC [64] LOG:  Anweisung: SET check_function_bodies = false;
2023-01-09 10:11:55 SET
2023-01-09 10:11:55 2023-01-09 09:11:55.525 UTC [64] LOG:  Anweisung: SET xmloption = content;
2023-01-09 10:11:55 SET
2023-01-09 10:11:55 2023-01-09 09:11:55.525 UTC [64] LOG:  Anweisung: SET client_min_messages = warning;
2023-01-09 10:11:55 SET
2023-01-09 10:11:55 2023-01-09 09:11:55.526 UTC [64] LOG:  Anweisung: SET row_security = off;
2023-01-09 10:11:55 SET
2023-01-09 10:11:55 2023-01-09 09:11:55.526 UTC [64] LOG:  Anweisung: show lc_monetary;
2023-01-09 10:11:55  lc_monetary
2023-01-09 10:11:55 -------------
2023-01-09 10:11:55  de_AT.utf8
2023-01-09 10:11:55 (1 Zeile)
2023-01-09 10:11:55
2023-01-09 10:11:55 2023-01-09 09:11:55.526 UTC [64] LOG:  Anweisung: CREATE EXTENSION IF NOT EXISTS plperl WITH SCHEMA pg_catalog;
2023-01-09 10:11:55 CREATE EXTENSION
2023-01-09 10:11:55 2023-01-09 09:11:55.551 UTC [64] LOG:  Anweisung: CREATE EXTENSION IF NOT EXISTS plpgsql WITH SCHEMA pg_catalog;
2023-01-09 10:11:55 CREATE EXTENSION
2023-01-09 10:11:55 2023-01-09 09:11:55.551 UTC [64] LOG:  Anweisung: CREATE EXTENSION IF NOT EXISTS btree_gist WITH SCHEMA public;
2023-01-09 10:11:55 CREATE EXTENSION
2023-01-09 10:11:55 2023-01-09 09:11:55.610 UTC [64] LOG:  Anweisung: show lc_monetary;
2023-01-09 10:11:55  lc_monetary
2023-01-09 10:11:55 -------------
2023-01-09 10:11:55  de_AT.utf8
2023-01-09 10:11:55 (1 Zeile)
2023-01-09 10:11:55
2023-01-09 10:11:55 2023-01-09 09:11:55.611 UTC [64] LOG:  Anweisung: CREATE DOMAIN public.nonnegmoney AS money
2023-01-09 10:11:55     CONSTRAINT nonnegmoney_check CHECK ((VALUE >= (0)::money));
2023-01-09 10:11:55 CREATE DOMAIN
2023-01-09 10:11:55 2023-01-09 09:11:55.612 UTC [64] LOG:  Anweisung: ALTER DOMAIN public.nonnegmoney OWNER TO vms_test;
2023-01-09 10:11:55 ALTER DOMAIN
2023-01-09 10:11:55 2023-01-09 09:11:55.613 UTC [64] LOG:  Anweisung: CREATE TABLE public.vms_test (
2023-01-09 10:11:55      id integer,
2023-01-09 10:11:55      money1 public.nonnegmoney,
2023-01-09 10:11:55      money2 money
2023-01-09 10:11:55 );
2023-01-09 10:11:55 CREATE TABLE
2023-01-09 10:11:55 2023-01-09 09:11:55.616 UTC [64] LOG:  Anweisung: ALTER TABLE public.vms_test OWNER TO vms_test;
2023-01-09 10:11:55 ALTER TABLE
2023-01-09 10:11:55 2023-01-09 09:11:55.617 UTC [64] LOG:  Anweisung: insert into public.vms_test (id, money1, money2) values (1, '€ 0,00', '€ 0,00');
2023-01-09 10:11:55 2023-01-09 09:11:55.617 UTC [64] FEHLER:  ungültige Eingabesyntax für Typ money: »€ 0,00« bei Zeichen 61
2023-01-09 10:11:55 2023-01-09 09:11:55.617 UTC [64] ANWEISUNG:  insert into public.vms_test (id, money1, money2) values (1, '€ 0,00', '€ 0,00');
2023-01-09 10:11:55 FEHLER:  ungültige Eingabesyntax für Typ money: »€ 0,00«
2023-01-09 10:11:55 ZEILE 1: ...o public.vms_test (id, money1, money2) values (1, '€ 0,00', ...
2023-01-09 10:11:55                                                               ^
```
<p>This is the database log with disabled <code>CREATE EXTENSION plperl</code> line:</p>
```2023-01-09 10:15:11 /usr/local/bin/docker-entrypoint.sh: sourcing /docker-entrypoint-initdb.d/15-create-dbs.sh
2023-01-09 10:15:11 === 17-monetary-test.sql ===
2023-01-09 10:15:11 2023-01-09 09:15:11.402 UTC [60] LOG:  Anweisung: CREATE ROLE vms_test LOGIN
2023-01-09 10:15:11   PASSWORD 'vms_test'
2023-01-09 10:15:11   NOSUPERUSER INHERIT NOCREATEDB NOCREATEROLE NOREPLICATION;
2023-01-09 10:15:11 CREATE ROLE
2023-01-09 10:15:11 2023-01-09 09:15:11.419 UTC [60] LOG:  Anweisung: create database vms_test with owner vms_test LC_COLLATE = 'de_AT.UTF-8' LC_CTYPE = 'de_AT.UTF-8' TEMPLATE template0;
2023-01-09 10:15:11 CREATE DATABASE
2023-01-09 10:15:11 2023-01-09 09:15:11.653 UTC [60] LOG:  Anweisung: set datestyle = 'iso, ymd';
2023-01-09 10:15:11 SET
2023-01-09 10:15:11 2023-01-09 09:15:11.653 UTC [60] LOG:  Anweisung: set lc_messages = 'en_US.UTF-8';
2023-01-09 10:15:11 SET
2023-01-09 10:15:11 2023-01-09 09:15:11.653 UTC [60] LOG:  statement: set lc_monetary = 'de_AT.UTF-8';
2023-01-09 10:15:11 SET
2023-01-09 10:15:11 2023-01-09 09:15:11.653 UTC [60] LOG:  statement: set lc_numeric = 'de_AT.UTF-8';
2023-01-09 10:15:11 SET
2023-01-09 10:15:11 2023-01-09 09:15:11.654 UTC [60] LOG:  statement: set lc_time = 'de_AT.UTF-8';
2023-01-09 10:15:11 SET
2023-01-09 10:15:11 2023-01-09 09:15:11.654 UTC [60] LOG:  statement: set default_text_search_config = 'pg_catalog.german';
2023-01-09 10:15:11 SET
2023-01-09 10:15:11 2023-01-09 09:15:11.655 UTC [60] LOG:  statement: GRANT ALL PRIVILEGES ON DATABASE vms_test TO vms_test;
2023-01-09 10:15:11 GRANT
2023-01-09 10:15:11
2023-01-09 10:15:11 === 18-monetry-test.sql.gz ===
2023-01-09 10:15:11 2023-01-09 09:15:11.743 UTC [63] LOG:  Anweisung: SET statement_timeout = 0;
2023-01-09 10:15:11 SET
2023-01-09 10:15:11 2023-01-09 09:15:11.743 UTC [63] LOG:  Anweisung: SET lock_timeout = 0;
2023-01-09 10:15:11 SET
2023-01-09 10:15:11 2023-01-09 09:15:11.743 UTC [63] LOG:  Anweisung: SET client_encoding = 'UTF8';
2023-01-09 10:15:11 SET
2023-01-09 10:15:11 2023-01-09 09:15:11.743 UTC [63] LOG:  Anweisung: SET standard_conforming_strings = on;
2023-01-09 10:15:11 SET
2023-01-09 10:15:11 2023-01-09 09:15:11.743 UTC [63] LOG:  Anweisung: SELECT pg_catalog.set_config('search_path', '', false);
2023-01-09 10:15:11  set_config
2023-01-09 10:15:11 ------------
2023-01-09 10:15:11
2023-01-09 10:15:11 (1 Zeile)
2023-01-09 10:15:11
2023-01-09 10:15:11 2023-01-09 09:15:11.744 UTC [63] LOG:  Anweisung: SET check_function_bodies = false;
2023-01-09 10:15:11 SET
2023-01-09 10:15:11 2023-01-09 09:15:11.744 UTC [63] LOG:  Anweisung: SET xmloption = content;
2023-01-09 10:15:11 SET
2023-01-09 10:15:11 2023-01-09 09:15:11.744 UTC [63] LOG:  Anweisung: SET client_min_messages = warning;
2023-01-09 10:15:11 SET
2023-01-09 10:15:11 2023-01-09 09:15:11.744 UTC [63] LOG:  Anweisung: SET row_security = off;
2023-01-09 10:15:11 SET
2023-01-09 10:15:11 2023-01-09 09:15:11.744 UTC [63] LOG:  Anweisung: show lc_monetary;
2023-01-09 10:15:11  lc_monetary
2023-01-09 10:15:11 -------------
2023-01-09 10:15:11  de_AT.utf8
2023-01-09 10:15:11 (1 Zeile)
2023-01-09 10:15:11
2023-01-09 10:15:11 2023-01-09 09:15:11.744 UTC [63] LOG:  Anweisung: CREATE EXTENSION IF NOT EXISTS plpgsql WITH SCHEMA pg_catalog;
2023-01-09 10:15:11 CREATE EXTENSION
2023-01-09 10:15:11 2023-01-09 09:15:11.745 UTC [63] LOG:  Anweisung: CREATE EXTENSION IF NOT EXISTS btree_gist WITH SCHEMA public;
2023-01-09 10:15:11 CREATE EXTENSION
2023-01-09 10:15:11 2023-01-09 09:15:11.815 UTC [63] LOG:  Anweisung: show lc_monetary;
2023-01-09 10:15:11  lc_monetary
2023-01-09 10:15:11 -------------
2023-01-09 10:15:11  de_AT.utf8
2023-01-09 10:15:11 (1 Zeile)
2023-01-09 10:15:11
2023-01-09 10:15:11 2023-01-09 09:15:11.815 UTC [63] LOG:  Anweisung: CREATE DOMAIN public.nonnegmoney AS money
2023-01-09 10:15:11     CONSTRAINT nonnegmoney_check CHECK ((VALUE >= (0)::money));
2023-01-09 10:15:11 CREATE DOMAIN
2023-01-09 10:15:11 2023-01-09 09:15:11.816 UTC [63] LOG:  Anweisung: ALTER DOMAIN public.nonnegmoney OWNER TO vms_test;
2023-01-09 10:15:11 ALTER DOMAIN
2023-01-09 10:15:11 2023-01-09 09:15:11.817 UTC [63] LOG:  Anweisung: CREATE TABLE public.vms_test (
2023-01-09 10:15:11      id integer,
2023-01-09 10:15:11      money1 public.nonnegmoney,
2023-01-09 10:15:11      money2 money
2023-01-09 10:15:11 );
2023-01-09 10:15:11 CREATE TABLE
2023-01-09 10:15:11 2023-01-09 09:15:11.818 UTC [63] LOG:  Anweisung: ALTER TABLE public.vms_test OWNER TO vms_test;
2023-01-09 10:15:11 ALTER TABLE
2023-01-09 10:15:11 2023-01-09 09:15:11.819 UTC [63] LOG:  Anweisung: insert into public.vms_test (id, money1, money2) values (1, '€ 0,00', '€ 0,00');
2023-01-09 10:15:11 INSERT 0 1
2023-01-09 10:15:11 2023-01-09 09:15:11.820 UTC [63] LOG:  Anweisung: insert into public.vms_test (id, money1, money2) values (2, '€ 625,00', '€ 625,00');
2023-01-09 10:15:11 INSERT 0 1
2023-01-09 10:15:11 2023-01-09 09:15:11.820 UTC [63] LOG:  Anweisung: REVOKE ALL ON TABLE public.vms_test FROM PUBLIC;
2023-01-09 10:15:11 REVOKE
2023-01-09 10:15:11 2023-01-09 09:15:11.820 UTC [63] LOG:  Anweisung: REVOKE ALL ON TABLE public.vms_test FROM vms_test;
2023-01-09 10:15:11 REVOKE
2023-01-09 10:15:11 2023-01-09 09:15:11.821 UTC [63] LOG:  Anweisung: GRANT ALL ON TABLE public.vms_test TO vms_test;
2023-01-09 10:15:11 GRANT
2023-01-09 10:15:11
2023-01-09 10:15:11
2023-01-09 10:15:11 2023-01-09 09:15:11.827 UTC [49] LOG:  schnelles Herunterfahren verlangt
2023-01-09 10:15:11 warte auf Herunterfahren des Servers...2023-01-09 09:15:11.828 UTC [49] LOG:  etwaige aktive Transaktionen werden abgebrochen
2023-01-09 10:15:11 2023-01-09 09:15:11.832 UTC [49] LOG:  Background-Worker »logical replication launcher« (PID 55) beendete mit Status 1
2023-01-09 10:15:11 .2023-01-09 09:15:11.835 UTC [50] LOG:  fahre herunter
2023-01-09 10:15:11 2023-01-09 09:15:11.836 UTC [50] LOG:  Checkpoint beginnt: shutdown immediate
2023-01-09 10:15:12 2023-01-09 09:15:12.013 UTC [50] LOG:  Checkpoint komplett: 973 Puffer geschrieben (5.9%); 0 WAL-Datei(en) hinzugefügt, 0 entfernt, 0 wiederverwendet; Schreiben=0,083 s, Sync=0,091 s, gesamt=0,179 s; sync. Dateien=258, längste=0,003 s, Durchschnitt=0.001 s; Entfernung=4905 kB, Schätzung=4905 kB
2023-01-09 10:15:12 2023-01-09 09:15:12.056 UTC [49] LOG:  Datenbanksystem ist heruntergefahren
2023-01-09 10:15:12  fertig
2023-01-09 10:15:12 Server angehalten
2023-01-09 10:15:12
2023-01-09 10:15:12 PostgreSQL init process complete; ready for start up.
2023-01-09 10:15:12
2023-01-09 10:15:12 2023-01-09 09:15:12.188 UTC [1] LOG:  PostgreSQL 15.1 (Debian 15.1-1.pgdg110+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 10.2.1-6) 10.2.1 20210110, 64-bit startet
2023-01-09 10:15:12 2023-01-09 09:15:12.188 UTC [1] LOG:  erwarte Verbindungen auf IPv4-Adresse »0.0.0.0«, Port 5432
2023-01-09 10:15:12 2023-01-09 09:15:12.188 UTC [1] LOG:  erwarte Verbindungen auf IPv6-Adresse »::«, Port 5432
2023-01-09 10:15:12 2023-01-09 09:15:12.191 UTC [1] LOG:  erwarte Verbindungen auf Unix-Socket »/var/run/postgresql/.s.PGSQL.5432«
2023-01-09 10:15:12 2023-01-09 09:15:12.204 UTC [68] LOG:  Datenbanksystem wurde am 2023-01-09 09:15:12 UTC heruntergefahren
2023-01-09 10:15:12 2023-01-09 09:15:12.220 UTC [1] LOG:  Datenbanksystem ist bereit, um Verbindungen anzunehmen
```
<p>This is the import script which is executed in the docker container:</p>
```#!/bin/bash

set -e

echo "=== 17-monetary-test.sql ==="
psql -v ON_ERROR_STOP=1 --username postgres --dbname postgres -f ../17-monetary-test.sql; echo;
echo "=== 18-monetry-test.sql.gz ==="
gunzip -c ../18-monetary-test.sql.gz | psql -v ON_ERROR_STOP=1 --username postgres --dbname vms_test; echo;
```

What do you think?

"SOLUTION"

I haven't found any real solution to this specific problem. All attempts with different postgres versions were unsuccessful, both with docker and directly on my Linux system.
Even if I execute all statements of the dump on the console, there is ultimately a problem with the import of larger amounts of money, because on newer Linux systems the thousands separator of lc_monetary for the locale de_AT has been changed from a normal space (<U0020>) to a non-breakable-space (<U202F>).

Since the official Docker container for postgres-9.5 is no longer supported, I got the Dockerfile for version 9.5 from the postgres git history, changed the apt directories to the archive directories and now have a running postgres-9.5 docker version, into which I can import the old database.
For our software upgrade to a current postgresql version, we will change all money columns to a numeric type!

Thank you for your help (especially @AdrianKlaver)

Body:
I was trying to import a Postgres 9.5 dump into a Postgres 15 database and found that creating the plperl extension changes the behavior with lc_monetary: inserts with columns of type money fail when in the dump: ERROR: invalid input syntax for type money
When I run the same inserts in the console after importing the dump, they are fine.
The dump works with Postgres 9.5 but not with Postgres 15.

I reduced the dump to the relevant lines:

SET statement_timeout = 0;
SET lock_timeout = 0;
SET client_encoding = 'UTF8';
SET standard_conforming_strings = on;
SELECT pg_catalog.set_config('search_path', '', false);
SET check_function_bodies = false;
SET xmloption = content;
SET client_min_messages = warning;
SET row_security = off;

show lc_monetary;

CREATE EXTENSION IF NOT EXISTS plperl WITH SCHEMA pg_catalog;

CREATE EXTENSION IF NOT EXISTS plpgsql WITH SCHEMA pg_catalog;

CREATE EXTENSION IF NOT EXISTS btree_gist WITH SCHEMA public;

show lc_monetary;

CREATE DOMAIN public.nonnegmoney AS money
    CONSTRAINT nonnegmoney_check CHECK ((VALUE >= (0)::money));

ALTER DOMAIN public.nonnegmoney OWNER TO vms_test;

CREATE TABLE public.vms_test (
     id integer,
     money1 public.nonnegmoney,
     money2 money
);

ALTER TABLE public.vms_test OWNER TO vms_test;

insert into public.vms_test (id, money1, money2) values (1, '€ 0,00', '€ 0,00'); -- <=== fails here
insert into public.vms_test (id, money1, money2) values (2, '€ 625,00', '€ 625,00');

REVOKE ALL ON TABLE public.vms_test FROM PUBLIC;
REVOKE ALL ON TABLE public.vms_test FROM vms_test;
GRANT ALL ON TABLE public.vms_test TO vms_test;

If I disable the plperl extension creation line, the dump works.
If I enable the line with plperl extension creation and disable the inserts, the dump works too - and - as I said - if I run those inserts afterwards, they work.
Also, it doesn't matter if I use --column-inserts for the dump or not.
(Changing the database is not an option)

Maybe it's a problem how I create the docker container.

Dockerfile:

FROM postgres:15
USER root
RUN localedef -i de_AT -c -f UTF-8 -A /usr/share/locale/locale.alias de_AT.UTF-8
RUN apt-get update
RUN apt-get -y install perl
RUN apt-get -y install postgresql-plperl-15
ENV LANG de_AT.utf8

docker-compose:

version: '2'

services:

  vmspostgres:
    build:
      context: .
      dockerfile: postgres/Dockerfile
    container_name: vms-postgres-15
    ports:
      - "5439:5432"
    volumes:
      - ./_postgresdata:/var/lib/postgresql/data
      - ./postgres/15-create-dbs.sh:/docker-entrypoint-initdb.d/15-create-dbs.sh
      - ./postgres/17-monetary-test.sql:/17-monetary-test.sql
      - ./postgres/18-monetary-test.sql.gz:/18-monetary-test.sql.gz
    environment:
      - POSTGRES_USER=vms
      - POSTGRES_PASSWORD=xxx
      - POSTGRES_DB=postgres
    command: ["postgres", "-c", "log_statement=all"]

This is the database log with enabled CREATE EXTENSION plperl line (Sorry it's in German but I hope you can get an idea of what it means):

2023-01-09 10:11:55 /usr/local/bin/docker-entrypoint.sh: sourcing /docker-entrypoint-initdb.d/15-create-dbs.sh
2023-01-09 10:11:55 === 17-monetary-test.sql ===
2023-01-09 10:11:55 2023-01-09 09:11:55.189 UTC [61] LOG:  Anweisung: CREATE ROLE vms_test LOGIN
2023-01-09 10:11:55   PASSWORD 'vms_test'
2023-01-09 10:11:55   NOSUPERUSER INHERIT NOCREATEDB NOCREATEROLE NOREPLICATION;
2023-01-09 10:11:55 CREATE ROLE
2023-01-09 10:11:55 2023-01-09 09:11:55.206 UTC [61] LOG:  Anweisung: create database vms_test with owner vms_test LC_COLLATE = 'de_AT.UTF-8' LC_CTYPE = 'de_AT.UTF-8' TEMPLATE template0;
2023-01-09 10:11:55 CREATE DATABASE
2023-01-09 10:11:55 2023-01-09 09:11:55.436 UTC [61] LOG:  Anweisung: set datestyle = 'iso, ymd';
2023-01-09 10:11:55 SET
2023-01-09 10:11:55 2023-01-09 09:11:55.436 UTC [61] LOG:  Anweisung: set lc_messages = 'en_US.UTF-8';
2023-01-09 10:11:55 SET
2023-01-09 10:11:55 2023-01-09 09:11:55.436 UTC [61] LOG:  statement: set lc_monetary = 'de_AT.UTF-8';
2023-01-09 10:11:55 SET
2023-01-09 10:11:55 2023-01-09 09:11:55.436 UTC [61] LOG:  statement: set lc_numeric = 'de_AT.UTF-8';
2023-01-09 10:11:55 SET
2023-01-09 10:11:55 2023-01-09 09:11:55.437 UTC [61] LOG:  statement: set lc_time = 'de_AT.UTF-8';
2023-01-09 10:11:55 SET
2023-01-09 10:11:55 2023-01-09 09:11:55.437 UTC [61] LOG:  statement: set default_text_search_config = 'pg_catalog.german';
2023-01-09 10:11:55 SET
2023-01-09 10:11:55 2023-01-09 09:11:55.438 UTC [61] LOG:  statement: GRANT ALL PRIVILEGES ON DATABASE vms_test TO vms_test;
2023-01-09 10:11:55 GRANT
2023-01-09 10:11:55
2023-01-09 10:11:55 === 18-monetry-test.sql.gz ===
2023-01-09 10:11:55 2023-01-09 09:11:55.522 UTC [64] LOG:  Anweisung: SET statement_timeout = 0;
2023-01-09 10:11:55 SET
2023-01-09 10:11:55 2023-01-09 09:11:55.523 UTC [64] LOG:  Anweisung: SET lock_timeout = 0;
2023-01-09 10:11:55 SET
2023-01-09 10:11:55 2023-01-09 09:11:55.523 UTC [64] LOG:  Anweisung: SET client_encoding = 'UTF8';
2023-01-09 10:11:55 SET
2023-01-09 10:11:55 2023-01-09 09:11:55.523 UTC [64] LOG:  Anweisung: SET standard_conforming_strings = on;
2023-01-09 10:11:55 SET
2023-01-09 10:11:55 2023-01-09 09:11:55.523 UTC [64] LOG:  Anweisung: SELECT pg_catalog.set_config('search_path', '', false);
2023-01-09 10:11:55  set_config
2023-01-09 10:11:55 ------------
2023-01-09 10:11:55
2023-01-09 10:11:55 (1 Zeile)
2023-01-09 10:11:55
2023-01-09 10:11:55 2023-01-09 09:11:55.524 UTC [64] LOG:  Anweisung: SET check_function_bodies = false;
2023-01-09 10:11:55 SET
2023-01-09 10:11:55 2023-01-09 09:11:55.525 UTC [64] LOG:  Anweisung: SET xmloption = content;
2023-01-09 10:11:55 SET
2023-01-09 10:11:55 2023-01-09 09:11:55.525 UTC [64] LOG:  Anweisung: SET client_min_messages = warning;
2023-01-09 10:11:55 SET
2023-01-09 10:11:55 2023-01-09 09:11:55.526 UTC [64] LOG:  Anweisung: SET row_security = off;
2023-01-09 10:11:55 SET
2023-01-09 10:11:55 2023-01-09 09:11:55.526 UTC [64] LOG:  Anweisung: show lc_monetary;
2023-01-09 10:11:55  lc_monetary
2023-01-09 10:11:55 -------------
2023-01-09 10:11:55  de_AT.utf8
2023-01-09 10:11:55 (1 Zeile)
2023-01-09 10:11:55
2023-01-09 10:11:55 2023-01-09 09:11:55.526 UTC [64] LOG:  Anweisung: CREATE EXTENSION IF NOT EXISTS plperl WITH SCHEMA pg_catalog;
2023-01-09 10:11:55 CREATE EXTENSION
2023-01-09 10:11:55 2023-01-09 09:11:55.551 UTC [64] LOG:  Anweisung: CREATE EXTENSION IF NOT EXISTS plpgsql WITH SCHEMA pg_catalog;
2023-01-09 10:11:55 CREATE EXTENSION
2023-01-09 10:11:55 2023-01-09 09:11:55.551 UTC [64] LOG:  Anweisung: CREATE EXTENSION IF NOT EXISTS btree_gist WITH SCHEMA public;
2023-01-09 10:11:55 CREATE EXTENSION
2023-01-09 10:11:55 2023-01-09 09:11:55.610 UTC [64] LOG:  Anweisung: show lc_monetary;
2023-01-09 10:11:55  lc_monetary
2023-01-09 10:11:55 -------------
2023-01-09 10:11:55  de_AT.utf8
2023-01-09 10:11:55 (1 Zeile)
2023-01-09 10:11:55
2023-01-09 10:11:55 2023-01-09 09:11:55.611 UTC [64] LOG:  Anweisung: CREATE DOMAIN public.nonnegmoney AS money
2023-01-09 10:11:55     CONSTRAINT nonnegmoney_check CHECK ((VALUE >= (0)::money));
2023-01-09 10:11:55 CREATE DOMAIN
2023-01-09 10:11:55 2023-01-09 09:11:55.612 UTC [64] LOG:  Anweisung: ALTER DOMAIN public.nonnegmoney OWNER TO vms_test;
2023-01-09 10:11:55 ALTER DOMAIN
2023-01-09 10:11:55 2023-01-09 09:11:55.613 UTC [64] LOG:  Anweisung: CREATE TABLE public.vms_test (
2023-01-09 10:11:55      id integer,
2023-01-09 10:11:55      money1 public.nonnegmoney,
2023-01-09 10:11:55      money2 money
2023-01-09 10:11:55 );
2023-01-09 10:11:55 CREATE TABLE
2023-01-09 10:11:55 2023-01-09 09:11:55.616 UTC [64] LOG:  Anweisung: ALTER TABLE public.vms_test OWNER TO vms_test;
2023-01-09 10:11:55 ALTER TABLE
2023-01-09 10:11:55 2023-01-09 09:11:55.617 UTC [64] LOG:  Anweisung: insert into public.vms_test (id, money1, money2) values (1, '€ 0,00', '€ 0,00');
2023-01-09 10:11:55 2023-01-09 09:11:55.617 UTC [64] FEHLER:  ungültige Eingabesyntax für Typ money: »€ 0,00« bei Zeichen 61
2023-01-09 10:11:55 2023-01-09 09:11:55.617 UTC [64] ANWEISUNG:  insert into public.vms_test (id, money1, money2) values (1, '€ 0,00', '€ 0,00');
2023-01-09 10:11:55 FEHLER:  ungültige Eingabesyntax für Typ money: »€ 0,00«
2023-01-09 10:11:55 ZEILE 1: ...o public.vms_test (id, money1, money2) values (1, '€ 0,00', ...
2023-01-09 10:11:55                                                               ^

This is the database log with disabled CREATE EXTENSION plperl line:

2023-01-09 10:15:11 /usr/local/bin/docker-entrypoint.sh: sourcing /docker-entrypoint-initdb.d/15-create-dbs.sh
2023-01-09 10:15:11 === 17-monetary-test.sql ===
2023-01-09 10:15:11 2023-01-09 09:15:11.402 UTC [60] LOG:  Anweisung: CREATE ROLE vms_test LOGIN
2023-01-09 10:15:11   PASSWORD 'vms_test'
2023-01-09 10:15:11   NOSUPERUSER INHERIT NOCREATEDB NOCREATEROLE NOREPLICATION;
2023-01-09 10:15:11 CREATE ROLE
2023-01-09 10:15:11 2023-01-09 09:15:11.419 UTC [60] LOG:  Anweisung: create database vms_test with owner vms_test LC_COLLATE = 'de_AT.UTF-8' LC_CTYPE = 'de_AT.UTF-8' TEMPLATE template0;
2023-01-09 10:15:11 CREATE DATABASE
2023-01-09 10:15:11 2023-01-09 09:15:11.653 UTC [60] LOG:  Anweisung: set datestyle = 'iso, ymd';
2023-01-09 10:15:11 SET
2023-01-09 10:15:11 2023-01-09 09:15:11.653 UTC [60] LOG:  Anweisung: set lc_messages = 'en_US.UTF-8';
2023-01-09 10:15:11 SET
2023-01-09 10:15:11 2023-01-09 09:15:11.653 UTC [60] LOG:  statement: set lc_monetary = 'de_AT.UTF-8';
2023-01-09 10:15:11 SET
2023-01-09 10:15:11 2023-01-09 09:15:11.653 UTC [60] LOG:  statement: set lc_numeric = 'de_AT.UTF-8';
2023-01-09 10:15:11 SET
2023-01-09 10:15:11 2023-01-09 09:15:11.654 UTC [60] LOG:  statement: set lc_time = 'de_AT.UTF-8';
2023-01-09 10:15:11 SET
2023-01-09 10:15:11 2023-01-09 09:15:11.654 UTC [60] LOG:  statement: set default_text_search_config = 'pg_catalog.german';
2023-01-09 10:15:11 SET
2023-01-09 10:15:11 2023-01-09 09:15:11.655 UTC [60] LOG:  statement: GRANT ALL PRIVILEGES ON DATABASE vms_test TO vms_test;
2023-01-09 10:15:11 GRANT
2023-01-09 10:15:11
2023-01-09 10:15:11 === 18-monetry-test.sql.gz ===
2023-01-09 10:15:11 2023-01-09 09:15:11.743 UTC [63] LOG:  Anweisung: SET statement_timeout = 0;
2023-01-09 10:15:11 SET
2023-01-09 10:15:11 2023-01-09 09:15:11.743 UTC [63] LOG:  Anweisung: SET lock_timeout = 0;
2023-01-09 10:15:11 SET
2023-01-09 10:15:11 2023-01-09 09:15:11.743 UTC [63] LOG:  Anweisung: SET client_encoding = 'UTF8';
2023-01-09 10:15:11 SET
2023-01-09 10:15:11 2023-01-09 09:15:11.743 UTC [63] LOG:  Anweisung: SET standard_conforming_strings = on;
2023-01-09 10:15:11 SET
2023-01-09 10:15:11 2023-01-09 09:15:11.743 UTC [63] LOG:  Anweisung: SELECT pg_catalog.set_config('search_path', '', false);
2023-01-09 10:15:11  set_config
2023-01-09 10:15:11 ------------
2023-01-09 10:15:11
2023-01-09 10:15:11 (1 Zeile)
2023-01-09 10:15:11
2023-01-09 10:15:11 2023-01-09 09:15:11.744 UTC [63] LOG:  Anweisung: SET check_function_bodies = false;
2023-01-09 10:15:11 SET
2023-01-09 10:15:11 2023-01-09 09:15:11.744 UTC [63] LOG:  Anweisung: SET xmloption = content;
2023-01-09 10:15:11 SET
2023-01-09 10:15:11 2023-01-09 09:15:11.744 UTC [63] LOG:  Anweisung: SET client_min_messages = warning;
2023-01-09 10:15:11 SET
2023-01-09 10:15:11 2023-01-09 09:15:11.744 UTC [63] LOG:  Anweisung: SET row_security = off;
2023-01-09 10:15:11 SET
2023-01-09 10:15:11 2023-01-09 09:15:11.744 UTC [63] LOG:  Anweisung: show lc_monetary;
2023-01-09 10:15:11  lc_monetary
2023-01-09 10:15:11 -------------
2023-01-09 10:15:11  de_AT.utf8
2023-01-09 10:15:11 (1 Zeile)
2023-01-09 10:15:11
2023-01-09 10:15:11 2023-01-09 09:15:11.744 UTC [63] LOG:  Anweisung: CREATE EXTENSION IF NOT EXISTS plpgsql WITH SCHEMA pg_catalog;
2023-01-09 10:15:11 CREATE EXTENSION
2023-01-09 10:15:11 2023-01-09 09:15:11.745 UTC [63] LOG:  Anweisung: CREATE EXTENSION IF NOT EXISTS btree_gist WITH SCHEMA public;
2023-01-09 10:15:11 CREATE EXTENSION
2023-01-09 10:15:11 2023-01-09 09:15:11.815 UTC [63] LOG:  Anweisung: show lc_monetary;
2023-01-09 10:15:11  lc_monetary
2023-01-09 10:15:11 -------------
2023-01-09 10:15:11  de_AT.utf8
2023-01-09 10:15:11 (1 Zeile)
2023-01-09 10:15:11
2023-01-09 10:15:11 2023-01-09 09:15:11.815 UTC [63] LOG:  Anweisung: CREATE DOMAIN public.nonnegmoney AS money
2023-01-09 10:15:11     CONSTRAINT nonnegmoney_check CHECK ((VALUE >= (0)::money));
2023-01-09 10:15:11 CREATE DOMAIN
2023-01-09 10:15:11 2023-01-09 09:15:11.816 UTC [63] LOG:  Anweisung: ALTER DOMAIN public.nonnegmoney OWNER TO vms_test;
2023-01-09 10:15:11 ALTER DOMAIN
2023-01-09 10:15:11 2023-01-09 09:15:11.817 UTC [63] LOG:  Anweisung: CREATE TABLE public.vms_test (
2023-01-09 10:15:11      id integer,
2023-01-09 10:15:11      money1 public.nonnegmoney,
2023-01-09 10:15:11      money2 money
2023-01-09 10:15:11 );
2023-01-09 10:15:11 CREATE TABLE
2023-01-09 10:15:11 2023-01-09 09:15:11.818 UTC [63] LOG:  Anweisung: ALTER TABLE public.vms_test OWNER TO vms_test;
2023-01-09 10:15:11 ALTER TABLE
2023-01-09 10:15:11 2023-01-09 09:15:11.819 UTC [63] LOG:  Anweisung: insert into public.vms_test (id, money1, money2) values (1, '€ 0,00', '€ 0,00');
2023-01-09 10:15:11 INSERT 0 1
2023-01-09 10:15:11 2023-01-09 09:15:11.820 UTC [63] LOG:  Anweisung: insert into public.vms_test (id, money1, money2) values (2, '€ 625,00', '€ 625,00');
2023-01-09 10:15:11 INSERT 0 1
2023-01-09 10:15:11 2023-01-09 09:15:11.820 UTC [63] LOG:  Anweisung: REVOKE ALL ON TABLE public.vms_test FROM PUBLIC;
2023-01-09 10:15:11 REVOKE
2023-01-09 10:15:11 2023-01-09 09:15:11.820 UTC [63] LOG:  Anweisung: REVOKE ALL ON TABLE public.vms_test FROM vms_test;
2023-01-09 10:15:11 REVOKE
2023-01-09 10:15:11 2023-01-09 09:15:11.821 UTC [63] LOG:  Anweisung: GRANT ALL ON TABLE public.vms_test TO vms_test;
2023-01-09 10:15:11 GRANT
2023-01-09 10:15:11
2023-01-09 10:15:11
2023-01-09 10:15:11 2023-01-09 09:15:11.827 UTC [49] LOG:  schnelles Herunterfahren verlangt
2023-01-09 10:15:11 warte auf Herunterfahren des Servers...2023-01-09 09:15:11.828 UTC [49] LOG:  etwaige aktive Transaktionen werden abgebrochen
2023-01-09 10:15:11 2023-01-09 09:15:11.832 UTC [49] LOG:  Background-Worker »logical replication launcher« (PID 55) beendete mit Status 1
2023-01-09 10:15:11 .2023-01-09 09:15:11.835 UTC [50] LOG:  fahre herunter
2023-01-09 10:15:11 2023-01-09 09:15:11.836 UTC [50] LOG:  Checkpoint beginnt: shutdown immediate
2023-01-09 10:15:12 2023-01-09 09:15:12.013 UTC [50] LOG:  Checkpoint komplett: 973 Puffer geschrieben (5.9%); 0 WAL-Datei(en) hinzugefügt, 0 entfernt, 0 wiederverwendet; Schreiben=0,083 s, Sync=0,091 s, gesamt=0,179 s; sync. Dateien=258, längste=0,003 s, Durchschnitt=0.001 s; Entfernung=4905 kB, Schätzung=4905 kB
2023-01-09 10:15:12 2023-01-09 09:15:12.056 UTC [49] LOG:  Datenbanksystem ist heruntergefahren
2023-01-09 10:15:12  fertig
2023-01-09 10:15:12 Server angehalten
2023-01-09 10:15:12
2023-01-09 10:15:12 PostgreSQL init process complete; ready for start up.
2023-01-09 10:15:12
2023-01-09 10:15:12 2023-01-09 09:15:12.188 UTC [1] LOG:  PostgreSQL 15.1 (Debian 15.1-1.pgdg110+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 10.2.1-6) 10.2.1 20210110, 64-bit startet
2023-01-09 10:15:12 2023-01-09 09:15:12.188 UTC [1] LOG:  erwarte Verbindungen auf IPv4-Adresse »0.0.0.0«, Port 5432
2023-01-09 10:15:12 2023-01-09 09:15:12.188 UTC [1] LOG:  erwarte Verbindungen auf IPv6-Adresse »::«, Port 5432
2023-01-09 10:15:12 2023-01-09 09:15:12.191 UTC [1] LOG:  erwarte Verbindungen auf Unix-Socket »/var/run/postgresql/.s.PGSQL.5432«
2023-01-09 10:15:12 2023-01-09 09:15:12.204 UTC [68] LOG:  Datenbanksystem wurde am 2023-01-09 09:15:12 UTC heruntergefahren
2023-01-09 10:15:12 2023-01-09 09:15:12.220 UTC [1] LOG:  Datenbanksystem ist bereit, um Verbindungen anzunehmen

This is the import script which is executed in the docker container:

#!/bin/bash

set -e

echo "=== 17-monetary-test.sql ==="
psql -v ON_ERROR_STOP=1 --username postgres --dbname postgres -f ../17-monetary-test.sql; echo;
echo "=== 18-monetry-test.sql.gz ==="
gunzip -c ../18-monetary-test.sql.gz | psql -v ON_ERROR_STOP=1 --username postgres --dbname vms_test; echo;

What do you think?

"SOLUTION"

I haven't found any real solution to this specific problem. All attempts with different postgres versions were unsuccessful, both with docker and directly on my Linux system.
Even if I execute all statements of the dump on the console, there is ultimately a problem with the import of larger amounts of money, because on newer Linux systems the thousands separator of lc_monetary for the locale de_AT has been changed from a normal space (<U0020>) to a non-breakable-space (<U202F>).

Since the official Docker container for postgres-9.5 is no longer supported, I got the Dockerfile for version 9.5 from the postgres git history, changed the apt directories to the archive directories and now have a running postgres-9.5 docker version, into which I can import the old database.
For our software upgrade to a current postgresql version, we will change all money columns to a numeric type!

Thank you for your help (especially @AdrianKlaver)


来源: stackexchange

问:
Read a very big .qvd file with iteration by row - unhandled bit types
I am trying to read with python a fairly large .qvd file into a DataFrame and then rewrite it in another file format, however when using this qvd.qvd_reader PyPI package and invoking:

df = qvd_reader.read(fpath)

I am getting "memory allocation of xxxxxxxxxxxx bytes failed", because obviously it cannot read/fetch all the data into the memory at once. My only option is to access N-rows of the .qvd (with a for loop) and write small files into chunks from that .qvd.

To do this I found this qvdfile repo and this thread.

The problem that I am facing is when I try to read any row with:

```<code>import qvdfile
qvd = qvdfile.QvdFile ("test.qvd")
print("First row of the file is {}".format(qvd.getRow(0))) # <- this lineis the issue

print("File has column '{}' with first value of '{}'".format(
        qvd.fields[0]["FieldName"], qvd.getFieldVal(qvd.fields[0]["FieldName"], 0)))
print("File has {} records".format(qvd.attribs["NoOfRecords"]))
</code>```

I am getting an error like:

UNHANDLED YET TYPE:  111

File has column 'StringColumn' with first value of 'None'

File has 3 records

Or UNHANDLED YET TYPE For values, ranging from 0 up to ? (255 I guess) - when trying with other .qvd files.

or error like:

bitstring.ReadError: Reading off the end of the data. Tried to read 32 bits when only 0 available.

Obviously the problem is with the incomplete code in
qvdfile.py at Line 130 (within the getFieldVal function)

My questions are -

• Can someone modify that sub, so it handles the rest of the byte types?

• Has anyone succeeded in reading such big .qvd files (without the QV api) and how?

• Is there any other library that can read a .qvd row by row that I am not aware of.

FYI -

• I tried to solve my problem with ChatGPT, without success.

• No access to Qlikview API on my machine (so please dont suggest win32com.Dispatch('QlikTech.QlikView')

• The .qvd files that I'm trying to read look like:

# File3.qvd - File has 67404124 records - memory allocation of x bytes failed

# File2.qvd - File has 48452228 records - memory allocation of x bytes failed

# File1.qvd - File has 25701860 records - was able to read with qvd.qvd_reader

ContentLicense: CC BY-SA 4.0

Body:
I am trying to read with python a fairly large .qvd file into a DataFrame and then rewrite it in another file format, however when using this qvd.qvd_reader PyPI package and invoking:

df = qvd_reader.read(fpath)

I am getting "memory allocation of xxxxxxxxxxxx bytes failed", because obviously it cannot read/fetch all the data into the memory at once. My only option is to access N-rows of the .qvd (with a for loop) and write small files into chunks from that .qvd.

To do this I found this qvdfile repo and this thread.

The problem that I am facing is when I try to read any row with:

import qvdfile
qvd = qvdfile.QvdFile ("test.qvd")
print("First row of the file is {}".format(qvd.getRow(0))) # <- this lineis the issue

print("File has column '{}' with first value of '{}'".format(
        qvd.fields[0]["FieldName"], qvd.getFieldVal(qvd.fields[0]["FieldName"], 0)))
print("File has {} records".format(qvd.attribs["NoOfRecords"]))

I am getting an error like:

UNHANDLED YET TYPE:  111

File has column 'StringColumn' with first value of 'None'

File has 3 records

Or UNHANDLED YET TYPE For values, ranging from 0 up to ? (255 I guess) - when trying with other .qvd files.

or error like:

bitstring.ReadError: Reading off the end of the data. Tried to read 32 bits when only 0 available.

Obviously the problem is with the incomplete code in
qvdfile.py at Line 130 (within the getFieldVal function)

My questions are -

• Can someone modify that sub, so it handles the rest of the byte types?

• Has anyone succeeded in reading such big .qvd files (without the QV api) and how?

• Is there any other library that can read a .qvd row by row that I am not aware of.

FYI -

• I tried to solve my problem with ChatGPT, without success.

• No access to Qlikview API on my machine (so please dont suggest win32com.Dispatch('QlikTech.QlikView')

• The .qvd files that I'm trying to read look like:

# File3.qvd - File has 67404124 records - memory allocation of x bytes failed

# File2.qvd - File has 48452228 records - memory allocation of x bytes failed

# File1.qvd - File has 25701860 records - was able to read with qvd.qvd_reader


问:
How can I preserve search efficiency, and reduce RAM usage of a dictionary container?
I'm keeping a record of what I'm calling profiles.

Each profile is a tuple of dictionaries: (Dict,Dict), and we can associate to it a unique id(may include characters like _ or -).

I need to keep them in RAM memory for a certain time, because I'll need to search and updated some of them, and only at the end, when I no longer need the whole set of profiles will I flush them to persistent storage.

Currently, I'm using a dictionary/hash table to keep all of them (number of elements around 100K, but could be more), since I'll do many searches, using the id:profile as the key:value pair.

The data looks similar to this:

```<code>{
"Aw23_1adGF":({
     "data":
        {"contacts":[11,22],"address":"usa"},
     "meta_data":
        {"created_by":"John"}
    },{"key_3":"yes"}),
"AK23_1adGF":({
     "data":
        {"contacts":[33,44],"address":"mexico"},
     "meta_data":
        {"created_by":"Juan"}
    },{"key_3":"no"}),
# ...
}
</code>```

Once this data structure is built, I don't need to add/delete any more elements. I only build it once, than search it many times. On certain occasions I'll need to update some element in the dictionaries that compose a profile. However, building this data object contributes to the peak RAM usage that I'm trying to diminish.

The problem is that the dictionary seems to use too much RAM.

What were my other options regarding data structures that could keep some of the search efficiency and with a small RAM footprint?

I thought of an ordered list, since the id seems to me to be orderable (maybe except for characters like _ or -).

What data structures are there that could help me in this predicament?

Body:
I'm keeping a record of what I'm calling profiles.

Each profile is a tuple of dictionaries: (Dict,Dict), and we can associate to it a unique id(may include characters like _ or -).

I need to keep them in RAM memory for a certain time, because I'll need to search and updated some of them, and only at the end, when I no longer need the whole set of profiles will I flush them to persistent storage.

Currently, I'm using a dictionary/hash table to keep all of them (number of elements around 100K, but could be more), since I'll do many searches, using the id:profile as the key:value pair.

The data looks similar to this:

{
"Aw23_1adGF":({
     "data":
        {"contacts":[11,22],"address":"usa"},
     "meta_data":
        {"created_by":"John"}
    },{"key_3":"yes"}),
"AK23_1adGF":({
     "data":
        {"contacts":[33,44],"address":"mexico"},
     "meta_data":
        {"created_by":"Juan"}
    },{"key_3":"no"}),
# ...
}

Once this data structure is built, I don't need to add/delete any more elements. I only build it once, than search it many times. On certain occasions I'll need to update some element in the dictionaries that compose a profile. However, building this data object contributes to the peak RAM usage that I'm trying to diminish.

The problem is that the dictionary seems to use too much RAM.

What were my other options regarding data structures that could keep some of the search efficiency and with a small RAM footprint?

I thought of an ordered list, since the id seems to me to be orderable (maybe except for characters like _ or -).

What data structures are there that could help me in this predicament?


问:
Unity Photon | How Can I Delete a Room When the Owner Leaves?
I am making an online game project for the first time and I have made systems such as leaving the room, setting up a room, but when I click the "delete room" button, I want to delete the room and kick everyone in it. How can I do that?

i tried PhotonNetwork.CurrentRoom.isOpen = false and PhotonNetwork.CurrentRoom.isVisible = false didn't work.


问:
Jsp show element on condition
I am trying to check that attribute in http session storage called "username" is there/not there in http session storage.
If it is in http session storage it will show a button.
If is not in http session storage the button should not be shown.

I have tried the following methods, both do not seem to work

First method: Review button shows up when "username" both when "username" is in http storage and not in http storage

```<code><%
                String username1 = (String) session.getAttribute("username");

                %>
                <c:if test = "${username1.length()!=0}">
                    <button class="btn btn-primary" style="background-color: #887775; border: none;" id="myBtn">Write a review</button>
                </c:if>
</code>```

Second method: Review button does not show up at all whether "username" is there or not there in http session storage

```<code><%
                String username1 = (String) session.getAttribute("username");

                %>
                <c:if test = "${username1.isEmpty()==true}">
                    <button class="btn btn-primary" style="background-color: #887775; border: none;" id="myBtn">Write a review</button>
                </c:if>
</code>```

Any help will be appreciated!

Title: Jsp show element on condition

Body:
I am trying to check that attribute in http session storage called "username" is there/not there in http session storage.
If it is in http session storage it will show a button.
If is not in http session storage the button should not be shown.

I have tried the following methods, both do not seem to work

First method: Review button shows up when "username" both when "username" is in http storage and not in http storage

<%
                String username1 = (String) session.getAttribute("username");

                %>
                <c:if test = "${username1.length()!=0}">
                    <button class="btn btn-primary" style="background-color: #887775; border: none;" id="myBtn">Write a review</button>
                </c:if>

Second method: Review button does not show up at all whether "username" is there or not there in http session storage

<%
                String username1 = (String) session.getAttribute("username");

                %>
                <c:if test = "${username1.isEmpty()==true}">
                    <button class="btn btn-primary" style="background-color: #887775; border: none;" id="myBtn">Write a review</button>
                </c:if>

Any help will be appreciated!


问:
Android - HealthConnectClient.readRecords or aggregateGroupByPeriod takes forever
Below codes takes forever to execute. Get it from official docs. HealthConnect is installed on the device.I believe there is an inner error that i cant see in logs of IDE. Code is called from java class.

What can cause this?

```<code>companion object {
    fun readStepsByTimeRange(
        healthConnectClient: HealthConnectClient,
        startTime: Instant,
        endTime: Instant
    ) : CompletableFuture<Long> = GlobalScope.future {
        innerReadStepsByTimeRange(healthConnectClient, startTime, endTime)
    }

    private suspend fun innerReadStepsByTimeRange (
        healthConnectClient: HealthConnectClient,
        startTime: Instant,
        endTime: Instant
    ) : Long {
        /*var totalStepsCount = 0L
        val response =
            healthConnectClient.readRecords(
                ReadRecordsRequest(
                    StepsRecord::class,
                    timeRangeFilter = TimeRangeFilter.between(startTime, endTime)
                )
            )
        for (stepRecord in response.records) {
            totalStepsCount += stepRecord.count;
        }
        return totalStepsCount*/
        val startTime = LocalDateTime.now().minusMonths(1)
        val endTime = LocalDateTime.now()

        try {

            val response =
                healthConnectClient.aggregateGroupByPeriod(
                    AggregateGroupByPeriodRequest(
                        metrics = setOf(StepsRecord.COUNT_TOTAL),
                        timeRangeFilter = TimeRangeFilter.between(startTime, endTime),
                        timeRangeSlicer = Period.ofDays(1)
                    )
                )

            return response[0].result[StepsRecord.COUNT_TOTAL]!!
        }catch (e: Exception) {
            return -1
        }
    }
}
</code>```

Java caller code below

```<code>CompletableFuture<Long> totalStepsCountCF = StepReaderUtils.Companion.readStepsByTimeRange(
        healthConnectClient, startDate, endDate);
return totalStepsCountCF.get();
</code>```

build.gradle

```<code>implementation 'org.jetbrains.kotlin:kotlin-stdlib:1.8.0'
implementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.8.0'
implementation "androidx.health.connect:connect-client:1.0.0-alpha08"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-jdk8:1.6.4"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.4"
</code>```

Body:
Below codes takes forever to execute. Get it from official docs. HealthConnect is installed on the device.I believe there is an inner error that i cant see in logs of IDE. Code is called from java class.

What can cause this?

companion object {
    fun readStepsByTimeRange(
        healthConnectClient: HealthConnectClient,
        startTime: Instant,
        endTime: Instant
    ) : CompletableFuture<Long> = GlobalScope.future {
        innerReadStepsByTimeRange(healthConnectClient, startTime, endTime)
    }

    private suspend fun innerReadStepsByTimeRange (
        healthConnectClient: HealthConnectClient,
        startTime: Instant,
        endTime: Instant
    ) : Long {
        /*var totalStepsCount = 0L
        val response =
            healthConnectClient.readRecords(
                ReadRecordsRequest(
                    StepsRecord::class,
                    timeRangeFilter = TimeRangeFilter.between(startTime, endTime)
                )
            )
        for (stepRecord in response.records) {
            totalStepsCount += stepRecord.count;
        }
        return totalStepsCount*/
        val startTime = LocalDateTime.now().minusMonths(1)
        val endTime = LocalDateTime.now()

        try {

            val response =
                healthConnectClient.aggregateGroupByPeriod(
                    AggregateGroupByPeriodRequest(
                        metrics = setOf(StepsRecord.COUNT_TOTAL),
                        timeRangeFilter = TimeRangeFilter.between(startTime, endTime),
                        timeRangeSlicer = Period.ofDays(1)
                    )
                )

            return response[0].result[StepsRecord.COUNT_TOTAL]!!
        }catch (e: Exception) {
            return -1
        }
    }
}

Java caller code below

CompletableFuture<Long> totalStepsCountCF = StepReaderUtils.Companion.readStepsByTimeRange(
        healthConnectClient, startDate, endDate);
return totalStepsCountCF.get();

build.gradle

implementation 'org.jetbrains.kotlin:kotlin-stdlib:1.8.0'
implementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.8.0'
implementation "androidx.health.connect:connect-client:1.0.0-alpha08"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-jdk8:1.6.4"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.4"


问:
initialization variable changed in each iteration in a for clause
A passed parameter was changed in the middle of the code without changing or manipulating the variable

I launched a C program with this command:

```<code>anonymous DELAI_ANONYME=O sanspm=O
</code>```

The main function code is below:

```<code>int main(int argc, char *argv[])
{
  EXEC SQL BEGIN DECLARE SECTION;
    SQL100 qstrRefIndiv = {0};
    int qiCheckIndiv = 0;
    SQL20 qstrTrigStatus = {0};
  EXEC SQL END DECLARE SECTION;

  char strLogName[100] = {0};
  char strRef[100] = {0};
  int iNoCommit = 0;
  int i = 0;
  int iDelCase=0;
  char strDelai[1];
  char strSanspm[1];
  strcpy(strDelai, "N");
  strcpy(strSanspm, "N");
  char selectcof[1000]= {0};
  initscr();
  bkg_init();

  for(i=1; i<argc; i++)
  {
    refresh();
    db_log_message (LL_INFO, "Iter Nbr= [%d]\n", i);

    if(strcmp(argv[i],"NOCOMMIT")==0)
    {
      iNoCommit = 1;
    }
    if(strncmp(argv[i], "ref=", 4)==0)
    {
       strcpy(strRef,&argv[i][4]);
       strcpy (qstrRefIndiv, strRef);
       db_log_message (LL_INFO, "ref param= [%s]\n", qstrRefIndiv);
    }
    if(strncmp(argv[i], "DELAI_ANONYME=", 14)==0)
    {
       strcpy(strDelai,&argv[i][14]);
       db_log_message (LL_INFO, "ref Delai= [%s]\n", strDelai);
    }
    if(strncmp(argv[i], "delcase=", 8)==0)
    {
       iDelCase=atoi(&argv[i][8]);
       db_log_message (LL_INFO, "ref iDelCase= [%s]\n", iDelCase);
    }
    if(strncmp(argv[i], "sanspm=", 7)==0)
    {
       db_log_message (LL_INFO, "[sanspm] before ref Delai= [%s]\n", strDelai);
       strcpy(strSanspm,&argv[i][7]);
       db_log_message (LL_INFO, "ref strSanspm= [%s]\n", strSanspm);
       db_log_message (LL_INFO, "[sanspm] after ref Delai= [%s]\n", strDelai);
    }
  }

  db_log_message (LL_INFO, "ref Delai 1= [%s]\n", strDelai);
  db_log_message (LL_INFO, "ref strSanspm 1= [%s]\n", strSanspm);
  ...
  endwin();
  return(0);
}
</code>```

After checking the log file I see that the DELAI_ANONYME variable was changed in the middel of the for clause as shown in the logs after launching the program

Log:

```<code>[INFO ] [    0.017] Iter Nbr= [1]
[INFO ] [    0.000] ref Delai= [O]
[INFO ] [    0.000] Iter Nbr= [2]
[INFO ] [    0.000] [sanspm] before ref Delai= [O]
[INFO ] [    0.000] ref strSanspm= [O]
[INFO ] [    0.000] [sanspm] after ref Delai= []
[INFO ] [    0.000] ref Delai 1= []
[INFO ] [    0.000] ref strSanspm 1= [O]
</code>```

When I changed the order of the parameters I got the below behavior with this command:

```<code>anonymous sanspm=O DELAI_ANONYME=O
</code>```

I see the DELAI_ANONYME variable is OK but at the same time strSanspm variable is taking another character that is not initialized at the beginning 'OO'

Log:

```<code>[INFO ] [    0.001] Iter Nbr= [1]
[INFO ] [    0.000] [sanspm] before ref Delai= []
[INFO ] [    0.000] ref strSanspm= [O]
[INFO ] [    0.000] [sanspm] after ref Delai= []
[INFO ] [    0.000] Iter Nbr= [2]
[INFO ] [    0.000] ref Delai= [O]
[INFO ] [    0.000] ref Delai 1= [O]
[INFO ] [    0.000] ref strSanspm 1= [OO]
</code>```

Body:
A passed parameter was changed in the middle of the code without changing or manipulating the variable

I launched a C program with this command:

anonymous DELAI_ANONYME=O sanspm=O

The main function code is below:

int main(int argc, char *argv[])
{
  EXEC SQL BEGIN DECLARE SECTION;
    SQL100 qstrRefIndiv = {0};
    int qiCheckIndiv = 0;
    SQL20 qstrTrigStatus = {0};
  EXEC SQL END DECLARE SECTION;

  char strLogName[100] = {0};
  char strRef[100] = {0};
  int iNoCommit = 0;
  int i = 0;
  int iDelCase=0;
  char strDelai[1];
  char strSanspm[1];
  strcpy(strDelai, "N");
  strcpy(strSanspm, "N");
  char selectcof[1000]= {0};
  initscr();
  bkg_init();

  for(i=1; i<argc; i++)
  {
    refresh();
    db_log_message (LL_INFO, "Iter Nbr= [%d]\n", i);

    if(strcmp(argv[i],"NOCOMMIT")==0)
    {
      iNoCommit = 1;
    }
    if(strncmp(argv[i], "ref=", 4)==0)
    {
       strcpy(strRef,&argv[i][4]);
       strcpy (qstrRefIndiv, strRef);
       db_log_message (LL_INFO, "ref param= [%s]\n", qstrRefIndiv);
    }
    if(strncmp(argv[i], "DELAI_ANONYME=", 14)==0)
    {
       strcpy(strDelai,&argv[i][14]);
       db_log_message (LL_INFO, "ref Delai= [%s]\n", strDelai);
    }
    if(strncmp(argv[i], "delcase=", 8)==0)
    {
       iDelCase=atoi(&argv[i][8]);
       db_log_message (LL_INFO, "ref iDelCase= [%s]\n", iDelCase);
    }
    if(strncmp(argv[i], "sanspm=", 7)==0)
    {
       db_log_message (LL_INFO, "[sanspm] before ref Delai= [%s]\n", strDelai);
       strcpy(strSanspm,&argv[i][7]);
       db_log_message (LL_INFO, "ref strSanspm= [%s]\n", strSanspm);
       db_log_message (LL_INFO, "[sanspm] after ref Delai= [%s]\n", strDelai);
    }
  }

  db_log_message (LL_INFO, "ref Delai 1= [%s]\n", strDelai);
  db_log_message (LL_INFO, "ref strSanspm 1= [%s]\n", strSanspm);
  ...
  endwin();
  return(0);
}

After checking the log file I see that the DELAI_ANONYME variable was changed in the middel of the for clause as shown in the logs after launching the program

Log:

[INFO ] [    0.017] Iter Nbr= [1]
[INFO ] [    0.000] ref Delai= [O]
[INFO ] [    0.000] Iter Nbr= [2]
[INFO ] [    0.000] [sanspm] before ref Delai= [O]
[INFO ] [    0.000] ref strSanspm= [O]
[INFO ] [    0.000] [sanspm] after ref Delai= []
[INFO ] [    0.000] ref Delai 1= []
[INFO ] [    0.000] ref strSanspm 1= [O]

When I changed the order of the parameters I got the below behavior with this command:

anonymous sanspm=O DELAI_ANONYME=O

I see the DELAI_ANONYME variable is OK but at the same time strSanspm variable is taking another character that is not initialized at the beginning 'OO'

Log:

[INFO ] [    0.001] Iter Nbr= [1]
[INFO ] [    0.000] [sanspm] before ref Delai= []
[INFO ] [    0.000] ref strSanspm= [O]
[INFO ] [    0.000] [sanspm] after ref Delai= []
[INFO ] [    0.000] Iter Nbr= [2]
[INFO ] [    0.000] ref Delai= [O]
[INFO ] [    0.000] ref Delai 1= [O]
[INFO ] [    0.000] ref strSanspm 1= [OO]


问:
Why is certificate invalid for one .net core web api project only?
I have .Net solution with two .Net core web API projects in it.
Both projects have swagger set up and for both projects, the HTTP URL works fine.

However, for the HTTPS URL, it works for one project but not the other.
The certificate is deemed invalid by the browser for the project that sees the error.

I've looked for a solution for hours and tried the following commands but could not make it work.

```<code>dotnet dev-certs https --clean
dotnet dev-certs https
dotnet dev-certs https --trust
</code>```

If I check the existence of the cert and if it is trusted, with dotnet dev-certs https -c -t, I see that the cert is present and trusted.

Then, using dotnet run, I have no compiling issue or anything but in the browser, only one of the project works and displays the swagger HTTPS page ...

I don't think I understand enough how certificates work between the browser and .net core to understand why I'm having this issue.

Do you have any idea how to fix it?

Here are a few observations that I hope may help:

The projects are identical and were simply created with Visual Studio, so that should not be something in the code that's in the way.

I don't see any certificate in the windows certificate manager. Since it works for one project, I don't understand where the certificate is stored.

If I clean the certificates and check again, it tells me that, as expected, there is no certificate found. After that, if I run dotnet run on each project, the one that used to work gives me an error saying it could not generate the https endpoints. That makes sense since the certificate is not present anymore. However, the one that was not working before I remove the certificates does not give me an error and runs like if nothing happened (though of course, still not working) ... I suspect it's not trying to create the https endpoint but I don't know why.

Do you know why one project would work and not another?
Where is the HTTPS endpoint created and what triggers that creation?

Body:
I have .Net solution with two .Net core web API projects in it.
Both projects have swagger set up and for both projects, the HTTP URL works fine.

However, for the HTTPS URL, it works for one project but not the other.
The certificate is deemed invalid by the browser for the project that sees the error.

I've looked for a solution for hours and tried the following commands but could not make it work.

dotnet dev-certs https --clean
dotnet dev-certs https
dotnet dev-certs https --trust

If I check the existence of the cert and if it is trusted, with dotnet dev-certs https -c -t, I see that the cert is present and trusted.

Then, using dotnet run, I have no compiling issue or anything but in the browser, only one of the project works and displays the swagger HTTPS page ...

I don't think I understand enough how certificates work between the browser and .net core to understand why I'm having this issue.

Do you have any idea how to fix it?

Here are a few observations that I hope may help:

The projects are identical and were simply created with Visual Studio, so that should not be something in the code that's in the way.

I don't see any certificate in the windows certificate manager. Since it works for one project, I don't understand where the certificate is stored.

If I clean the certificates and check again, it tells me that, as expected, there is no certificate found. After that, if I run dotnet run on each project, the one that used to work gives me an error saying it could not generate the https endpoints. That makes sense since the certificate is not present anymore. However, the one that was not working before I remove the certificates does not give me an error and runs like if nothing happened (though of course, still not working) ... I suspect it's not trying to create the https endpoint but I don't know why.

Do you know why one project would work and not another?
Where is the HTTPS endpoint created and what triggers that creation?


问:
react-hook-form onsubmit data showing old defaultvalues, (although watch prints updated value)
React-hook-form issue:
I have a table which is responsive, but the layout is different so I have 2 different component for this.

This is a table, where the user can edit it's content.
Here is the layout:

When the user clicks on the green button, the editing will be done, and the values will be saved. It's a bit tricky, because the the button trigger the react-hook-form onSubmit which is in a different component solved with forwardRef.

```<code>("react-hook-form": "^7.38.0",)
</code>```

Here is the EditableView code:

```<code>import React, { forwardRef } from "react";
import { useForm, useFieldArray } from "react-hook-form";
import { useProfileContext } from "../../context/ProfileContext";
import PrimaryButton from "../Button/PrimaryButton";

const EditableDayMenu = forwardRef(({ weekOfYear, dayOfWeek, menu }, ref) => {
  const { register, control, handleSubmit, watch, getValues } = useForm({
    defaultValues: {
      menu: menu?.map((item) => {
        return {
          menuCategory: item.menuCategory,
          menuDescription: item.menuDescription,
        };
      }),
    },
  });

  const { fields, append, remove } = useFieldArray({
    control,
    name: "menu",
  });
  const { handleMenu } = useProfileContext();

  const onSubmit = (data) => {
    console.log(Data);
    handleMenu(weekOfYear, dayOfWeek, data);
  };

  console.log(watch());

  return (
    <form onSubmit={handleSubmit(onSubmit)}>
      {fields.map((item, index) => {
        return (
          <div className="" key={item.id}>
            <label className="block text-gray-700 text-sm font-bold mb-2">
              Menü kategória
            </label>
            <input
              className="shadow appearance-none border rounded w-full py-2 px-3 text-gray-700 leading-tight focus:outline-none focus:shadow-outline"
              {...register(`menu.${index}.menuCategory`, { required: true })}
            />
            <label className="block text-gray-700 text-sm font-bold mb-2">
              Menü leírása
            </label>
            <textarea
              rows={5}
              className="shadow appearance-none border rounded w-full py-2 px-3 text-gray-700 leading-tight focus:outline-none focus:shadow-outline"
              {...register(`menu.${index}.menuDescription`, { required: true })}
            />

            <button
              className="mb-3"
              type="button"
              onClick={() => remove(index)}
            >
              Menü törlése
            </button>
          </div>
        );
      })}
      <button
        className="block lg:hidden xl:block mx-auto"
        type="button"
        onClick={() => {
          append({ menuCategory: "", menuDescription: "" });
        }}
      >
        <PrimaryButton text={"Új menü hozzáadása"} />
      </button>
      <button
        className="hidden lg:block xl:hidden mx-auto"
        type="button"
        onClick={() => {
          append({ menuCategory: "", menuDescription: "" });
        }}
      >
        <PrimaryButton text={"+"} />
      </button>
      <button hidden={true} ref={ref} type={"submit"} />
    </form>
  );
});

export default EditableDayMenu;
EditableDayMenu.displayName = "EditableDayMenu";
</code>```

The whole menu with the refs:

```<code>const WeeklyMenu = ({ allMenu, isEditable = true }) => {
  const [currentWeek, setCurrentWeek] = useState();
  const [isEditView, setIsEditView] = useState(false);
  const fixWeek = Number(moment().format("w"));
  const arrLength = 7;
  const elRefs = React.useRef([]);
  const mobileelRefs = React.useRef([]);
  const [isMobileView, setIsMobileView] = useState();

  const handleResize = () => {
     window.innerWidth>1024 ? setIsMobileView(false) :
     setIsMobileView(true)
  }

  if (elRefs.current.length !== arrLength) {
    // add or remove refs
    elRefs.current = Array(arrLength)
      .fill()
      .map((_, i) => elRefs.current?.[i] || createRef());
  }

  if (mobileelRefs.current.length !== arrLength) {
    // add or remove refs
    mobileelRefs.current = Array(arrLength)
      .fill()
      .map((_, i) => mobileelRefs.current?.[i] || createRef());
  }

  const menuThisWeek = menuOfTheWeek(currentWeek);

  return (
    <div className="text-Brand-Primary relative pt-4 lg:pt-0">
      {menuThisWeek != null && isEditable && (
        <div className="flex items-center gap-x-2 absolute right-0 w-full justify-center sm:w-fit">

          {!isEditView ? (
            <button
              onClick={() => setIsEditView(true)}
              className="bg-Brand-Secondary rounded-2xl px-3 py-2 text-white hover:bg-opacity-80"
            >
              Menü szerkesztése
            </button>
          ) : (
            <button
              onClick={() => {
                setIsEditView(false);
                const weekResponsiveButtons = isMobileView ? mobileelRefs : elRefs
                console.log(isMobileView)
                weekResponsiveButtons.current.forEach((ref) => {
                  console.log(ref.current);
                  ref.current?.click();
                });
              }}
              className="bg-green-500 rounded-2xl px-3 py-2 text-white hover:bg-opacity-80"
            >
              Mentés
            </button>
          )}
        </div>
      )}
      <div className="block lg:hidden h-12" />
      <p className="text-3xl">Heti menü</p>

      <div className="w-full space-x-3 hidden lg:flex">
      <DesktopWeeklyMenu
          isEditView={isEditView}
          weeks={getCurrentWeek(fixWeek - currentWeek)}
          menus={menuThisWeek}
          currentWeek={currentWeek}
          elRefs={elRefs}
          menuThisWeek={menuThisWeek}
        />
      </div>
      {(
        <MobileWeeklyMenu
          isEditView={isEditView}
          weeks={getCurrentWeek(fixWeek - currentWeek)}
          menus={menuThisWeek}
          currentWeek={currentWeek}
          elRefs={mobileelRefs}
          menuThisWeek={menuThisWeek}
        />
      )}

      {menuThisWeek == null && (
        <UnlockMenuWeek weekOfYear={currentWeek} isEditable={isEditable} />
      )}
    </div>
  );
};

export default WeeklyMenu;
</code>```

When I try to edit in the desktop layout, it works perfectly, in the mobile layout it's not, although we are using the same EditableDayMenu component in both:

```<code>  const onSubmit = (data) => {
    handleMenu(weekOfYear, dayOfWeek, data)
};

    console.log(watch())
</code>```

When we try to submit the form, the data only shows the old (defaultValues), but the console.log(watch()) prints out the latest updated fields, so I don't understand why it is not the same in the onsubmit (and what is the difference between my desktop and mobile approach?)

Desktop layout:

```<code>import React from 'react'
import EditableDayMenu from './EditableDayMenu';

const DesktopWeeklyMenu = ({
    isEditView,
    weeks,
    menus,
    currentWeek,
    elRefs,
    menuThisWeek,
}) => {
  return (
    <table className="table-fixed w-[90%] mx-auto border-2 border-gray-500 rounded-xl">
    <thead>
      <tr>
        {weeks.map((item) => {
          return (
            <th
              key={item}
              className="border border-gray-400 text-Brand-Secondary px-1 xl:px-6"
            >
              {item}
            </th>
          );
        })}
      </tr>
    </thead>
    <tbody>
      <tr>
        {menuThisWeek?.map((day, dayOfWeek) => {
          return (
            <td
              key={day + dayOfWeek}
              valign="top"
              className="border border-gray-400 p-1 2xl:p-3"
            >
              <div className="flex flex-col gap-y-3">
                {!isEditView &&
                  day.day?.map((menu, idx) => {
                    return (
                      <div key={menu.menuCategory + idx}>
                        <p className="font-bold text-lg">
                          {menu.menuCategory}
                        </p>
                        <p className="font-base text-gray-700 break-all">
                          {menu.menuDescription}
                        </p>
                      </div>
                    );
                  })}
              </div>
              {isEditView && (
                <EditableDayMenu
                  ref={elRefs.current[dayOfWeek]}
                  weekOfYear={currentWeek}
                  dayOfWeek={dayOfWeek}
                  menu={day.day}
                />

              )}
            </td>
          );
        })}
      </tr>
    </tbody>
  </table>
    )
}

export default DesktopWeeklyMenu
</code>```

Mobile layout:

```<code>import React from "react";
import EditableDayMenu from "./EditableDayMenu";
import UnlockMenuWeek from "./UnlockMenuWeek";

const MobileWeeklyMenu = ({
  isEditView,
  weeks,
  menus,
  currentWeek,
  elRefs,
  menuThisWeek,
}) => {

  return (
    <table className="w-full mx-auto border-collapse border-spacing-10 block lg:hidden whitespace-normal border-2 border-gray-500 rounded-xl overflow-x-auto">
      {weeks.map((week, dayOfWeek) => {
        return (
          <tr key={week}>
            <th className="border w-[30%] border-gray-400 text-Brand-Secondary px-1 xl:px-6">
              {week}
            </th>
            <td valign="top" className={`border border-gray-400 p-3 ${menuThisWeek==null ? 'bg-slate-200' :''}`}>
              {menus?.[dayOfWeek]?.day?.map((day, index) => {
                return !isEditView ? (
                  <div key={day.menuCategory + index}>
                    <p className="font-bold text-lg">{day.menuCategory}</p>
                    <p className="font-base text-gray-700 break-all">
                      {day.menuDescription}
                    </p>
                  </div>
                ) : (
                  <EditableDayMenu
                    key={day.menuCategory + index+"edit"}
                    ref={elRefs.current[dayOfWeek]}
                    weekOfYear={currentWeek}
                    dayOfWeek={dayOfWeek}
                    menu={menus?.[dayOfWeek]?.day}
                  />
                );
              })}
            </td>
          </tr>
        );
      })}

    </table>
  );
};

export default MobileWeeklyMenu;
</code>```

Here is an example of the log in the mobile layout:

Watch:

```<code>{menu: Array(3)}menu: Array(3)0: {menuCategory: 'EDIT CATEGORY NAME', menuDescription: 'Leves minden leírva blabla, második'}1: ...
</code>```

OnSubmit:

```<code> {menu: Array(3)}menu: Array(3)0: {menuCategory: 'a1', menuDescription: 'Leves minden leírva blabla, második'}1: ...
</code>```

After save:

You can see, that the edited value will not be stored, it's very strange, because the same works in the desktop version, hope you guys can help me figure it out.

Body:
React-hook-form issue:
I have a table which is responsive, but the layout is different so I have 2 different component for this.

This is a table, where the user can edit it's content.
Here is the layout:

When the user clicks on the green button, the editing will be done, and the values will be saved. It's a bit tricky, because the the button trigger the react-hook-form onSubmit which is in a different component solved with forwardRef.

("react-hook-form": "^7.38.0",)

Here is the EditableView code:

import React, { forwardRef } from "react";
import { useForm, useFieldArray } from "react-hook-form";
import { useProfileContext } from "../../context/ProfileContext";
import PrimaryButton from "../Button/PrimaryButton";

const EditableDayMenu = forwardRef(({ weekOfYear, dayOfWeek, menu }, ref) => {
  const { register, control, handleSubmit, watch, getValues } = useForm({
    defaultValues: {
      menu: menu?.map((item) => {
        return {
          menuCategory: item.menuCategory,
          menuDescription: item.menuDescription,
        };
      }),
    },
  });

  const { fields, append, remove } = useFieldArray({
    control,
    name: "menu",
  });
  const { handleMenu } = useProfileContext();

  const onSubmit = (data) => {
    console.log(Data);
    handleMenu(weekOfYear, dayOfWeek, data);
  };

  console.log(watch());

  return (
    <form onSubmit={handleSubmit(onSubmit)}>
      {fields.map((item, index) => {
        return (

              Menü kategória

            <input
              className="shadow appearance-none border rounded w-full py-2 px-3 text-gray-700 leading-tight focus:outline-none focus:shadow-outline"
              {...register(`menu.${index}.menuCategory`, { required: true })}
            />

              Menü leírása

            <textarea
              rows={5}
              className="shadow appearance-none border rounded w-full py-2 px-3 text-gray-700 leading-tight focus:outline-none focus:shadow-outline"
              {...register(`menu.${index}.menuDescription`, { required: true })}
            />

            <button
              className="mb-3"
              type="button"
              onClick={() => remove(index)}
            >
              Menü törlése
            </button>

        );
      })}
      <button
        className="block lg:hidden xl:block mx-auto"
        type="button"
        onClick={() => {
          append({ menuCategory: "", menuDescription: "" });
        }}
      >
        <PrimaryButton text={"Új menü hozzáadása"} />
      </button>
      <button
        className="hidden lg:block xl:hidden mx-auto"
        type="button"
        onClick={() => {
          append({ menuCategory: "", menuDescription: "" });
        }}
      >
        <PrimaryButton text={"+"} />
      </button>
      <button hidden={true} ref={ref} type={"submit"} />
    </form>
  );
});

export default EditableDayMenu;
EditableDayMenu.displayName = "EditableDayMenu";

The whole menu with the refs:

const WeeklyMenu = ({ allMenu, isEditable = true }) => {
  const [currentWeek, setCurrentWeek] = useState();
  const [isEditView, setIsEditView] = useState(false);
  const fixWeek = Number(moment().format("w"));
  const arrLength = 7;
  const elRefs = React.useRef([]);
  const mobileelRefs = React.useRef([]);
  const [isMobileView, setIsMobileView] = useState();

  const handleResize = () => {
     window.innerWidth>1024 ? setIsMobileView(false) :
     setIsMobileView(true)
  }

  if (elRefs.current.length !== arrLength) {
    // add or remove refs
    elRefs.current = Array(arrLength)
      .fill()
      .map((_, i) => elRefs.current?.[i] || createRef());
  }

  if (mobileelRefs.current.length !== arrLength) {
    // add or remove refs
    mobileelRefs.current = Array(arrLength)
      .fill()
      .map((_, i) => mobileelRefs.current?.[i] || createRef());
  }

  const menuThisWeek = menuOfTheWeek(currentWeek);

  return (

      {menuThisWeek != null && isEditable && (

          {!isEditView ? (
            <button
              onClick={() => setIsEditView(true)}
              className="bg-Brand-Secondary rounded-2xl px-3 py-2 text-white hover:bg-opacity-80"
            >
              Menü szerkesztése
            </button>
          ) : (
            <button
              onClick={() => {
                setIsEditView(false);
                const weekResponsiveButtons = isMobileView ? mobileelRefs : elRefs
                console.log(isMobileView)
                weekResponsiveButtons.current.forEach((ref) => {
                  console.log(ref.current);
                  ref.current?.click();
                });
              }}
              className="bg-green-500 rounded-2xl px-3 py-2 text-white hover:bg-opacity-80"
            >
              Mentés
            </button>
          )}

      )}

Heti menü

      <DesktopWeeklyMenu
          isEditView={isEditView}
          weeks={getCurrentWeek(fixWeek - currentWeek)}
          menus={menuThisWeek}
          currentWeek={currentWeek}
          elRefs={elRefs}
          menuThisWeek={menuThisWeek}
        />

      {(
        <MobileWeeklyMenu
          isEditView={isEditView}
          weeks={getCurrentWeek(fixWeek - currentWeek)}
          menus={menuThisWeek}
          currentWeek={currentWeek}
          elRefs={mobileelRefs}
          menuThisWeek={menuThisWeek}
        />
      )}

      {menuThisWeek == null && (
        <UnlockMenuWeek weekOfYear={currentWeek} isEditable={isEditable} />
      )}

  );
};

export default WeeklyMenu;

When I try to edit in the desktop layout, it works perfectly, in the mobile layout it's not, although we are using the same EditableDayMenu component in both:

  const onSubmit = (data) => {
    handleMenu(weekOfYear, dayOfWeek, data)
};

    console.log(watch())

When we try to submit the form, the data only shows the old (defaultValues), but the console.log(watch()) prints out the latest updated fields, so I don't understand why it is not the same in the onsubmit (and what is the difference between my desktop and mobile approach?)

Desktop layout:

import React from 'react'
import EditableDayMenu from './EditableDayMenu';

const DesktopWeeklyMenu = ({
    isEditView,
    weeks,
    menus,
    currentWeek,
    elRefs,
    menuThisWeek,
}) => {
  return (

        {weeks.map((item) => {
          return (

              {item}

          );
        })}

        {menuThisWeek?.map((day, dayOfWeek) => {
          return (

                {!isEditView &&
                  day.day?.map((menu, idx) => {
                    return (

                          {menu.menuCategory}

                          {menu.menuDescription}

                    );
                  })}

              {isEditView && (
                <EditableDayMenu
                  ref={elRefs.current[dayOfWeek]}
                  weekOfYear={currentWeek}
                  dayOfWeek={dayOfWeek}
                  menu={day.day}
                />

              )}

          );
        })}

    )
}

export default DesktopWeeklyMenu

Mobile layout:

import React from "react";
import EditableDayMenu from "./EditableDayMenu";
import UnlockMenuWeek from "./UnlockMenuWeek";

const MobileWeeklyMenu = ({
  isEditView,
  weeks,
  menus,
  currentWeek,
  elRefs,
  menuThisWeek,
}) => {

  return (

      {weeks.map((week, dayOfWeek) => {
        return (

              {week}

            <td valign="top" className={`border border-gray-400 p-3 ${menuThisWeek==null ? 'bg-slate-200' :''}`}>
              {menus?.[dayOfWeek]?.day?.map((day, index) => {
                return !isEditView ? (

{day.menuCategory}

                      {day.menuDescription}

                ) : (
                  <EditableDayMenu
                    key={day.menuCategory + index+"edit"}
                    ref={elRefs.current[dayOfWeek]}
                    weekOfYear={currentWeek}
                    dayOfWeek={dayOfWeek}
                    menu={menus?.[dayOfWeek]?.day}
                  />
                );
              })}

        );
      })}

  );
};

export default MobileWeeklyMenu;

Here is an example of the log in the mobile layout:

Watch:

{menu: Array(3)}menu: Array(3)0: {menuCategory: 'EDIT CATEGORY NAME', menuDescription: 'Leves minden leírva blabla, második'}1: ...

OnSubmit:

 {menu: Array(3)}menu: Array(3)0: {menuCategory: 'a1', menuDescription: 'Leves minden leírva blabla, második'}1: ...

After save:

You can see, that the edited value will not be stored, it's very strange, because the same works in the desktop version, hope you guys can help me figure it out.


问:
Vaadin too many logs :INFO [v-server-output] DevServerOutputTracker : [TypeScript] Found 0 errors. Watching for file changes
I downloaded a Vaadin starter project from Vaadin Starter and running in my eclipse. It is giving me continuous logs. Can someone tell me the reason of these logs and how can I suppress these logs?</p>
```<code>2023-01-08 13:43:00.370  INFO 16860 --- [v-server-output] c.v.b.devserver.DevServerOutputTracker   :
2023-01-08 13:43:00.370  INFO 16860 --- [v-server-output] c.v.b.devserver.DevServerOutputTracker   : [TypeScript] Found 0 errors. Watching for file changes.
2023-01-08 13:43:00.945  INFO 16860 --- [v-server-output] c.v.b.devserver.DevServerOutputTracker   :
2023-01-08 13:43:00.945  INFO 16860 --- [v-server-output] c.v.b.devserver.DevServerOutputTracker   : [TypeScript] Found 0 errors. Watching for file changes.
</code>```

Body:
I downloaded a Vaadin starter project from Vaadin Starter and running in my eclipse. It is giving me continuous logs. Can someone tell me the reason of these logs and how can I suppress these logs?

2023-01-08 13:43:00.370  INFO 16860 --- [v-server-output] c.v.b.devserver.DevServerOutputTracker   :
2023-01-08 13:43:00.370  INFO 16860 --- [v-server-output] c.v.b.devserver.DevServerOutputTracker   : [TypeScript] Found 0 errors. Watching for file changes.
2023-01-08 13:43:00.945  INFO 16860 --- [v-server-output] c.v.b.devserver.DevServerOutputTracker   :
2023-01-08 13:43:00.945  INFO 16860 --- [v-server-output] c.v.b.devserver.DevServerOutputTracker   : [TypeScript] Found 0 errors. Watching for file changes.


问:
Encog Image Recognition, Invalid command Error
I am trying to run image recognition code in Encog framework.

This one

But I am having problems with the input. I am getting the following error

I am trying to get the picture into the program. I did it the following way.

```<code>public static void main(final String[] args) {

    /*
    if (args.length < 1) {
        System.out
                .println("Must specify command file.  See source for format.");
    } else {

     */

    String string = "/Users/hehe/Downloads/Screenshot_2023-01-08_at_08.11.24-removebg-preview.png";
    try {
        final ImageNeuralNetwork program = new ImageNeuralNetwork();
        program.execute(string);
    } catch (final Exception e) {
        e.printStackTrace();
    }

    Encog.getInstance().shutdown();
}
</code>```

I commented first part of the code because I can't run this program in command line.

When I try to compile it like this

javac /Users/hehe/IdeaProjects/TestRencognition/src/main/java/ImageNeuralNetwork.java

I am getting error that the package org.encog does not exist

Body:
I am trying to run image recognition code in Encog framework.

This one

But I am having problems with the input. I am getting the following error

I am trying to get the picture into the program. I did it the following way.

public static void main(final String[] args) {

    /*
    if (args.length < 1) {
        System.out
                .println("Must specify command file.  See source for format.");
    } else {

     */

    String string = "/Users/hehe/Downloads/Screenshot_2023-01-08_at_08.11.24-removebg-preview.png";
    try {
        final ImageNeuralNetwork program = new ImageNeuralNetwork();
        program.execute(string);
    } catch (final Exception e) {
        e.printStackTrace();
    }

    Encog.getInstance().shutdown();
}

I commented first part of the code because I can't run this program in command line.

When I try to compile it like this

javac /Users/hehe/IdeaProjects/TestRencognition/src/main/java/ImageNeuralNetwork.java

I am getting error that the package org.encog does not exist


问:
How do i check if the data I had sent is a list or a string through sockets?
I'm pretty new to python and I'm trying to build a multiplayer tic tac toe game where 2 players can play at once. I have used sockets, select and threads to accomplish this.

However, I am at a dead end at a particular problem.

SERVER

```<code>    def incoming_message(self, client_socket: socket.socket, client_address):
        while True:
            try:
                client_msg = client_socket.recv(2048)
                move = client_msg.decode('utf-8')
                print(f"Player {self.players[f'{client_address}'].symbol} chose: {move}")
                self.send_board()
                self.send_updates(client_address)

            except Exception:
                import traceback
                print(traceback.format_exc())
                socket.close()
</code>```

The above function is in its own thread. If it receives a 'message' or rather, a move from the player, it will try to send the players an updated board as well as what position the player had chosen.

```<code>    def send_updates(self, client_address):
        self.connected_clients[f"{client_address}"].send(
            bytes(f"You {self.players[f'{client_address}'].symbol} sent ", encoding='utf-8'))

    def send_board(self):
        for all_connected_clients in self.connected_clients:
            self.connected_clients[all_connected_clients].send(pickle.dumps(self.board))
</code>```

send_board function sends the player the updated board using pickle as the board itself is a 2d array which I would format it on the client side.

send_updates is just a regular str that is being sent over as well.

CLIENT

```<code>    def incoming_message(self, client_socket):
        while True:
            ready_sockets, _, _ = select.select(
                [client_socket], [], [], 60
            )
            if ready_sockets:
                try:
                    for sockets in ready_sockets:
                        received_board = sockets.recv(1024)
                        self.board = pickle.loads(received_board)
                        self.print_board()

                except Exception as e:
                    print(sockets.recv(1024).decode())
                    print(e)

</code>```

on the client side, function incoming_message is in its own thread as well. I used select to check if the sockets that I had received from the server is readable.

If it is readable, i would try to unpack the bytes that are sent over.

I tried to use try and except error handling to look for any unpickling error. From what i had understood, if pickle.loads() is unable to load the received bytes, the except block would handle it by printing the sockets bytes as it as.

Any help or advices would be appreciated! Thanks

EDIT:

This is the error:

```<code>UnicodeDecodeError: 'utf-8' codec can't decode byte 0x80 in position 0: invalid start byte
</code>```

Body:
I'm pretty new to python and I'm trying to build a multiplayer tic tac toe game where 2 players can play at once. I have used sockets, select and threads to accomplish this.

However, I am at a dead end at a particular problem.

SERVER

    def incoming_message(self, client_socket: socket.socket, client_address):
        while True:
            try:
                client_msg = client_socket.recv(2048)
                move = client_msg.decode('utf-8')
                print(f"Player {self.players[f'{client_address}'].symbol} chose: {move}")
                self.send_board()
                self.send_updates(client_address)

            except Exception:
                import traceback
                print(traceback.format_exc())
                socket.close()

The above function is in its own thread. If it receives a 'message' or rather, a move from the player, it will try to send the players an updated board as well as what position the player had chosen.

    def send_updates(self, client_address):
        self.connected_clients[f"{client_address}"].send(
            bytes(f"You {self.players[f'{client_address}'].symbol} sent ", encoding='utf-8'))

    def send_board(self):
        for all_connected_clients in self.connected_clients:
            self.connected_clients[all_connected_clients].send(pickle.dumps(self.board))

send_board function sends the player the updated board using pickle as the board itself is a 2d array which I would format it on the client side.

send_updates is just a regular str that is being sent over as well.

CLIENT

    def incoming_message(self, client_socket):
        while True:
            ready_sockets, _, _ = select.select(
                [client_socket], [], [], 60
            )
            if ready_sockets:
                try:
                    for sockets in ready_sockets:
                        received_board = sockets.recv(1024)
                        self.board = pickle.loads(received_board)
                        self.print_board()

                except Exception as e:
                    print(sockets.recv(1024).decode())
                    print(e)

on the client side, function incoming_message is in its own thread as well. I used select to check if the sockets that I had received from the server is readable.

If it is readable, i would try to unpack the bytes that are sent over.

I tried to use try and except error handling to look for any unpickling error. From what i had understood, if pickle.loads() is unable to load the received bytes, the except block would handle it by printing the sockets bytes as it as.

Any help or advices would be appreciated! Thanks

EDIT:

This is the error:

UnicodeDecodeError: 'utf-8' codec can't decode byte 0x80 in position 0: invalid start byte


问:
Replacing innerText with an innerHTML - [object HTMLSpanElement] error
Solved:

I receive Chinese content from an API and use a special font for this language. But some names in this content have a-zA-Z0-9 letters and for them I want to use "Montserrat" font. Now I write a span around these words / numbers:

```<code>打扰一下。打扰一下。[object HTMLSpanElement] [object HTMLSpanElement] 打扰一下。打扰一下。
</code>```

This is what I want:

```<code><div class="vce-post-description--excerpt">
<p>打扰一下。打扰一下。<span style="font-family: Montserrat;">51612</span> <span style="font-family: Montserrat;">Hello</span> 打扰一下。打扰一下。</p>
</div>
</code>```

Here the solution - JS part:

```<code><script>
document.addEventListener("DOMContentLoaded", () => {

    const regex = /[0-9A-Za-z]+/g;

    var textElements = document.querySelectorAll(".vce-post-description--title a, .vce-post-description--excerpt");

    for (var i = 0; i < textElements.length; i++) {

        if (textElements[i].textContent.match(regex)) {

            var foundString = textElements[i].textContent.match(regex).toString();
      //console.log("Changing Words: "+foundString);
      let foundArray = foundString.split(",");
      foundArray.forEach(changeInnerText);

        }
    }

  function changeInnerText(item) {
        addElement = document.createElement('span');
        addElement.style.fontFamily = "Montserrat";
        addElement.style.visibility = "visible";
        addElement.textContent  = item;
        //console.log('New Style: '+addElement.outerHTML);
        var regex = new RegExp(item, "g");
                tempHTML = textElements[i].innerHTML.replace(regex, addElement.outerHTML);
        textElements[i].innerHTML = tempHTML;
  }

})

</script>
</code>```

And here is the JSFiddle.

Body:
Solved:

I receive Chinese content from an API and use a special font for this language. But some names in this content have a-zA-Z0-9 letters and for them I want to use "Montserrat" font. Now I write a span around these words / numbers:

打扰一下。打扰一下。[object HTMLSpanElement] [object HTMLSpanElement] 打扰一下。打扰一下。

This is what I want:

打扰一下。打扰一下。51612 Hello 打扰一下。打扰一下。

Here the solution - JS part:

And here is the JSFiddle.


问:
Count Case When SQL Statements in DynamoDB
I have recently moved a flask app to serverless and its all running fine apart from some of the more complicated sql statements.

I want to count when the Player name appears but only if the Team A result is less than the Team B result.

Take the example below. The statement called sql works but the statement called sql2 fails with error:

botocore.exceptions.ClientError: An error occurred (ValidationException) when calling the ExecuteStatement operation: Unexpected path component at 1:8:5

```<code>client = boto3.client('dynamodb')

player = 'Player2'

sql = f"SELECT * FROM player_table WHERE Name = '{player}'"
sql2 = f"SELECT COUNT(CASE WHEN 'Team A Player 1' = '{player}' AND 'Team A Result?' < 'Team B Result?' THEN 1 END) FROM results_table"

response = client.execute_statement(Statement= sql)
response2 = client.execute_statement(Statement= sql2)

print(sql)
print(response['Items'])

print(sql2)
print(response2['Items'])

</code>```

Here is the downloaded csv version of the dynamodb table:

```<code>
"Date","Team A Colour","Team A Player 1","Team A Player 2","Team A Player 3","Team A Player 4","Team A Player 5","Team A Result?","Team A Total","Team B Colour","Team B Player 1","Team B Player 2","Team B Player 3","Team B Player 4","Team B Player 5","Team B Result?","Team B Total"
"2023-01-11","blue","Player17","Player1","Player10","Player14","Player13","'-","385","green","Player11","Player12","Player15","Player18","Player16","'-","385"
"2023-01-01","black","Player1","Player2","Player3","Player4","Player5","1","400","white","Player6","Player7","Player8","Player9","Player10","1","400"

</code>```

--EDIT--

Based on the answer below saying this is not possible using SQL, ive written it in python to get the same result but want to run it multiple times.  Can someone help me tidy the python code to reduce the repetition as im not great at python coding?

```<code>import boto3
client = boto3.client('dynamodb')

player = 'Player2'
sql1 = f"""SELECT "Team A Result?" FROM "results_table" WHERE "Team A Player 1" = '{player}' AND "Team A Result?" > "Team B Result?";"""
sql2 = f"""SELECT "Team A Result?" FROM "results_table" WHERE "Team A Player 2" = '{player}' AND "Team A Result?" > "Team B Result?";"""
sql3 = f"""SELECT "Team A Result?" FROM "results_table" WHERE "Team A Player 3" = '{player}' AND "Team A Result?" > "Team B Result?";"""
sql4 = f"""SELECT "Team A Result?" FROM "results_table" WHERE "Team A Player 4" = '{player}' AND "Team A Result?" > "Team B Result?";"""
sql5 = f"""SELECT "Team A Result?" FROM "results_table" WHERE "Team A Player 5" = '{player}' AND "Team A Result?" > "Team B Result?";"""
sql6 = f"""SELECT "Team A Result?" FROM "results_table" WHERE "Team B Player 1" = '{player}' AND "Team A Result?" > "Team B Result?";"""
sql7 = f"""SELECT "Team A Result?" FROM "results_table" WHERE "Team B Player 2" = '{player}' AND "Team A Result?" > "Team B Result?";"""
sql8 = f"""SELECT "Team A Result?" FROM "results_table" WHERE "Team B Player 3" = '{player}' AND "Team A Result?" > "Team B Result?";"""
sql9 = f"""SELECT "Team A Result?" FROM "results_table" WHERE "Team B Player 4" = '{player}' AND "Team A Result?" > "Team B Result?";"""
sql10 = f"""SELECT "Team A Result?" FROM "results_table" WHERE "Team B Player 5" = '{player}' AND "Team A Result?" > "Team B Result?";"""

response1 = client.execute_statement(Statement= sql1)
response2 = client.execute_statement(Statement= sql2)
response3 = client.execute_statement(Statement= sql3)
response4 = client.execute_statement(Statement= sql4)
response5 = client.execute_statement(Statement= sql5)
response6 = client.execute_statement(Statement= sql6)
response7 = client.execute_statement(Statement= sql7)
response8 = client.execute_statement(Statement= sql8)
response9 = client.execute_statement(Statement= sql9)
response10 = client.execute_statement(Statement= sql10)

string1 = response1['Items']
string2 = response2['Items']
string3 = response3['Items']
string4 = response4['Items']
string5 = response5['Items']
string6 = response6['Items']
string7 = response7['Items']
string8 = response8['Items']
string9 = response9['Items']
string10 = response10['Items']

n = 0
for i in [string1,
        string2,
        string3,
        string4,
        string5,
        string6,
        string7,
        string8,
        string9,
        string10]:
    if len(i) != 0:
        n+=1
print(n)
</code>```

Body:
I have recently moved a flask app to serverless and its all running fine apart from some of the more complicated sql statements.

I want to count when the Player name appears but only if the Team A result is less than the Team B result.

Take the example below. The statement called sql works but the statement called sql2 fails with error:

botocore.exceptions.ClientError: An error occurred (ValidationException) when calling the ExecuteStatement operation: Unexpected path component at 1:8:5

client = boto3.client('dynamodb')

player = 'Player2'

sql = f"SELECT * FROM player_table WHERE Name = '{player}'"
sql2 = f"SELECT COUNT(CASE WHEN 'Team A Player 1' = '{player}' AND 'Team A Result?' < 'Team B Result?' THEN 1 END) FROM results_table"

response = client.execute_statement(Statement= sql)
response2 = client.execute_statement(Statement= sql2)

print(sql)
print(response['Items'])

print(sql2)
print(response2['Items'])

Here is the downloaded csv version of the dynamodb table:

"Date","Team A Colour","Team A Player 1","Team A Player 2","Team A Player 3","Team A Player 4","Team A Player 5","Team A Result?","Team A Total","Team B Colour","Team B Player 1","Team B Player 2","Team B Player 3","Team B Player 4","Team B Player 5","Team B Result?","Team B Total"
"2023-01-11","blue","Player17","Player1","Player10","Player14","Player13","'-","385","green","Player11","Player12","Player15","Player18","Player16","'-","385"
"2023-01-01","black","Player1","Player2","Player3","Player4","Player5","1","400","white","Player6","Player7","Player8","Player9","Player10","1","400"

--EDIT--

Based on the answer below saying this is not possible using SQL, ive written it in python to get the same result but want to run it multiple times.  Can someone help me tidy the python code to reduce the repetition as im not great at python coding?

import boto3
client = boto3.client('dynamodb')

player = 'Player2'
sql1 = f"""SELECT "Team A Result?" FROM "results_table" WHERE "Team A Player 1" = '{player}' AND "Team A Result?" > "Team B Result?";"""
sql2 = f"""SELECT "Team A Result?" FROM "results_table" WHERE "Team A Player 2" = '{player}' AND "Team A Result?" > "Team B Result?";"""
sql3 = f"""SELECT "Team A Result?" FROM "results_table" WHERE "Team A Player 3" = '{player}' AND "Team A Result?" > "Team B Result?";"""
sql4 = f"""SELECT "Team A Result?" FROM "results_table" WHERE "Team A Player 4" = '{player}' AND "Team A Result?" > "Team B Result?";"""
sql5 = f"""SELECT "Team A Result?" FROM "results_table" WHERE "Team A Player 5" = '{player}' AND "Team A Result?" > "Team B Result?";"""
sql6 = f"""SELECT "Team A Result?" FROM "results_table" WHERE "Team B Player 1" = '{player}' AND "Team A Result?" > "Team B Result?";"""
sql7 = f"""SELECT "Team A Result?" FROM "results_table" WHERE "Team B Player 2" = '{player}' AND "Team A Result?" > "Team B Result?";"""
sql8 = f"""SELECT "Team A Result?" FROM "results_table" WHERE "Team B Player 3" = '{player}' AND "Team A Result?" > "Team B Result?";"""
sql9 = f"""SELECT "Team A Result?" FROM "results_table" WHERE "Team B Player 4" = '{player}' AND "Team A Result?" > "Team B Result?";"""
sql10 = f"""SELECT "Team A Result?" FROM "results_table" WHERE "Team B Player 5" = '{player}' AND "Team A Result?" > "Team B Result?";"""

response1 = client.execute_statement(Statement= sql1)
response2 = client.execute_statement(Statement= sql2)
response3 = client.execute_statement(Statement= sql3)
response4 = client.execute_statement(Statement= sql4)
response5 = client.execute_statement(Statement= sql5)
response6 = client.execute_statement(Statement= sql6)
response7 = client.execute_statement(Statement= sql7)
response8 = client.execute_statement(Statement= sql8)
response9 = client.execute_statement(Statement= sql9)
response10 = client.execute_statement(Statement= sql10)

string1 = response1['Items']
string2 = response2['Items']
string3 = response3['Items']
string4 = response4['Items']
string5 = response5['Items']
string6 = response6['Items']
string7 = response7['Items']
string8 = response8['Items']
string9 = response9['Items']
string10 = response10['Items']

n = 0
for i in [string1,
        string2,
        string3,
        string4,
        string5,
        string6,
        string7,
        string8,
        string9,
        string10]:
    if len(i) != 0:
        n+=1
print(n)