public inbox for [email protected]  
help / color / mirror / Atom feed
[PATCH 4/4] Remove pointless Exporter usage in Catalog.pm
4+ messages / 3 participants
[nested] [flat]

* [PATCH 4/4] Remove pointless Exporter usage in Catalog.pm
@ 2017-04-17 14:57  Dagfinn Ilmari Mannsåker <[email protected]>
  0 siblings, 0 replies; 4+ messages in thread

From: Dagfinn Ilmari Mannsåker @ 2017-04-17 14:57 UTC (permalink / raw)

None of the users actually import any of the subroutines, they just call
them by their fully-qualified names.
---
 src/backend/catalog/Catalog.pm | 5 -----
 1 file changed, 5 deletions(-)

diff --git a/src/backend/catalog/Catalog.pm b/src/backend/catalog/Catalog.pm
index 9c06ec1..662df3b 100644
--- a/src/backend/catalog/Catalog.pm
+++ b/src/backend/catalog/Catalog.pm
@@ -16,11 +16,6 @@ package Catalog;
 use strict;
 use warnings;
 
-require Exporter;
-our @ISA       = qw(Exporter);
-our @EXPORT    = ();
-our @EXPORT_OK = qw(Catalogs SplitDataLine RenameTempFile);
-
 # Call this function with an array of names of header files to parse.
 # Returns a nested data structure describing the data in the headers.
 sub Catalogs
-- 
2.7.4


--=-=-=
Content-Type: text/plain
Content-Disposition: inline
Content-Transfer-Encoding: 8bit
MIME-Version: 1.0


-- 
Sent via pgsql-hackers mailing list ([email protected])
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

--=-=-=--




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

* [PATCH 6/8] Remove pointless Exporter usage in Catalog.pm
@ 2017-04-17 14:57  Dagfinn Ilmari Mannsåker <[email protected]>
  0 siblings, 0 replies; 4+ messages in thread

From: Dagfinn Ilmari Mannsåker @ 2017-04-17 14:57 UTC (permalink / raw)

None of the users actually import any of the subroutines, they just call
them by their fully-qualified names.
---
 src/backend/catalog/Catalog.pm | 5 -----
 1 file changed, 5 deletions(-)

diff --git a/src/backend/catalog/Catalog.pm b/src/backend/catalog/Catalog.pm
index b326427..d4b4170 100644
--- a/src/backend/catalog/Catalog.pm
+++ b/src/backend/catalog/Catalog.pm
@@ -16,11 +16,6 @@ package Catalog;
 use strict;
 use warnings;
 
-require Exporter;
-our @ISA       = qw(Exporter);
-our @EXPORT    = ();
-our @EXPORT_OK = qw(Catalogs SplitDataLine RenameTempFile);
-
 # Call this function with an array of names of header files to parse.
 # Returns a nested data structure describing the data in the headers.
 sub Catalogs
-- 
2.7.4


--=-=-=
Content-Type: text/plain
Content-Disposition: inline
Content-Transfer-Encoding: 8bit
MIME-Version: 1.0


-- 
Sent via pgsql-hackers mailing list ([email protected])
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

--=-=-=--




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

* [PATCH 05/18] comment typos
@ 2021-02-10 23:45  Justin Pryzby <[email protected]>
  0 siblings, 0 replies; 4+ messages in thread

From: Justin Pryzby @ 2021-02-10 23:45 UTC (permalink / raw)

---
 src/include/lib/simplehash.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/include/lib/simplehash.h b/src/include/lib/simplehash.h
index 395be1ca9a..99a03c8f21 100644
--- a/src/include/lib/simplehash.h
+++ b/src/include/lib/simplehash.h
@@ -626,7 +626,7 @@ restart:
 		uint32		curoptimal;
 		SH_ELEMENT_TYPE *entry = &data[curelem];
 
