public inbox for [email protected]  
help / color / mirror / Atom feed
[PATCH 2/7] Allow composite types in bootstrap
6+ messages / 4 participants
[nested] [flat]

* [PATCH 2/7] Allow composite types in bootstrap
@ 2020-11-17 15:28  Justin Pryzby <[email protected]>
  0 siblings, 0 replies; 6+ messages in thread

From: Justin Pryzby @ 2020-11-17 15:28 UTC (permalink / raw)

---
 src/backend/bootstrap/bootstrap.c | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)

diff --git a/src/backend/bootstrap/bootstrap.c b/src/backend/bootstrap/bootstrap.c
index 9a9fa7fd38..f8a883dad7 100644
--- a/src/backend/bootstrap/bootstrap.c
+++ b/src/backend/bootstrap/bootstrap.c
@@ -916,6 +916,7 @@ gettype(char *type)
 {
 	if (Typ != NIL)
 	{
+		static bool did_reread PG_USED_FOR_ASSERTS_ONLY = false; /* Already reread pg_types */
 		ListCell *lc;
 
 		foreach (lc, Typ)
@@ -927,6 +928,33 @@ gettype(char *type)
 				return app->am_oid;
 			}
 		}
+
+		/*
+		 * The type wasn't known; check again to handle composite
+		 * types, added since first populating the array.
+		 */
+
+		/*
+		 * Once all the types are populated and we handled composite
+		 * types, shouldn't need to do that again.
+		 */
+		Assert(!did_reread);
+		did_reread = true;
+
+		list_free_deep(Typ);
+		Typ = NULL;
+		populate_typ_array();
+
+		/* Need to avoid infinite recursion... */
+		foreach (lc, Typ)
+		{
+			struct typmap *app = lfirst(lc);
+			if (strncmp(NameStr(app->am_typ.typname), type, NAMEDATALEN) == 0)
+			{
+				Ap = app;
+				return app->am_oid;
+			}
+		}
 	}
 	else
 	{
-- 
2.17.0


--fUYQa+Pmc3FrFX/N
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
 filename="0003-Extended-statistics-on-expressions.patch"



^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: pgsql: psql: add an optional execution-count limit to \watch.
@ 2023-04-07 14:00  Tom Lane <[email protected]>
  0 siblings, 1 reply; 6+ messages in thread

From: Tom Lane @ 2023-04-07 14:00 UTC (permalink / raw)
  To: Alexander Korotkov <[email protected]>; +Cc: [email protected]; Andrew Dunstan <[email protected]>

Alexander Korotkov <[email protected]> writes:
> On Thu, Apr 6, 2023 at 8:18 PM Tom Lane <[email protected]> wrote:
>> psql: add an optional execution-count limit to \watch.

> This commit makes tests fail for me.  psql parses 'i' option of
> '\watch' using locale-aware strtod(), but 001_basic.pl uses hard-coded
> decimal separator.

Huh, yeah, I see it too if I set LANG=ru_RU.utf8 before running psql's
TAP tests.  It seems unfortunate that none of the buildfarm has noticed
this.  I guess all the TAP tests are run under C locale?

> The proposed fix is attached.

LGTM, will push in a bit (unless you want to?)

			regards, tom lane






^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: pgsql: psql: add an optional execution-count limit to \watch.
@ 2023-04-07 14:06  Alexander Korotkov <[email protected]>
  parent: Tom Lane <[email protected]>
  0 siblings, 1 reply; 6+ messages in thread

From: Alexander Korotkov @ 2023-04-07 14:06 UTC (permalink / raw)
  To: Tom Lane <[email protected]>; +Cc: [email protected]; Andrew Dunstan <[email protected]>

On Fri, Apr 7, 2023 at 5:00 PM Tom Lane <[email protected]> wrote:
> Alexander Korotkov <[email protected]> writes:
> > On Thu, Apr 6, 2023 at 8:18 PM Tom Lane <[email protected]> wrote:
> >> psql: add an optional execution-count limit to \watch.
>
> > This commit makes tests fail for me.  psql parses 'i' option of
> > '\watch' using locale-aware strtod(), but 001_basic.pl uses hard-coded
> > decimal separator.
>
> Huh, yeah, I see it too if I set LANG=ru_RU.utf8 before running psql's
> TAP tests.  It seems unfortunate that none of the buildfarm has noticed
> this.  I guess all the TAP tests are run under C locale?

I wonder if we can setup as least some buildfarm members to exercise
TAP tests on non-C locales.

> > The proposed fix is attached.
>
> LGTM, will push in a bit (unless you want to?)

Please push.

------
Regards,
Alexander Korotkov






^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: pgsql: psql: add an optional execution-count limit to \watch.
@ 2023-04-10 12:48  Aleksander Alekseev <[email protected]>
  parent: Alexander Korotkov <[email protected]>
  0 siblings, 1 reply; 6+ messages in thread

From: Aleksander Alekseev @ 2023-04-10 12:48 UTC (permalink / raw)
  To: [email protected]; +Cc: Alexander Korotkov <[email protected]>; Tom Lane <[email protected]>; Andrew Dunstan <[email protected]>

Hi,

> I wonder if we can setup as least some buildfarm members to exercise
> TAP tests on non-C locales.
>
> > > The proposed fix is attached.
> >
> > LGTM, will push in a bit (unless you want to?)
>
> Please push.

The test still fails under the following conditions:

```
$ env | grep UTF-8
LC_ADDRESS=ru_RU.UTF-8
LC_NAME=ru_RU.UTF-8
LC_MONETARY=ru_RU.UTF-8
LC_PAPER=ru_RU.UTF-8
LANG=en_US.UTF-8
LC_IDENTIFICATION=ru_RU.UTF-8
LC_TELEPHONE=ru_RU.UTF-8
LC_MEASUREMENT=ru_RU.UTF-8
LC_CTYPE=en_US.UTF-8
LC_TIME=ru_RU.UTF-8
LC_ALL=en_US.UTF-8
LC_NUMERIC=ru_RU.UTF-8
```

This is up-to-dated Ubuntu 22.04 with pretty much default settings
except for the timezone changed to MSK and enabled Russian keyboard
layout.

Here is a proposed fix. I realize this is a somewhat suboptimal
solution, but it makes the test pass regardless of the locale
settings.

-- 
Best regards,
Aleksander Alekseev


Attachments:

  [application/octet-stream] fix.diff (427B, ../../CAJ7c6TO9KpYYxoVVseWEQB5KtjWDkt8NfyAeKPcHoe2Jq+ykpw@mail.gmail.com/2-fix.diff)
  download | inline diff:
diff --git a/src/bin/psql/t/001_basic.pl b/src/bin/psql/t/001_basic.pl
index 596746de17..a74d24b63d 100644
--- a/src/bin/psql/t/001_basic.pl
+++ b/src/bin/psql/t/001_basic.pl
@@ -355,7 +355,7 @@ psql_like(
 # Note: the interval value is parsed with locale-aware strtod()
 psql_like(
 	$node,
-	sprintf('SELECT 1 \watch c=3 i=%g', 0.01),
+	sprintf('SELECT 1 \watch c=3 i=%g', 1),
 	qr/1\n1\n1/,
 	'\watch with 3 iterations');
 


^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: pgsql: psql: add an optional execution-count limit to \watch.
@ 2023-04-10 13:54  Tom Lane <[email protected]>
  parent: Aleksander Alekseev <[email protected]>
  0 siblings, 1 reply; 6+ messages in thread

From: Tom Lane @ 2023-04-10 13:54 UTC (permalink / raw)
  To: Aleksander Alekseev <[email protected]>; +Cc: [email protected]; Alexander Korotkov <[email protected]>; Andrew Dunstan <[email protected]>

Aleksander Alekseev <[email protected]> writes:
> The test still fails under the following conditions:

> $ env | grep UTF-8
> LANG=en_US.UTF-8
> LC_ALL=en_US.UTF-8
> LC_NUMERIC=ru_RU.UTF-8

Hmm, so psql is honoring the LC_NUMERIC setting in that environment,
but perl isn't.  For me, it appears that adding 'use locale;' to
the test script will fix it ... can you confirm if it's OK for you?

			regards, tom lane






^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: pgsql: psql: add an optional execution-count limit to \watch.
@ 2023-04-10 14:30  Aleksander Alekseev <[email protected]>
  parent: Tom Lane <[email protected]>
  0 siblings, 0 replies; 6+ messages in thread

From: Aleksander Alekseev @ 2023-04-10 14:30 UTC (permalink / raw)
  To: [email protected]; +Cc: Tom Lane <[email protected]>; Alexander Korotkov <[email protected]>; Andrew Dunstan <[email protected]>

Hi Tom,

> Aleksander Alekseev <[email protected]> writes:
> > The test still fails under the following conditions:
>
> > $ env | grep UTF-8
> > LANG=en_US.UTF-8
> > LC_ALL=en_US.UTF-8
> > LC_NUMERIC=ru_RU.UTF-8
>
> Hmm, so psql is honoring the LC_NUMERIC setting in that environment,
> but perl isn't.  For me, it appears that adding 'use locale;' to
> the test script will fix it ... can you confirm if it's OK for you?

Right, src/bin/psql/t/001_basic.pl has "use locale;" since cd82e5c7
and it fails nevertheless.

If I set LC_NUMERIC manually:

```
LC_NUMERIC=en_US.UTF-8 meson test -C build --suite postgresql:psql
```

... the test passes. I can confirm that Perl doesn't seem to be
honoring LC_NUMERIC:

```
$ LC_ALL=en_US.UTF-8 LC_NUMERIC=en_US.UTF-8 perl -e 'use locale;
printf("%g\n", 0.01)'
0.01
$ LC_ALL=en_US.UTF-8 LC_NUMERIC=ru_RU.UTF-8 perl -e 'use locale;
printf("%g\n", 0.01)'
0.01
$ LC_ALL=ru_RU.UTF-8 LC_NUMERIC=en_US.UTF-8 perl -e 'use locale;
printf("%g\n", 0.01)'
0,01
$ LC_ALL=ru_RU.UTF-8 LC_NUMERIC=ru_RU.UTF-8 perl -e 'use locale;
printf("%g\n", 0.01)'
0,01
```

The Perl version is 5.34.0.

It is consistent with `perdoc perllocale`:

```
    The initial program is started up using the locale specified from the
    environment, as currently, described in "ENVIRONMENT". [...]

ENVIRONMENT
[...]
    "LC_ALL"    "LC_ALL" is the "override-all" locale environment variable.
                If set, it overrides all the rest of the locale environment
                variables.
```

So it looks like what happens is LC_ALL overwrites LC_NUMERIC for perl
but not for psql.

-- 
Best regards,
Aleksander Alekseev






^ permalink  raw  reply  [nested|flat] 6+ messages in thread


end of thread, other threads:[~2023-04-10 14:30 UTC | newest]

Thread overview: 6+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2020-11-17 15:28 [PATCH 2/7] Allow composite types in bootstrap Justin Pryzby <[email protected]>
2023-04-07 14:00 Re: pgsql: psql: add an optional execution-count limit to \watch. Tom Lane <[email protected]>
2023-04-07 14:06 ` Re: pgsql: psql: add an optional execution-count limit to \watch. Alexander Korotkov <[email protected]>
2023-04-10 12:48   ` Re: pgsql: psql: add an optional execution-count limit to \watch. Aleksander Alekseev <[email protected]>
2023-04-10 13:54     ` Re: pgsql: psql: add an optional execution-count limit to \watch. Tom Lane <[email protected]>
2023-04-10 14:30       ` Re: pgsql: psql: add an optional execution-count limit to \watch. Aleksander Alekseev <[email protected]>

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox