public inbox for [email protected]
help / color / mirror / Atom feedCompilation error after redesign of the archive modules
4+ messages / 3 participants
[nested] [flat]
* Compilation error after redesign of the archive modules
@ 2023-03-10 08:11 Sravan Kumar <[email protected]>
0 siblings, 1 reply; 4+ messages in thread
From: Sravan Kumar @ 2023-03-10 08:11 UTC (permalink / raw)
To: [email protected]; [email protected]
Hi,
With the redesign of the archive modules:
35739b87dcfef9fc0186aca659f262746fecd778 - Redesign archive modules
if we were to compile basic_archive module with USE_PGXS=1, we get
compilation error:
[]$ make USE_PGXS=1
gcc -std=gnu99 -Wall -Wmissing-prototypes -Wpointer-arith
-Wdeclaration-after-statement -Werror=vla -Wendif-labels
-Wmissing-format-attribute -Wformat-security -fno-strict-aliasing
-fwrapv -fexcess-precision=standard -g -g -O0 -fPIC
-fvisibility=hidden -I. -I./
-I/home/sravanv/work/workspaces/PGdevel_test/include/postgresql/server
-I/home/sravanv/work/workspaces/PGdevel_test/include/postgresql/internal
-D_GNU_SOURCE -I/usr/include/libxml2 -c -o basic_archive.o
basic_archive.c -MMD -MP -MF .deps/basic_archive.Po
basic_archive.c:33:36: fatal error: archive/archive_module.h: No such
file or directory
#include "archive/archive_module.h"
^
compilation terminated.
make: *** [basic_archive.o] Error 1
I have attached a patch that fixes the problem. Can you please review
if it makes sense to push this patch?
--
Thanks & Regards,
Sravan Velagandula
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
Attachments:
[application/octet-stream] v1-0001-fix-archive-module-compilation-error.patch (850B, ../../CA+=NbjguiQy-MbVqfQ-jQ=2Fcmx3Zs36OkKb-vjt28jMTG0OOg@mail.gmail.com/2-v1-0001-fix-archive-module-compilation-error.patch)
download | inline diff:
From 49bfe6750d6b1709226708808830251dddf93414 Mon Sep 17 00:00:00 2001
From: Sravan Velagandula <[email protected]>
Date: Thu, 9 Mar 2023 08:18:43 -0500
Subject: [PATCH v1] fix archive module compilation error
---
src/include/Makefile | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/include/Makefile b/src/include/Makefile
index 7472cd5e01..56576dcf5c 100644
--- a/src/include/Makefile
+++ b/src/include/Makefile
@@ -17,7 +17,7 @@ all: pg_config.h pg_config_ext.h pg_config_os.h
# Subdirectories containing installable headers
-SUBDIRS = access bootstrap catalog commands common datatype \
+SUBDIRS = access archive bootstrap catalog commands common datatype \
executor fe_utils foreign jit \
lib libpq mb nodes optimizer parser partitioning postmaster \
regex replication rewrite \
--
2.38.1
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: Compilation error after redesign of the archive modules
@ 2023-03-10 08:16 Michael Paquier <[email protected]>
parent: Sravan Kumar <[email protected]>
0 siblings, 1 reply; 4+ messages in thread
From: Michael Paquier @ 2023-03-10 08:16 UTC (permalink / raw)
To: Sravan Kumar <[email protected]>; +Cc: [email protected]
On Fri, Mar 10, 2023 at 01:41:07PM +0530, Sravan Kumar wrote:
> I have attached a patch that fixes the problem. Can you please review
> if it makes sense to push this patch?
Indeed, reproduced here. I'll fix that in a bit..
--
Michael
Attachments:
[application/pgp-signature] signature.asc (833B, ../../[email protected]/2-signature.asc)
download
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: Compilation error after redesign of the archive modules
@ 2023-03-13 05:03 Michael Paquier <[email protected]>
parent: Michael Paquier <[email protected]>
0 siblings, 0 replies; 4+ messages in thread
From: Michael Paquier @ 2023-03-13 05:03 UTC (permalink / raw)
To: Sravan Kumar <[email protected]>; +Cc: [email protected]
On Fri, Mar 10, 2023 at 05:16:53PM +0900, Michael Paquier wrote:
> On Fri, Mar 10, 2023 at 01:41:07PM +0530, Sravan Kumar wrote:
>> I have attached a patch that fixes the problem. Can you please review
>> if it makes sense to push this patch?
>
> Indeed, reproduced here. I'll fix that in a bit..
(Sorry for the late reply, I thought that I sent that on Friday but it
was stuck in my drafts.)
Note that your patch took only care of the ./configure part of the
installation process, but it was missing meson. Applied a fix for
both as of 6ad5793.
--
Michael
Attachments:
[application/pgp-signature] signature.asc (833B, ../../[email protected]/2-signature.asc)
download
^ permalink raw reply [nested|flat] 4+ messages in thread
* [PATCH] change get_tables_to_repack_partitioned
@ 2026-07-09 14:55 Álvaro Herrera <[email protected]>
0 siblings, 0 replies; 4+ messages in thread
From: Álvaro Herrera @ 2026-07-09 14:55 UTC (permalink / raw)
---
src/backend/commands/repack.c | 127 +++++++++++++++++-----------------
1 file changed, 65 insertions(+), 62 deletions(-)
diff --git a/src/backend/commands/repack.c b/src/backend/commands/repack.c
index 02883fe34a4..b3589ceff51 100644
--- a/src/backend/commands/repack.c
+++ b/src/backend/commands/repack.c
@@ -169,8 +169,8 @@ static void copy_table_data(Relation NewHeap, Relation OldHeap, Relation OldInde
MultiXactId *pCutoffMulti);
static List *get_tables_to_repack(RepackCommand cmd, bool usingindex,
MemoryContext permcxt);
-static List *get_tables_to_repack_partitioned(RepackCommand cmd,
- Oid relid, bool rel_is_index,
+static List *get_tables_to_repack_partitioned(RepackStmt *stmt,
+ Relation rel,
MemoryContext permcxt);
static bool repack_is_permitted_for_relation(RepackCommand cmd,
Oid relid, Oid userid);
@@ -387,58 +387,8 @@ ExecRepack(ParseState *pstate, RepackStmt *stmt, bool isTopLevel)
}
else
{
- Oid relid;
- bool rel_is_index;
-
- Assert(rel->rd_rel->relkind == RELKIND_PARTITIONED_TABLE);
-
- /*
- * If USING INDEX was specified, resolve the index name now and pass
- * it down.
- */
- if (stmt->usingindex)
- {
- /*
- * If no index name was specified when repacking a partitioned
- * table, punt for now. Maybe we can improve this later.
- */
- if (!stmt->indexname)
- {
- if (stmt->command == REPACK_COMMAND_CLUSTER)
- ereport(ERROR,
- errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
- errmsg("there is no previously clustered index for table \"%s\"",
- RelationGetRelationName(rel)));
- else
- ereport(ERROR,
- errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
- /*- translator: first %s is name of a SQL command, eg. REPACK */
- errmsg("cannot execute %s on partitioned table \"%s\" USING INDEX with no index name",
- RepackCommandAsString(stmt->command),
- RelationGetRelationName(rel)));
- }
-
- relid = determine_clustered_index(rel, stmt->usingindex,
- stmt->indexname);
- if (!OidIsValid(relid))
- elog(ERROR, "unable to determine index to cluster on");
- check_index_is_clusterable(rel, relid, AccessExclusiveLock);
-
- rel_is_index = true;
- }
- else
- {
- relid = RelationGetRelid(rel);
- rel_is_index = false;
- }
-
- rtcs = get_tables_to_repack_partitioned(stmt->command,
- relid, rel_is_index,
- repack_context);
-
- /* close parent relation, releasing lock on it */
- table_close(rel, AccessExclusiveLock);
- rel = NULL;
+ rtcs = get_tables_to_repack_partitioned(stmt, rel, repack_context);
+ rel = NULL; /* clobber no longer valid pointer */
}
/* Commit to get out of starting transaction */
@@ -2255,19 +2205,66 @@ get_tables_to_repack(RepackCommand cmd, bool usingindex, MemoryContext permcxt)
}
/*
- * Given a partitioned table or its index, return a list of RelToCluster for
- * all the leaf child tables/indexes.
+ * Resolve a partitioned table named as target of REPACK to the list of
+ * its partitions, and return it as a list of RelToCluster.
*
- * 'rel_is_index' tells whether 'relid' is that of an index (true) or of the
- * owning relation.
+ * The partitioned table in question was already opened and locked by caller
+ * and is given as argument; it is closed and unlocked here before return.
*/
static List *
-get_tables_to_repack_partitioned(RepackCommand cmd, Oid relid,
- bool rel_is_index, MemoryContext permcxt)
+get_tables_to_repack_partitioned(RepackStmt *stmt, Relation rel,
+ MemoryContext permcxt)
{
+ Oid relid;
+ bool rel_is_index;
List *inhoids;
List *rtcs = NIL;
+ Assert(rel->rd_rel->relkind == RELKIND_PARTITIONED_TABLE);
+ Assert(CheckRelationLockedByMe(rel, AccessExclusiveLock, false));
+
+ /*
+ * We find the list of tables by looking for inheritors. If USING INDEX
+ * was given, look for inheritors of that index, whose name we resolve now.
+ *
+ * Otherwise we look for inheritors of the table itself.
+ */
+ if (stmt->usingindex)
+ {
+ /*
+ * If no index name was specified when repacking a partitioned
+ * table, punt for now. Maybe we can improve this later.
+ */
+ if (!stmt->indexname)
+ {
+ if (stmt->command == REPACK_COMMAND_CLUSTER)
+ ereport(ERROR,
+ errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
+ errmsg("there is no previously clustered index for table \"%s\"",
+ RelationGetRelationName(rel)));
+ else
+ ereport(ERROR,
+ errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
+ /*- translator: first %s is name of a SQL command, eg. REPACK */
+ errmsg("cannot execute %s on partitioned table \"%s\" USING INDEX with no index name",
+ RepackCommandAsString(stmt->command),
+ RelationGetRelationName(rel)));
+ }
+
+ relid = determine_clustered_index(rel, stmt->usingindex,
+ stmt->indexname);
+ if (!OidIsValid(relid))
+ elog(ERROR, "unable to determine index to cluster on");
+ check_index_is_clusterable(rel, relid, AccessExclusiveLock);
+
+ rel_is_index = true;
+ }
+ else
+ {
+ relid = RelationGetRelid(rel);
+ rel_is_index = false;
+ }
+
/*
* Do not lock the children until they're processed. Note that we do hold
* a lock on the parent partitioned table.
@@ -2286,7 +2283,9 @@ get_tables_to_repack_partitioned(RepackCommand cmd, Oid relid,
if (get_rel_relkind(child_oid) != RELKIND_INDEX)
continue;
- table_oid = IndexGetRelation(child_oid, false);
+ table_oid = IndexGetRelation(child_oid, true);
+ if (!OidIsValid(table_oid))
+ continue;
index_oid = child_oid;
}
else
@@ -2304,7 +2303,8 @@ get_tables_to_repack_partitioned(RepackCommand cmd, Oid relid,
* leaf partition despite having them on the partitioned table. Skip
* if so.
*/
- if (!repack_is_permitted_for_relation(cmd, table_oid, GetUserId()))
+ if (!repack_is_permitted_for_relation(stmt->command, table_oid,
+ GetUserId()))
continue;
/* Use a permanent memory context for the result list */
@@ -2316,6 +2316,9 @@ get_tables_to_repack_partitioned(RepackCommand cmd, Oid relid,
MemoryContextSwitchTo(oldcxt);
}
+ /* close parent relation, releasing lock on it */
+ table_close(rel, AccessExclusiveLock);
+
return rtcs;
}
--
2.47.3
--f4uihmgjmvhgvze3--
^ permalink raw reply [nested|flat] 4+ messages in thread
end of thread, other threads:[~2026-07-09 14:55 UTC | newest]
Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2023-03-10 08:11 Compilation error after redesign of the archive modules Sravan Kumar <[email protected]>
2023-03-10 08:16 ` Michael Paquier <[email protected]>
2023-03-13 05:03 ` Michael Paquier <[email protected]>
2026-07-09 14:55 [PATCH] change get_tables_to_repack_partitioned Álvaro Herrera <[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