-		/* any empty bucket can directly be used */
+		/* any empty bucket can be used directly */
 		if (entry->status == SH_STATUS_EMPTY)
 		{
 			tb->members++;
-- 
2.17.0


--lc9FT7cWel8HagAv
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment; filename="0006-One-fewer-not-one-less.patch"



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

* Re: pgbench with partitioned tables
@ 2025-02-03 04:37  Sergey Tatarintsev <[email protected]>
  0 siblings, 0 replies; 4+ messages in thread

From: Sergey Tatarintsev @ 2025-02-03 04:37 UTC (permalink / raw)
  To: Álvaro Herrera <[email protected]>; Melanie Plageman <[email protected]>; +Cc: [email protected] <[email protected]>


02.02.2025 20:45, Álvaro Herrera пишет:
> On 2025-Jan-31, Melanie Plageman wrote:
>
>> Maybe instead of just not using COPY FREEZE on a table if it is
>> partitioned, we could add new data generation init_steps. Perhaps one
>> that is client-side data generation (g) but with no freezing? I'm not
>> really sure what the letter would be (f? making it f, g, and G?).
> I think it makes sense to do what you suggest, but on the other hand,
> the original code that Sergey is patching looks like a hack in the sense
> that it hardcodes which tables to use FREEZE with.  There's no point to
> doing things that way actually, so accepting Sergey's patch to replace
> that with a relkind check feels sensible to me.
>
> I think the query should be
> SELECT relkind FROM pg_catalog.pg_class WHERE oid='%s'::pg_catalog.regclass
> if only for consistency with pgbench's other query on catalogs.
>
>
> Your proposal to add different init_steps might be reasonable, at least
> if we allowed partitionedness of tables to vary in other ways (eg. if we
> made pgbench_history partitioned), but I don't think it conflicts with
> Sergey's patch in spirit.

Thanks for the note. I changed the query in the patch (v2 patch attached)

Btw, an additional benefit from the patch is that we can use foreign tables
(for example, to test postgres_fdw optimizations)


-- 
With best regards,
Sergey Tatarintsev,
PostgresPro


Attachments:

  [text/x-patch] v1-0002-Fix-pgbench-client-side-data-generation-f.patch (2.1K, ../../[email protected]/2-v1-0002-Fix-pgbench-client-side-data-generation-f.patch)
  download | inline diff:
From 9aaf2b222d6eb0c218c8a417280a8fdc0a42c296 Mon Sep 17 00:00:00 2001
From: Sergey Tatarintsev <[email protected]>
Date: Thu, 30 Jan 2025 14:52:29 +0700
Subject: [PATCH-v1] Fix pgbench client-side data generation for partitioned tables

Client-side data generation cannot perform COPY WITH (FREEZE = ON) on partitioned
tables except pgbench_accounts.
Patch disables FREEZE for any non-regular tables

---
 src/bin/pgbench/pgbench.c | 34 +++++++++++++++++++++++++---------
 1 file changed, 25 insertions(+), 9 deletions(-)

diff --git a/src/bin/pgbench/pgbench.c b/src/bin/pgbench/pgbench.c
index b5cf3c6ed01..cac5312c4b1 100644
--- a/src/bin/pgbench/pgbench.c
+++ b/src/bin/pgbench/pgbench.c
@@ -847,6 +847,28 @@ static const PsqlScanCallbacks pgbench_callbacks = {
 	NULL,						/* don't need get_variable functionality */
 };
 
+static bool
+is_regular_table(PGconn *con, const char *table)
+{
+	PGresult   *res;
+	char		*sql = psprintf("SELECT relkind FROM pg_catalog.pg_class WHERE oid='%s'::pg_catalog.regclass", table);
+	bool		is_regular_table = true;
+
+	res = PQexec(con, sql);
+	if (PQresultStatus(res) != PGRES_TUPLES_OK)
+	{
+		pg_log_error("query failed: %s", PQerrorMessage(con));
+		pg_log_error_detail("Query was: %s", sql);
+		exit(1);
+	}
+	if (!PQgetisnull(res, 0, 0))
+		is_regular_table = strncmp(PQgetvalue(res, 0, 0), "r", 1) == 0;
+
+	PQclear(res);
+	pfree(sql);
+	return is_regular_table;
+}
+
 static inline pg_time_usec_t
 pg_time_now(void)
 {
@@ -4958,16 +4980,10 @@ initPopulateTable(PGconn *con, const char *table, int64 base,
 
 	initPQExpBuffer(&sql);
 
-	/*
-	 * Use COPY with FREEZE on v14 and later for all the tables except
-	 * pgbench_accounts when it is partitioned.
-	 */
-	if (PQserverVersion(con) >= 140000)
-	{
-		if (strcmp(table, "pgbench_accounts") != 0 ||
-			partitions == 0)
+	/* Use COPY with FREEZE on v14 and later for all regular tables */
+	if ((PQserverVersion(con) >= 140000) && is_regular_table(con, table))
 			copy_statement_fmt = "copy %s from stdin with (freeze on)";
-	}
+
 
 	n = pg_snprintf(copy_statement, sizeof(copy_statement), copy_statement_fmt, table);
 	if (n >= sizeof(copy_statement))
-- 
2.43.0



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


end of thread, other threads:[~2025-02-03 04:37 UTC | newest]

Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2017-04-17 14:57 [PATCH 4/4] Remove pointless Exporter usage in Catalog.pm Dagfinn Ilmari Mannsåker <[email protected]>
2017-04-17 14:57 [PATCH 6/8] Remove pointless Exporter usage in Catalog.pm Dagfinn Ilmari Mannsåker <[email protected]>
2021-02-10 23:45 [PATCH 05/18] comment typos Justin Pryzby <[email protected]>
2025-02-03 04:37 Re: pgbench with partitioned tables Sergey Tatarintsev <[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