public inbox for [email protected]
help / color / mirror / Atom feed[PATCH v2 3/5] pg_rewind: Replace the hybrid list+array data structure with simplehash.
6+ messages / 4 participants
[nested] [flat]
* [PATCH v2 3/5] pg_rewind: Replace the hybrid list+array data structure with simplehash.
@ 2020-08-19 12:34 Heikki Linnakangas <[email protected]>
0 siblings, 0 replies; 6+ messages in thread
From: Heikki Linnakangas @ 2020-08-19 12:34 UTC (permalink / raw)
Now that simplehash can be use in frontend code, let's make use of it.
---
src/bin/pg_rewind/copy_fetch.c | 4 +-
src/bin/pg_rewind/fetch.c | 2 +-
src/bin/pg_rewind/fetch.h | 2 +-
src/bin/pg_rewind/filemap.c | 285 ++++++++++++++------------------
src/bin/pg_rewind/filemap.h | 67 +++-----
src/bin/pg_rewind/libpq_fetch.c | 4 +-
src/bin/pg_rewind/pg_rewind.c | 12 +-
7 files changed, 168 insertions(+), 208 deletions(-)
diff --git a/src/bin/pg_rewind/copy_fetch.c b/src/bin/pg_rewind/copy_fetch.c
index 18fad32600e..61aed8018b6 100644
--- a/src/bin/pg_rewind/copy_fetch.c
+++ b/src/bin/pg_rewind/copy_fetch.c
@@ -207,9 +207,9 @@ copy_executeFileMap(filemap_t *map)
file_entry_t *entry;
int i;
- for (i = 0; i < map->narray; i++)
+ for (i = 0; i < map->nactions; i++)
{
- entry = map->array[i];
+ entry = map->actions[i];
execute_pagemap(&entry->target_modified_pages, entry->path);
switch (entry->action)
diff --git a/src/bin/pg_rewind/fetch.c b/src/bin/pg_rewind/fetch.c
index f18fe5386ed..f41d0f295ea 100644
--- a/src/bin/pg_rewind/fetch.c
+++ b/src/bin/pg_rewind/fetch.c
@@ -37,7 +37,7 @@ fetchSourceFileList(void)
* Fetch all relation data files that are marked in the given data page map.
*/
void
-executeFileMap(void)
+execute_file_actions(filemap_t *filemap)
{
if (datadir_source)
copy_executeFileMap(filemap);
diff --git a/src/bin/pg_rewind/fetch.h b/src/bin/pg_rewind/fetch.h
index 7cf8b6ea090..b20df8b1537 100644
--- a/src/bin/pg_rewind/fetch.h
+++ b/src/bin/pg_rewind/fetch.h
@@ -25,7 +25,7 @@
*/
extern void fetchSourceFileList(void);
extern char *fetchFile(const char *filename, size_t *filesize);
-extern void executeFileMap(void);
+extern void execute_file_actions(filemap_t *filemap);
/* in libpq_fetch.c */
extern void libpqProcessFileList(void);
diff --git a/src/bin/pg_rewind/filemap.c b/src/bin/pg_rewind/filemap.c
index 7971daeda5e..e6e037d1cd4 100644
--- a/src/bin/pg_rewind/filemap.c
+++ b/src/bin/pg_rewind/filemap.c
@@ -3,6 +3,19 @@
* filemap.c
* A data structure for keeping track of files that have changed.
*
+ * This source file contains the logic to decide what to do with different
+ * kinds of files, and the data structure to support it. Before modifying
+ * anything, pg_rewind collects information about all the files and their
+ * attributes in the target and source data directories. It also scans the
+ * WAL log in the target, and collects information about data blocks that
+ * were changed. All this information is stored in a hash table, using the
+ * file path, relative to the root of the data directory, as the key.
+ *
+ * After collecting all the information required, the filemap_finalize()
+ * function scans the hash table and decides what action needs to be taken
+ * for each file. Finally, it sorts the array to the final order that the
+ * actions should be executed in.
+ *
* Copyright (c) 2013-2020, PostgreSQL Global Development Group
*
*-------------------------------------------------------------------------
@@ -14,22 +27,39 @@
#include <unistd.h>
#include "catalog/pg_tablespace_d.h"
+#include "common/hashfn.h"
#include "common/string.h"
#include "datapagemap.h"
#include "filemap.h"
#include "pg_rewind.h"
#include "storage/fd.h"
-filemap_t *filemap = NULL;
+/*
+ * Define a hash table which we can use to store information about the files
+ * mentioned in the backup manifest.
+ */
+static uint32 hash_string_pointer(const char *s);
+#define SH_PREFIX filehash
+#define SH_ELEMENT_TYPE file_entry_t
+#define SH_KEY_TYPE const char *
+#define SH_KEY path
+#define SH_HASH_KEY(tb, key) hash_string_pointer(key)
+#define SH_EQUAL(tb, a, b) (strcmp(a, b) == 0)
+#define SH_SCOPE static inline
+#define SH_RAW_ALLOCATOR pg_malloc0
+#define SH_DECLARE
+#define SH_DEFINE
+#include "lib/simplehash.h"
+
+static filehash_hash *filehash;
static bool isRelDataFile(const char *path);
static char *datasegpath(RelFileNode rnode, ForkNumber forknum,
BlockNumber segno);
-static int path_cmp(const void *a, const void *b);
-static file_entry_t *get_filemap_entry(const char *path, bool create);
+static file_entry_t *insert_filehash_entry(const char *path);
+static file_entry_t *lookup_filehash_entry(const char *path);
static int final_filemap_cmp(const void *a, const void *b);
-static void filemap_list_to_array(filemap_t *map);
static bool check_file_excluded(const char *path, bool is_source);
/*
@@ -131,54 +161,26 @@ static const struct exclude_list_item excludeFiles[] =
};
/*
- * Create a new file map (stored in the global pointer "filemap").
+ * Initialize the hash table for the file map.
*/
void
-filemap_create(void)
+filemap_init(void)
{
- filemap_t *map;
-
- map = pg_malloc(sizeof(filemap_t));
- map->first = map->last = NULL;
- map->nlist = 0;
- map->array = NULL;
- map->narray = 0;
-
- Assert(filemap == NULL);
- filemap = map;
+ filehash = filehash_create(1000, NULL);
}
-/* Look up or create entry for 'path' */
+/* Look up entry for 'path', creating new one if it doesn't exists */
static file_entry_t *
-get_filemap_entry(const char *path, bool create)
+insert_filehash_entry(const char *path)
{
- filemap_t *map = filemap;
file_entry_t *entry;
- file_entry_t **e;
- file_entry_t key;
- file_entry_t *key_ptr;
-
- if (map->array)
- {
- key.path = (char *) path;
- key_ptr = &key;
- e = bsearch(&key_ptr, map->array, map->narray, sizeof(file_entry_t *),
- path_cmp);
- }
- else
- e = NULL;
+ bool found;
- if (e)
- entry = *e;
- else if (!create)
- entry = NULL;
- else
+ entry = filehash_insert(filehash, path, &found);
+ if (!found)
{
- /* Create a new entry for this file */
- entry = pg_malloc(sizeof(file_entry_t));
entry->path = pg_strdup(path);
entry->isrelfile = isRelDataFile(path);
- entry->action = FILE_ACTION_UNDECIDED;
entry->target_exists = false;
entry->target_type = FILE_TYPE_UNDEFINED;
@@ -192,21 +194,18 @@ get_filemap_entry(const char *path, bool create)
entry->source_size = 0;
entry->source_link_target = NULL;
- entry->next = NULL;
-
- if (map->last)
- {
- map->last->next = entry;
- map->last = entry;
- }
- else
- map->first = map->last = entry;
- map->nlist++;
+ entry->action = FILE_ACTION_UNDECIDED;
}
return entry;
}
+static file_entry_t *
+lookup_filehash_entry(const char *path)
+{
+ return filehash_lookup(filehash, path);
+}
+
/*
* Callback for processing source file list.
*
@@ -220,8 +219,6 @@ process_source_file(const char *path, file_type_t type, size_t size,
{
file_entry_t *entry;
- Assert(filemap->array == NULL);
-
/*
* Pretend that pg_wal is a directory, even if it's really a symlink. We
* don't want to mess with the symlink itself, nor complain if it's a
@@ -238,7 +235,9 @@ process_source_file(const char *path, file_type_t type, size_t size,
pg_fatal("data file \"%s\" in source is not a regular file", path);
/* Remember this source file */
- entry = get_filemap_entry(path, true);
+ entry = insert_filehash_entry(path);
+ if (entry->source_exists)
+ pg_fatal("duplicate source file \"%s\"", path);
entry->source_exists = true;
entry->source_type = type;
entry->source_size = size;
@@ -256,7 +255,6 @@ void
process_target_file(const char *path, file_type_t type, size_t size,
const char *link_target)
{
- filemap_t *map = filemap;
file_entry_t *entry;
/*
@@ -264,21 +262,6 @@ process_target_file(const char *path, file_type_t type, size_t size,
* from the target data folder all paths which have been filtered out from
* the source data folder when processing the source files.
*/
- if (map->array == NULL)
- {
- /* on first call, initialize lookup array */
- if (map->nlist == 0)
- {
- /* should not happen */
- pg_fatal("source file list is empty");
- }
-
- filemap_list_to_array(map);
-
- Assert(map->array != NULL);
-
- qsort(map->array, map->narray, sizeof(file_entry_t *), path_cmp);
- }
/*
* Like in process_source_file, pretend that pg_wal is always a directory.
@@ -287,7 +270,9 @@ process_target_file(const char *path, file_type_t type, size_t size,
type = FILE_TYPE_DIRECTORY;
/* Remember this target file */
- entry = get_filemap_entry(path, true);
+ entry = insert_filehash_entry(path);
+ if (entry->target_exists)
+ pg_fatal("duplicate source file \"%s\"", path);
entry->target_exists = true;
entry->target_type = type;
entry->target_size = size;
@@ -300,7 +285,7 @@ process_target_file(const char *path, file_type_t type, size_t size,
* changed blocks in the pagemap of the file.
*
* NOTE: All the files on both systems must have already been added to the
- * file map!
+ * hash table!
*/
void
process_target_wal_block_change(ForkNumber forknum, RelFileNode rnode,
@@ -311,47 +296,45 @@ process_target_wal_block_change(ForkNumber forknum, RelFileNode rnode,
BlockNumber blkno_inseg;
int segno;
- Assert(filemap->array);
-
segno = blkno / RELSEG_SIZE;
blkno_inseg = blkno % RELSEG_SIZE;
path = datasegpath(rnode, forknum, segno);
- entry = get_filemap_entry(path, false);
+ entry = lookup_filehash_entry(path);
pfree(path);
+ /*
+ * If the block still exists in both systems, remember it. Otherwise we
+ * can safely ignore it.
+ *
+ * If the block is beyond the EOF in the source system, or the file doesn't
+ * doesn'exist in the source at all, we're going to truncate/remove it away
+ * from the target anyway. Likewise, if it doesn't exist in the target
+ * anymore, we will copy it over with the "tail" from the source system,
+ * anyway.
+ *
+ * It is possible to find WAL for a file that doesn't exist on either
+ * system anymore. It means that the relation was dropped later in the
+ * target system, and independently on the source system too, or that
+ * it was created and dropped in the target system and it never existed
+ * in the source. Either way, we can safely ignore it.
+ */
if (entry)
{
- int64 end_offset;
-
Assert(entry->isrelfile);
if (entry->target_type != FILE_TYPE_REGULAR)
pg_fatal("unexpected page modification for directory or symbolic link \"%s\"",
entry->path);
- /*
- * If the block beyond the EOF in the source system, no need to
- * remember it now, because we're going to truncate it away from the
- * target anyway. Also no need to remember the block if it's beyond
- * the current EOF in the target system; we will copy it over with the
- * "tail" from the source system, anyway.
- */
- end_offset = (blkno_inseg + 1) * BLCKSZ;
- if (end_offset <= entry->source_size &&
- end_offset <= entry->target_size)
- datapagemap_add(&entry->target_modified_pages, blkno_inseg);
- }
- else
- {
- /*
- * If we don't have any record of this file in the file map, it means
- * that it's a relation that doesn't exist in the source system. It
- * could exist in the target system; we haven't moved the target-only
- * entries from the linked list to the array yet! But in any case, if
- * it doesn't exist in the source it will be removed from the target
- * too, and we can safely ignore it.
- */
+ if (entry->target_exists && entry->source_exists)
+ {
+ off_t end_offset;
+
+ end_offset = (blkno_inseg + 1) * BLCKSZ;
+ if (end_offset <= entry->source_size && end_offset <= entry->target_size)
+ datapagemap_add(&entry->target_modified_pages, blkno_inseg);
+ }
}
}
@@ -413,34 +396,6 @@ check_file_excluded(const char *path, bool is_source)
return false;
}
-/*
- * Convert the linked list of entries in map->first/last to the array,
- * map->array.
- */
-static void
-filemap_list_to_array(filemap_t *map)
-{
- int narray;
- file_entry_t *entry,
- *next;
-
- map->array = (file_entry_t **)
- pg_realloc(map->array,
- (map->nlist + map->narray) * sizeof(file_entry_t *));
-
- narray = map->narray;
- for (entry = map->first; entry != NULL; entry = next)
- {
- map->array[narray++] = entry;
- next = entry->next;
- entry->next = NULL;
- }
- Assert(narray == map->nlist + map->narray);
- map->narray = narray;
- map->nlist = 0;
- map->first = map->last = NULL;
-}
-
static const char *
action_to_str(file_action_t action)
{
@@ -468,32 +423,31 @@ action_to_str(file_action_t action)
* Calculate the totals needed for progress reports.
*/
void
-calculate_totals(void)
+calculate_totals(filemap_t *filemap)
{
file_entry_t *entry;
int i;
- filemap_t *map = filemap;
- map->total_size = 0;
- map->fetch_size = 0;
+ filemap->total_size = 0;
+ filemap->fetch_size = 0;
- for (i = 0; i < map->narray; i++)
+ for (i = 0; i < filemap->nactions; i++)
{
- entry = map->array[i];
+ entry = filemap->actions[i];
if (entry->source_type != FILE_TYPE_REGULAR)
continue;
- map->total_size += entry->source_size;
+ filemap->total_size += entry->source_size;
if (entry->action == FILE_ACTION_COPY)
{
- map->fetch_size += entry->source_size;
+ filemap->fetch_size += entry->source_size;
continue;
}
if (entry->action == FILE_ACTION_COPY_TAIL)
- map->fetch_size += (entry->source_size - entry->target_size);
+ filemap->fetch_size += (entry->source_size - entry->target_size);
if (entry->target_modified_pages.bitmapsize > 0)
{
@@ -502,7 +456,7 @@ calculate_totals(void)
iter = datapagemap_iterate(&entry->target_modified_pages);
while (datapagemap_next(iter, &blk))
- map->fetch_size += BLCKSZ;
+ filemap->fetch_size += BLCKSZ;
pg_free(iter);
}
@@ -510,15 +464,14 @@ calculate_totals(void)
}
void
-print_filemap(void)
+print_filemap(filemap_t *filemap)
{
- filemap_t *map = filemap;
file_entry_t *entry;
int i;
- for (i = 0; i < map->narray; i++)
+ for (i = 0; i < filemap->nactions; i++)
{
- entry = map->array[i];
+ entry = filemap->actions[i];
if (entry->action != FILE_ACTION_NONE ||
entry->target_modified_pages.bitmapsize > 0)
{
@@ -640,15 +593,6 @@ datasegpath(RelFileNode rnode, ForkNumber forknum, BlockNumber segno)
return path;
}
-static int
-path_cmp(const void *a, const void *b)
-{
- file_entry_t *fa = *((file_entry_t **) a);
- file_entry_t *fb = *((file_entry_t **) b);
-
- return strcmp(fa->path, fb->path);
-}
-
/*
* In the final stage, the filemap is sorted so that removals come last.
* From disk space usage point of view, it would be better to do removals
@@ -834,21 +778,48 @@ decide_file_action(file_entry_t *entry)
/*
* Decide what to do with each file.
*/
-void
+filemap_t *
filemap_finalize()
{
int i;
+ filehash_iterator it;
+ file_entry_t *entry;
+ filemap_t *filemap;
- filemap_list_to_array(filemap);
-
- for (i = 0; i < filemap->narray; i++)
+ filehash_start_iterate(filehash, &it);
+ while ((entry = filehash_iterate(filehash, &it)) != NULL)
{
- file_entry_t *entry = filemap->array[i];
-
entry->action = decide_file_action(entry);
}
- /* Sort the actions to the order that they should be performed */
- qsort(filemap->array, filemap->narray, sizeof(file_entry_t *),
+ /*
+ * Turn the hash table into an array, sorted in the order that the actions
+ * should be performed.
+ */
+ filemap = pg_malloc(offsetof(filemap_t, actions) +
+ filehash->members * sizeof(file_entry_t *));
+ filemap->nactions = filehash->members;
+ filehash_start_iterate(filehash, &it);
+ i = 0;
+ while ((entry = filehash_iterate(filehash, &it)) != NULL)
+ {
+ filemap->actions[i++] = entry;
+ }
+
+ qsort(&filemap->actions, filemap->nactions, sizeof(file_entry_t *),
final_filemap_cmp);
+
+ return filemap;
+}
+
+
+/*
+ * Helper function for filemap hash table.
+ */
+static uint32
+hash_string_pointer(const char *s)
+{
+ unsigned char *ss = (unsigned char *) s;
+
+ return hash_bytes(ss, strlen(s));
}
diff --git a/src/bin/pg_rewind/filemap.h b/src/bin/pg_rewind/filemap.h
index a5e8df57f40..3660ffe0990 100644
--- a/src/bin/pg_rewind/filemap.h
+++ b/src/bin/pg_rewind/filemap.h
@@ -12,15 +12,6 @@
#include "storage/block.h"
#include "storage/relfilenode.h"
-/*
- * For every file found in the local or remote system, we have a file entry
- * that contains information about the file on both systems. For relation
- * files, there is also a page map that marks pages in the file that were
- * changed in the target after the last common checkpoint. Each entry also
- * contains an 'action' field, which says what we are going to do with the
- * file.
- */
-
/* these enum values are sorted in the order we want actions to be processed */
typedef enum
{
@@ -44,9 +35,21 @@ typedef enum
FILE_TYPE_SYMLINK
} file_type_t;
+/*
+ * For every file found in the local or remote system, we have a file entry
+ * that contains information about the file on both systems. For relation
+ * files, there is also a page map that marks pages in the file that were
+ * changed in the target after the last common checkpoint.
+ *
+ * When gathering information, these are kept in a hash table, private to
+ * filemap.c. filemap_finalize() fills in the 'action' field, sorts all the
+ * entries, and returns them in an array, ready for executing the actions.
+ */
typedef struct file_entry_t
{
- char *path;
+ uint32 status; /* hash status */
+
+ const char *path;
bool isrelfile; /* is it a relation data file? */
/*
@@ -71,44 +74,25 @@ typedef struct file_entry_t
* What will we do to the file?
*/
file_action_t action;
-
- struct file_entry_t *next;
} file_entry_t;
+/*
+ * This represents the final decisions on what to do with each file.
+ * 'actions' array contains an entry for each file, sorted in the order
+ * that their actions should executed.
+ */
typedef struct filemap_t
{
- /*
- * New entries are accumulated to a linked list, in process_source_file
- * and process_target_file.
- */
- file_entry_t *first;
- file_entry_t *last;
- int nlist; /* number of entries currently in list */
-
- /*
- * After processing all the remote files, the entries in the linked list
- * are moved to this array. After processing local files, too, all the
- * local entries are added to the array by filemap_finalize, and sorted in
- * the final order. After filemap_finalize, all the entries are in the
- * array, and the linked list is empty.
- */
- file_entry_t **array;
- int narray; /* current length of array */
-
- /*
- * Summary information.
- */
+ /* Summary information, filled by calculate_totals() */
uint64 total_size; /* total size of the source cluster */
uint64 fetch_size; /* number of bytes that needs to be copied */
-} filemap_t;
-extern filemap_t *filemap;
-
-extern void filemap_create(void);
-extern void calculate_totals(void);
-extern void print_filemap(void);
+ int nactions; /* size of 'actions' array */
+ file_entry_t *actions[FLEXIBLE_ARRAY_MEMBER];
+} filemap_t;
/* Functions for populating the filemap */
+extern void filemap_init(void);
extern void process_source_file(const char *path, file_type_t type,
size_t size, const char *link_target);
extern void process_target_file(const char *path, file_type_t type,
@@ -116,6 +100,9 @@ extern void process_target_file(const char *path, file_type_t type,
extern void process_target_wal_block_change(ForkNumber forknum,
RelFileNode rnode,
BlockNumber blkno);
-extern void filemap_finalize(void);
+
+extern filemap_t *filemap_finalize(void);
+extern void calculate_totals(filemap_t *filemap);
+extern void print_filemap(filemap_t *filemap);
#endif /* FILEMAP_H */
diff --git a/src/bin/pg_rewind/libpq_fetch.c b/src/bin/pg_rewind/libpq_fetch.c
index 7fc9161b8c8..9c541bb73d5 100644
--- a/src/bin/pg_rewind/libpq_fetch.c
+++ b/src/bin/pg_rewind/libpq_fetch.c
@@ -460,9 +460,9 @@ libpq_executeFileMap(filemap_t *map)
PQresultErrorMessage(res));
PQclear(res);
- for (i = 0; i < map->narray; i++)
+ for (i = 0; i < map->nactions; i++)
{
- entry = map->array[i];
+ entry = map->actions[i];
/* If this is a relation file, copy the modified blocks */
execute_pagemap(&entry->target_modified_pages, entry->path);
diff --git a/src/bin/pg_rewind/pg_rewind.c b/src/bin/pg_rewind/pg_rewind.c
index 210984d302b..2bdeed26c53 100644
--- a/src/bin/pg_rewind/pg_rewind.c
+++ b/src/bin/pg_rewind/pg_rewind.c
@@ -129,6 +129,7 @@ main(int argc, char **argv)
TimeLineID endtli;
ControlFileData ControlFile_new;
bool writerecoveryconf = false;
+ filemap_t *filemap;
pg_logging_init(argv[0]);
set_pglocale_pgservice(argv[0], PG_TEXTDOMAIN("pg_rewind"));
@@ -371,10 +372,11 @@ main(int argc, char **argv)
/*
* Collect information about all files in the target and source systems.
*/
- filemap_create();
if (showprogress)
pg_log_info("reading source file list");
+ filemap_init();
fetchSourceFileList();
+
if (showprogress)
pg_log_info("reading target file list");
traverse_datadir(datadir_target, &process_target_file);
@@ -395,13 +397,13 @@ main(int argc, char **argv)
* We have collected all information we need from both systems. Decide
* what to do with each file.
*/
- filemap_finalize();
+ filemap = filemap_finalize();
if (showprogress)
- calculate_totals();
+ calculate_totals(filemap);
/* this is too verbose even for verbose mode */
if (debug)
- print_filemap();
+ print_filemap(filemap);
/*
* Ok, we're ready to start copying things over.
@@ -421,7 +423,7 @@ main(int argc, char **argv)
* modified the target directory and there is no turning back!
*/
- executeFileMap();
+ execute_file_actions(filemap);
progress_report(true);
--
2.20.1
--------------BF34D0120055DC3839060F92
Content-Type: text/x-patch; charset=UTF-8;
name="v2-0004-pg_rewind-Refactor-the-abstraction-to-fetch-from-.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
filename*0="v2-0004-pg_rewind-Refactor-the-abstraction-to-fetch-from-.pa";
filename*1="tch"
^ permalink raw reply [nested|flat] 6+ messages in thread
* Put genbki.pl output into src/include/catalog/ directly
@ 2024-02-08 07:58 Peter Eisentraut <[email protected]>
0 siblings, 2 replies; 6+ messages in thread
From: Peter Eisentraut @ 2024-02-08 07:58 UTC (permalink / raw)
To: pgsql-hackers
With the makefile rules, the output of genbki.pl was written to
src/backend/catalog/, and then the header files were linked to
src/include/catalog/.
This patch changes it so that the output files are written directly to
src/include/catalog/. This makes the logic simpler, and it also makes
the behavior consistent with the meson build system. For example, a
file like schemapg.h is now mentioned only in
src/include/catalog/{meson.build,Makefile,.gitignore}
where before it was mentioned in (checks ...)
src/backend/catalog/.gitignore
src/backend/catalog/Makefile
src/include/Makefile
src/include/catalog/.gitignore
src/include/catalog/meson.build
Also, the list of catalog files is now kept in parallel in
src/include/catalog/{meson.build,Makefile}, while before the makefiles
had it in src/backend/catalog/Makefile.
I think keeping the two build systems aligned this way will be useful
for longer-term maintenance.
(There are other generated header files that are linked in a similar way
and could perhaps be simplified. But they don't all work the same way.
Some of the scripts also generate .c files, for example, so they need to
put some stuff under src/backend/. So I restricted this patch to
src/{backend,include}/catalog/, especially because it would be good to
keep the catalog lists aligned.)
From e9f3bfeeff47d96c2557836e7c964adba2d9edb5 Mon Sep 17 00:00:00 2001
From: Peter Eisentraut <[email protected]>
Date: Thu, 8 Feb 2024 08:31:21 +0100
Subject: [PATCH] Put genbki.pl output into src/include/catalog/ directly
With the makefile rules, the output of genbki.pl was written to
src/backend/catalog/, and then the header files were linked to
src/include/catalog/.
This changes it so that the output files are written directly to
src/include/catalog/. This makes the logic simpler, and it also makes
the behavior consistent with the meson build system. Also, the list
of catalog files is now kept in parallel in
src/include/catalog/{meson.build,Makefile}, while before the makefiles
had it in src/backend/catalog/Makefile.
---
src/backend/Makefile | 2 +-
src/backend/catalog/.gitignore | 8 --
src/backend/catalog/Makefile | 140 +-------------------------
src/include/Makefile | 7 +-
src/include/catalog/.gitignore | 4 +-
src/include/catalog/Makefile | 152 +++++++++++++++++++++++++++++
src/include/catalog/meson.build | 3 +-
src/tools/pginclude/cpluspluscheck | 2 -
src/tools/pginclude/headerscheck | 2 -
9 files changed, 163 insertions(+), 157 deletions(-)
delete mode 100644 src/backend/catalog/.gitignore
diff --git a/src/backend/Makefile b/src/backend/Makefile
index 7d2ea7d54a6..6b3c432c545 100644
--- a/src/backend/Makefile
+++ b/src/backend/Makefile
@@ -138,7 +138,7 @@ utils/activity/wait_event_types.h: utils/activity/generate-wait_event_types.pl u
# run this unconditionally to avoid needing to know its dependencies here:
submake-catalog-headers:
- $(MAKE) -C catalog generated-header-symlinks
+ $(MAKE) -C ../include/catalog generated-headers
# run this unconditionally to avoid needing to know its dependencies here:
submake-nodes-headers:
diff --git a/src/backend/catalog/.gitignore b/src/backend/catalog/.gitignore
deleted file mode 100644
index b580f734c71..00000000000
--- a/src/backend/catalog/.gitignore
+++ /dev/null
@@ -1,8 +0,0 @@
-/postgres.bki
-/schemapg.h
-/syscache_ids.h
-/syscache_info.h
-/system_fk_info.h
-/system_constraints.sql
-/pg_*_d.h
-/bki-stamp
diff --git a/src/backend/catalog/Makefile b/src/backend/catalog/Makefile
index 196ecafc909..1589a75fd53 100644
--- a/src/backend/catalog/Makefile
+++ b/src/backend/catalog/Makefile
@@ -50,141 +50,8 @@ OBJS = \
include $(top_srcdir)/src/backend/common.mk
-# Note: the order of this list determines the order in which the catalog
-# header files are assembled into postgres.bki. BKI_BOOTSTRAP catalogs
-# must appear first, and pg_statistic before pg_statistic_ext_data, and
-# there are reputedly other, undocumented ordering dependencies.
-CATALOG_HEADERS := \
- pg_proc.h \
- pg_type.h \
- pg_attribute.h \
- pg_class.h \
- pg_attrdef.h \
- pg_constraint.h \
- pg_inherits.h \
- pg_index.h \
- pg_operator.h \
- pg_opfamily.h \
- pg_opclass.h \
- pg_am.h \
- pg_amop.h \
- pg_amproc.h \
- pg_language.h \
- pg_largeobject_metadata.h \
- pg_largeobject.h \
- pg_aggregate.h \
- pg_statistic.h \
- pg_statistic_ext.h \
- pg_statistic_ext_data.h \
- pg_rewrite.h \
- pg_trigger.h \
- pg_event_trigger.h \
- pg_description.h \
- pg_cast.h \
- pg_enum.h \
- pg_namespace.h \
- pg_conversion.h \
- pg_depend.h \
- pg_database.h \
- pg_db_role_setting.h \
- pg_tablespace.h \
- pg_authid.h \
- pg_auth_members.h \
- pg_shdepend.h \
- pg_shdescription.h \
- pg_ts_config.h \
- pg_ts_config_map.h \
- pg_ts_dict.h \
- pg_ts_parser.h \
- pg_ts_template.h \
- pg_extension.h \
- pg_foreign_data_wrapper.h \
- pg_foreign_server.h \
- pg_user_mapping.h \
- pg_foreign_table.h \
- pg_policy.h \
- pg_replication_origin.h \
- pg_default_acl.h \
- pg_init_privs.h \
- pg_seclabel.h \
- pg_shseclabel.h \
- pg_collation.h \
- pg_parameter_acl.h \
- pg_partitioned_table.h \
- pg_range.h \
- pg_transform.h \
- pg_sequence.h \
- pg_publication.h \
- pg_publication_namespace.h \
- pg_publication_rel.h \
- pg_subscription.h \
- pg_subscription_rel.h
-
-GENERATED_HEADERS := $(CATALOG_HEADERS:%.h=%_d.h) schemapg.h syscache_ids.h syscache_info.h system_fk_info.h
-
-POSTGRES_BKI_SRCS := $(addprefix $(top_srcdir)/src/include/catalog/, $(CATALOG_HEADERS))
-
-# The .dat files we need can just be listed alphabetically.
-POSTGRES_BKI_DATA = $(addprefix $(top_srcdir)/src/include/catalog/,\
- pg_aggregate.dat \
- pg_am.dat \
- pg_amop.dat \
- pg_amproc.dat \
- pg_authid.dat \
- pg_cast.dat \
- pg_class.dat \
- pg_collation.dat \
- pg_conversion.dat \
- pg_database.dat \
- pg_language.dat \
- pg_namespace.dat \
- pg_opclass.dat \
- pg_operator.dat \
- pg_opfamily.dat \
- pg_proc.dat \
- pg_range.dat \
- pg_tablespace.dat \
- pg_ts_config.dat \
- pg_ts_config_map.dat \
- pg_ts_dict.dat \
- pg_ts_parser.dat \
- pg_ts_template.dat \
- pg_type.dat \
- )
-
-all: generated-header-symlinks
-
-.PHONY: generated-header-symlinks
-
-generated-header-symlinks: $(top_builddir)/src/include/catalog/header-stamp
-
-# bki-stamp records the last time we ran genbki.pl. We don't rely on
-# the timestamps of the individual output files, because the Perl script
-# won't update them if they didn't change (to avoid unnecessary recompiles).
-# Technically, this should depend on Makefile.global which supplies
-# $(MAJORVERSION); but then genbki.pl would need to be re-run after every
-# configure run, even in distribution tarballs. So depending on configure.ac
-# instead is cheating a bit, but it will achieve the goal of updating the
-# version number when it changes.
-bki-stamp: genbki.pl Catalog.pm $(POSTGRES_BKI_SRCS) $(POSTGRES_BKI_DATA) $(top_srcdir)/configure.ac $(top_srcdir)/src/include/access/transam.h
- $(PERL) $< --include-path=$(top_srcdir)/src/include/ \
- --set-version=$(MAJORVERSION) $(POSTGRES_BKI_SRCS)
- touch $@
-
-# The generated headers must all be symlinked into src/include/.
-# We use header-stamp to record that we've done this because the symlinks
-# themselves may appear older than bki-stamp.
-$(top_builddir)/src/include/catalog/header-stamp: bki-stamp
- cd '$(dir $@)' && for file in $(GENERATED_HEADERS); do \
- rm -f $$file && $(LN_S) "../../../$(subdir)/$$file" . ; \
- done
- touch $@
-
-# Note: installation of generated headers is handled elsewhere
.PHONY: install-data
-install-data: bki-stamp installdirs
- $(INSTALL_DATA) postgres.bki '$(DESTDIR)$(datadir)/postgres.bki'
- $(INSTALL_DATA) system_constraints.sql '$(DESTDIR)$(datadir)/system_constraints.sql'
+install-data: installdirs
$(INSTALL_DATA) $(srcdir)/system_functions.sql '$(DESTDIR)$(datadir)/system_functions.sql'
$(INSTALL_DATA) $(srcdir)/system_views.sql '$(DESTDIR)$(datadir)/system_views.sql'
$(INSTALL_DATA) $(srcdir)/information_schema.sql '$(DESTDIR)$(datadir)/information_schema.sql'
@@ -195,7 +62,4 @@ installdirs:
.PHONY: uninstall-data
uninstall-data:
- rm -f $(addprefix '$(DESTDIR)$(datadir)'/, postgres.bki system_constraints.sql system_functions.sql system_views.sql information_schema.sql sql_features.txt)
-
-clean:
- rm -f bki-stamp postgres.bki system_constraints.sql $(GENERATED_HEADERS)
+ rm -f $(addprefix '$(DESTDIR)$(datadir)'/, system_functions.sql system_views.sql information_schema.sql sql_features.txt)
diff --git a/src/include/Makefile b/src/include/Makefile
index 584d0300d98..b8b576a4de3 100644
--- a/src/include/Makefile
+++ b/src/include/Makefile
@@ -54,10 +54,11 @@ install: all installdirs
$(INSTALL_DATA) $(srcdir)/$$dir/*.h '$(DESTDIR)$(includedir_server)'/$$dir || exit; \
done
ifeq ($(vpath_build),yes)
- for file in catalog/schemapg.h catalog/syscache_ids.h catalog/system_fk_info.h catalog/pg_*_d.h storage/lwlocknames.h utils/probes.h utils/wait_event_types.h; do \
+ for file in storage/lwlocknames.h utils/probes.h utils/wait_event_types.h; do \
$(INSTALL_DATA) $$file '$(DESTDIR)$(includedir_server)'/$$file || exit; \
done
endif
+ $(MAKE) -C catalog install
installdirs:
$(MKDIR_P) '$(DESTDIR)$(includedir)/libpq' '$(DESTDIR)$(includedir_internal)/libpq'
@@ -69,14 +70,14 @@ uninstall:
rm -f $(addprefix '$(DESTDIR)$(includedir_internal)'/, c.h port.h postgres_fe.h libpq/pqcomm.h libpq/protocol.h)
# heuristic...
rm -rf $(addprefix '$(DESTDIR)$(includedir_server)'/, $(SUBDIRS) *.h)
+ $(MAKE) -C catalog uninstall
clean:
rm -f utils/fmgroids.h utils/fmgrprotos.h utils/errcodes.h utils/header-stamp
rm -f storage/lwlocknames.h utils/probes.h utils/wait_event_types.h
- rm -f catalog/schemapg.h catalog/syscache_ids.h catalog/syscache_info.h catalog/system_fk_info.h
- rm -f catalog/pg_*_d.h catalog/header-stamp
rm -f nodes/nodetags.h nodes/header-stamp
+ $(MAKE) -C catalog clean
distclean: clean
rm -f pg_config.h pg_config_ext.h pg_config_os.h stamp-h stamp-ext-h
diff --git a/src/include/catalog/.gitignore b/src/include/catalog/.gitignore
index 983574f2c4d..b580f734c71 100644
--- a/src/include/catalog/.gitignore
+++ b/src/include/catalog/.gitignore
@@ -1,6 +1,8 @@
+/postgres.bki
/schemapg.h
/syscache_ids.h
/syscache_info.h
/system_fk_info.h
+/system_constraints.sql
/pg_*_d.h
-/header-stamp
+/bki-stamp
diff --git a/src/include/catalog/Makefile b/src/include/catalog/Makefile
index c2b3cf238db..167f91a6e3f 100644
--- a/src/include/catalog/Makefile
+++ b/src/include/catalog/Makefile
@@ -13,6 +13,158 @@ subdir = src/include/catalog
top_builddir = ../../..
include $(top_builddir)/src/Makefile.global
+# Note: the order of this list determines the order in which the catalog
+# header files are assembled into postgres.bki. BKI_BOOTSTRAP catalogs
+# must appear first, and pg_statistic before pg_statistic_ext_data, and
+# there are reputedly other, undocumented ordering dependencies.
+CATALOG_HEADERS := \
+ pg_proc.h \
+ pg_type.h \
+ pg_attribute.h \
+ pg_class.h \
+ pg_attrdef.h \
+ pg_constraint.h \
+ pg_inherits.h \
+ pg_index.h \
+ pg_operator.h \
+ pg_opfamily.h \
+ pg_opclass.h \
+ pg_am.h \
+ pg_amop.h \
+ pg_amproc.h \
+ pg_language.h \
+ pg_largeobject_metadata.h \
+ pg_largeobject.h \
+ pg_aggregate.h \
+ pg_statistic.h \
+ pg_statistic_ext.h \
+ pg_statistic_ext_data.h \
+ pg_rewrite.h \
+ pg_trigger.h \
+ pg_event_trigger.h \
+ pg_description.h \
+ pg_cast.h \
+ pg_enum.h \
+ pg_namespace.h \
+ pg_conversion.h \
+ pg_depend.h \
+ pg_database.h \
+ pg_db_role_setting.h \
+ pg_tablespace.h \
+ pg_authid.h \
+ pg_auth_members.h \
+ pg_shdepend.h \
+ pg_shdescription.h \
+ pg_ts_config.h \
+ pg_ts_config_map.h \
+ pg_ts_dict.h \
+ pg_ts_parser.h \
+ pg_ts_template.h \
+ pg_extension.h \
+ pg_foreign_data_wrapper.h \
+ pg_foreign_server.h \
+ pg_user_mapping.h \
+ pg_foreign_table.h \
+ pg_policy.h \
+ pg_replication_origin.h \
+ pg_default_acl.h \
+ pg_init_privs.h \
+ pg_seclabel.h \
+ pg_shseclabel.h \
+ pg_collation.h \
+ pg_parameter_acl.h \
+ pg_partitioned_table.h \
+ pg_range.h \
+ pg_transform.h \
+ pg_sequence.h \
+ pg_publication.h \
+ pg_publication_namespace.h \
+ pg_publication_rel.h \
+ pg_subscription.h \
+ pg_subscription_rel.h
+
+GENERATED_HEADERS := $(CATALOG_HEADERS:%.h=%_d.h)
+
+POSTGRES_BKI_SRCS := $(addprefix $(top_srcdir)/src/include/catalog/, $(CATALOG_HEADERS))
+
+# The .dat files we need can just be listed alphabetically.
+POSTGRES_BKI_DATA = \
+ pg_aggregate.dat \
+ pg_am.dat \
+ pg_amop.dat \
+ pg_amproc.dat \
+ pg_authid.dat \
+ pg_cast.dat \
+ pg_class.dat \
+ pg_collation.dat \
+ pg_conversion.dat \
+ pg_database.dat \
+ pg_language.dat \
+ pg_namespace.dat \
+ pg_opclass.dat \
+ pg_operator.dat \
+ pg_opfamily.dat \
+ pg_proc.dat \
+ pg_range.dat \
+ pg_tablespace.dat \
+ pg_ts_config.dat \
+ pg_ts_config_map.dat \
+ pg_ts_dict.dat \
+ pg_ts_parser.dat \
+ pg_ts_template.dat \
+ pg_type.dat
+
+GENBKI_OUTPUT_FILES = \
+ $(GENERATED_HEADERS) \
+ postgres.bki \
+ system_constraints.sql \
+ schemapg.h \
+ syscache_ids.h \
+ syscache_info.h \
+ system_fk_info.h
+
+all: generated-headers
+
+.PHONY: generated-headers
+
+generated-headers: bki-stamp
+
+# bki-stamp records the last time we ran genbki.pl. We don't rely on
+# the timestamps of the individual output files, because the Perl script
+# won't update them if they didn't change (to avoid unnecessary recompiles).
+# Technically, this should depend on Makefile.global which supplies
+# $(MAJORVERSION); but then genbki.pl would need to be re-run after every
+# configure run, even in distribution tarballs. So depending on configure.ac
+# instead is cheating a bit, but it will achieve the goal of updating the
+# version number when it changes.
+bki-stamp: $(top_srcdir)/src/backend/catalog/genbki.pl $(top_srcdir)/src/backend/catalog/Catalog.pm $(POSTGRES_BKI_SRCS) $(POSTGRES_BKI_DATA) $(top_srcdir)/configure.ac $(top_srcdir)/src/include/access/transam.h
+ $(PERL) $< --include-path=$(top_srcdir)/src/include/ \
+ --set-version=$(MAJORVERSION) $(POSTGRES_BKI_SRCS)
+ touch $@
+
+install: all installdirs
+ $(INSTALL_DATA) postgres.bki '$(DESTDIR)$(datadir)/postgres.bki'
+ $(INSTALL_DATA) system_constraints.sql '$(DESTDIR)$(datadir)/system_constraints.sql'
+# In non-vpath builds, src/include/Makefile already installs all headers.
+ifeq ($(vpath_build),yes)
+ $(INSTALL_DATA) schemapg.h '$(DESTDIR)$(includedir_server)'/catalog/schemapg.h
+ $(INSTALL_DATA) syscache_ids.h '$(DESTDIR)$(includedir_server)'/catalog/syscache_ids.h
+ $(INSTALL_DATA) system_fk_info.h '$(DESTDIR)$(includedir_server)'/catalog/system_fk_info.h
+ for file in $(GENERATED_HEADERS); do \
+ $(INSTALL_DATA) $$file '$(DESTDIR)$(includedir_server)'/catalog/$$file || exit; \
+ done
+endif
+
+installdirs:
+ $(MKDIR_P) '$(DESTDIR)$(datadir)' '$(DESTDIR)$(includedir_server)'
+
+uninstall:
+ rm -f $(addprefix '$(DESTDIR)$(datadir)'/, postgres.bki system_constraints.sql)
+ rm -f $(addprefix '$(DESTDIR)$(includedir_server)'/catalog/, schemapg.h syscache_ids.h system_fk_info.h $(GENERATED_HEADERS))
+
+clean:
+ rm -f bki-stamp $(GENBKI_OUTPUT_FILES)
+
# 'make reformat-dat-files' is a convenience target for rewriting the
# catalog data files in our standard format. This includes collapsing
# out any entries that are redundant with a BKI_DEFAULT annotation.
diff --git a/src/include/catalog/meson.build b/src/include/catalog/meson.build
index 6b3c56c20e8..f70d1daba52 100644
--- a/src/include/catalog/meson.build
+++ b/src/include/catalog/meson.build
@@ -145,8 +145,7 @@ generated_catalog_headers = custom_target('generated_catalog_headers',
generated_headers += generated_catalog_headers.to_list()
# autoconf generates the file there, ensure we get a conflict
-generated_sources_ac += {'src/backend/catalog': output_files + ['bki-stamp']}
-generated_sources_ac += {'src/include/catalog': ['header-stamp']}
+generated_sources_ac += {'src/include/catalog': output_files + ['bki-stamp']}
# 'reformat-dat-files' is a convenience target for rewriting the
# catalog data files in our standard format. This includes collapsing
diff --git a/src/tools/pginclude/cpluspluscheck b/src/tools/pginclude/cpluspluscheck
index 7edfc44b49a..404c6584b16 100755
--- a/src/tools/pginclude/cpluspluscheck
+++ b/src/tools/pginclude/cpluspluscheck
@@ -119,8 +119,6 @@ do
test "$f" = src/include/common/unicode_nonspacing_table.h && continue
test "$f" = src/include/common/unicode_east_asian_fw_table.h && continue
- test "$f" = src/backend/catalog/syscache_ids.h && continue
- test "$f" = src/backend/catalog/syscache_info.h && continue
test "$f" = src/include/catalog/syscache_ids.h && continue
test "$f" = src/include/catalog/syscache_info.h && continue
diff --git a/src/tools/pginclude/headerscheck b/src/tools/pginclude/headerscheck
index 84b892b5c51..a5299bf459f 100755
--- a/src/tools/pginclude/headerscheck
+++ b/src/tools/pginclude/headerscheck
@@ -114,8 +114,6 @@ do
test "$f" = src/include/common/unicode_nonspacing_table.h && continue
test "$f" = src/include/common/unicode_east_asian_fw_table.h && continue
- test "$f" = src/backend/catalog/syscache_ids.h && continue
- test "$f" = src/backend/catalog/syscache_info.h && continue
test "$f" = src/include/catalog/syscache_ids.h && continue
test "$f" = src/include/catalog/syscache_info.h && continue
base-commit: 25799850867292efecf34da73db4ea1ad1aad573
--
2.43.0
Attachments:
[text/plain] 0001-Put-genbki.pl-output-into-src-include-catalog-direct.patch (15.8K, ../../[email protected]/2-0001-Put-genbki.pl-output-into-src-include-catalog-direct.patch)
download | inline diff:
From e9f3bfeeff47d96c2557836e7c964adba2d9edb5 Mon Sep 17 00:00:00 2001
From: Peter Eisentraut <[email protected]>
Date: Thu, 8 Feb 2024 08:31:21 +0100
Subject: [PATCH] Put genbki.pl output into src/include/catalog/ directly
With the makefile rules, the output of genbki.pl was written to
src/backend/catalog/, and then the header files were linked to
src/include/catalog/.
This changes it so that the output files are written directly to
src/include/catalog/. This makes the logic simpler, and it also makes
the behavior consistent with the meson build system. Also, the list
of catalog files is now kept in parallel in
src/include/catalog/{meson.build,Makefile}, while before the makefiles
had it in src/backend/catalog/Makefile.
---
src/backend/Makefile | 2 +-
src/backend/catalog/.gitignore | 8 --
src/backend/catalog/Makefile | 140 +-------------------------
src/include/Makefile | 7 +-
src/include/catalog/.gitignore | 4 +-
src/include/catalog/Makefile | 152 +++++++++++++++++++++++++++++
src/include/catalog/meson.build | 3 +-
src/tools/pginclude/cpluspluscheck | 2 -
src/tools/pginclude/headerscheck | 2 -
9 files changed, 163 insertions(+), 157 deletions(-)
delete mode 100644 src/backend/catalog/.gitignore
diff --git a/src/backend/Makefile b/src/backend/Makefile
index 7d2ea7d54a6..6b3c432c545 100644
--- a/src/backend/Makefile
+++ b/src/backend/Makefile
@@ -138,7 +138,7 @@ utils/activity/wait_event_types.h: utils/activity/generate-wait_event_types.pl u
# run this unconditionally to avoid needing to know its dependencies here:
submake-catalog-headers:
- $(MAKE) -C catalog generated-header-symlinks
+ $(MAKE) -C ../include/catalog generated-headers
# run this unconditionally to avoid needing to know its dependencies here:
submake-nodes-headers:
diff --git a/src/backend/catalog/.gitignore b/src/backend/catalog/.gitignore
deleted file mode 100644
index b580f734c71..00000000000
--- a/src/backend/catalog/.gitignore
+++ /dev/null
@@ -1,8 +0,0 @@
-/postgres.bki
-/schemapg.h
-/syscache_ids.h
-/syscache_info.h
-/system_fk_info.h
-/system_constraints.sql
-/pg_*_d.h
-/bki-stamp
diff --git a/src/backend/catalog/Makefile b/src/backend/catalog/Makefile
index 196ecafc909..1589a75fd53 100644
--- a/src/backend/catalog/Makefile
+++ b/src/backend/catalog/Makefile
@@ -50,141 +50,8 @@ OBJS = \
include $(top_srcdir)/src/backend/common.mk
-# Note: the order of this list determines the order in which the catalog
-# header files are assembled into postgres.bki. BKI_BOOTSTRAP catalogs
-# must appear first, and pg_statistic before pg_statistic_ext_data, and
-# there are reputedly other, undocumented ordering dependencies.
-CATALOG_HEADERS := \
- pg_proc.h \
- pg_type.h \
- pg_attribute.h \
- pg_class.h \
- pg_attrdef.h \
- pg_constraint.h \
- pg_inherits.h \
- pg_index.h \
- pg_operator.h \
- pg_opfamily.h \
- pg_opclass.h \
- pg_am.h \
- pg_amop.h \
- pg_amproc.h \
- pg_language.h \
- pg_largeobject_metadata.h \
- pg_largeobject.h \
- pg_aggregate.h \
- pg_statistic.h \
- pg_statistic_ext.h \
- pg_statistic_ext_data.h \
- pg_rewrite.h \
- pg_trigger.h \
- pg_event_trigger.h \
- pg_description.h \
- pg_cast.h \
- pg_enum.h \
- pg_namespace.h \
- pg_conversion.h \
- pg_depend.h \
- pg_database.h \
- pg_db_role_setting.h \
- pg_tablespace.h \
- pg_authid.h \
- pg_auth_members.h \
- pg_shdepend.h \
- pg_shdescription.h \
- pg_ts_config.h \
- pg_ts_config_map.h \
- pg_ts_dict.h \
- pg_ts_parser.h \
- pg_ts_template.h \
- pg_extension.h \
- pg_foreign_data_wrapper.h \
- pg_foreign_server.h \
- pg_user_mapping.h \
- pg_foreign_table.h \
- pg_policy.h \
- pg_replication_origin.h \
- pg_default_acl.h \
- pg_init_privs.h \
- pg_seclabel.h \
- pg_shseclabel.h \
- pg_collation.h \
- pg_parameter_acl.h \
- pg_partitioned_table.h \
- pg_range.h \
- pg_transform.h \
- pg_sequence.h \
- pg_publication.h \
- pg_publication_namespace.h \
- pg_publication_rel.h \
- pg_subscription.h \
- pg_subscription_rel.h
-
-GENERATED_HEADERS := $(CATALOG_HEADERS:%.h=%_d.h) schemapg.h syscache_ids.h syscache_info.h system_fk_info.h
-
-POSTGRES_BKI_SRCS := $(addprefix $(top_srcdir)/src/include/catalog/, $(CATALOG_HEADERS))
-
-# The .dat files we need can just be listed alphabetically.
-POSTGRES_BKI_DATA = $(addprefix $(top_srcdir)/src/include/catalog/,\
- pg_aggregate.dat \
- pg_am.dat \
- pg_amop.dat \
- pg_amproc.dat \
- pg_authid.dat \
- pg_cast.dat \
- pg_class.dat \
- pg_collation.dat \
- pg_conversion.dat \
- pg_database.dat \
- pg_language.dat \
- pg_namespace.dat \
- pg_opclass.dat \
- pg_operator.dat \
- pg_opfamily.dat \
- pg_proc.dat \
- pg_range.dat \
- pg_tablespace.dat \
- pg_ts_config.dat \
- pg_ts_config_map.dat \
- pg_ts_dict.dat \
- pg_ts_parser.dat \
- pg_ts_template.dat \
- pg_type.dat \
- )
-
-all: generated-header-symlinks
-
-.PHONY: generated-header-symlinks
-
-generated-header-symlinks: $(top_builddir)/src/include/catalog/header-stamp
-
-# bki-stamp records the last time we ran genbki.pl. We don't rely on
-# the timestamps of the individual output files, because the Perl script
-# won't update them if they didn't change (to avoid unnecessary recompiles).
-# Technically, this should depend on Makefile.global which supplies
-# $(MAJORVERSION); but then genbki.pl would need to be re-run after every
-# configure run, even in distribution tarballs. So depending on configure.ac
-# instead is cheating a bit, but it will achieve the goal of updating the
-# version number when it changes.
-bki-stamp: genbki.pl Catalog.pm $(POSTGRES_BKI_SRCS) $(POSTGRES_BKI_DATA) $(top_srcdir)/configure.ac $(top_srcdir)/src/include/access/transam.h
- $(PERL) $< --include-path=$(top_srcdir)/src/include/ \
- --set-version=$(MAJORVERSION) $(POSTGRES_BKI_SRCS)
- touch $@
-
-# The generated headers must all be symlinked into src/include/.
-# We use header-stamp to record that we've done this because the symlinks
-# themselves may appear older than bki-stamp.
-$(top_builddir)/src/include/catalog/header-stamp: bki-stamp
- cd '$(dir $@)' && for file in $(GENERATED_HEADERS); do \
- rm -f $$file && $(LN_S) "../../../$(subdir)/$$file" . ; \
- done
- touch $@
-
-# Note: installation of generated headers is handled elsewhere
.PHONY: install-data
-install-data: bki-stamp installdirs
- $(INSTALL_DATA) postgres.bki '$(DESTDIR)$(datadir)/postgres.bki'
- $(INSTALL_DATA) system_constraints.sql '$(DESTDIR)$(datadir)/system_constraints.sql'
+install-data: installdirs
$(INSTALL_DATA) $(srcdir)/system_functions.sql '$(DESTDIR)$(datadir)/system_functions.sql'
$(INSTALL_DATA) $(srcdir)/system_views.sql '$(DESTDIR)$(datadir)/system_views.sql'
$(INSTALL_DATA) $(srcdir)/information_schema.sql '$(DESTDIR)$(datadir)/information_schema.sql'
@@ -195,7 +62,4 @@ installdirs:
.PHONY: uninstall-data
uninstall-data:
- rm -f $(addprefix '$(DESTDIR)$(datadir)'/, postgres.bki system_constraints.sql system_functions.sql system_views.sql information_schema.sql sql_features.txt)
-
-clean:
- rm -f bki-stamp postgres.bki system_constraints.sql $(GENERATED_HEADERS)
+ rm -f $(addprefix '$(DESTDIR)$(datadir)'/, system_functions.sql system_views.sql information_schema.sql sql_features.txt)
diff --git a/src/include/Makefile b/src/include/Makefile
index 584d0300d98..b8b576a4de3 100644
--- a/src/include/Makefile
+++ b/src/include/Makefile
@@ -54,10 +54,11 @@ install: all installdirs
$(INSTALL_DATA) $(srcdir)/$$dir/*.h '$(DESTDIR)$(includedir_server)'/$$dir || exit; \
done
ifeq ($(vpath_build),yes)
- for file in catalog/schemapg.h catalog/syscache_ids.h catalog/system_fk_info.h catalog/pg_*_d.h storage/lwlocknames.h utils/probes.h utils/wait_event_types.h; do \
+ for file in storage/lwlocknames.h utils/probes.h utils/wait_event_types.h; do \
$(INSTALL_DATA) $$file '$(DESTDIR)$(includedir_server)'/$$file || exit; \
done
endif
+ $(MAKE) -C catalog install
installdirs:
$(MKDIR_P) '$(DESTDIR)$(includedir)/libpq' '$(DESTDIR)$(includedir_internal)/libpq'
@@ -69,14 +70,14 @@ uninstall:
rm -f $(addprefix '$(DESTDIR)$(includedir_internal)'/, c.h port.h postgres_fe.h libpq/pqcomm.h libpq/protocol.h)
# heuristic...
rm -rf $(addprefix '$(DESTDIR)$(includedir_server)'/, $(SUBDIRS) *.h)
+ $(MAKE) -C catalog uninstall
clean:
rm -f utils/fmgroids.h utils/fmgrprotos.h utils/errcodes.h utils/header-stamp
rm -f storage/lwlocknames.h utils/probes.h utils/wait_event_types.h
- rm -f catalog/schemapg.h catalog/syscache_ids.h catalog/syscache_info.h catalog/system_fk_info.h
- rm -f catalog/pg_*_d.h catalog/header-stamp
rm -f nodes/nodetags.h nodes/header-stamp
+ $(MAKE) -C catalog clean
distclean: clean
rm -f pg_config.h pg_config_ext.h pg_config_os.h stamp-h stamp-ext-h
diff --git a/src/include/catalog/.gitignore b/src/include/catalog/.gitignore
index 983574f2c4d..b580f734c71 100644
--- a/src/include/catalog/.gitignore
+++ b/src/include/catalog/.gitignore
@@ -1,6 +1,8 @@
+/postgres.bki
/schemapg.h
/syscache_ids.h
/syscache_info.h
/system_fk_info.h
+/system_constraints.sql
/pg_*_d.h
-/header-stamp
+/bki-stamp
diff --git a/src/include/catalog/Makefile b/src/include/catalog/Makefile
index c2b3cf238db..167f91a6e3f 100644
--- a/src/include/catalog/Makefile
+++ b/src/include/catalog/Makefile
@@ -13,6 +13,158 @@ subdir = src/include/catalog
top_builddir = ../../..
include $(top_builddir)/src/Makefile.global
+# Note: the order of this list determines the order in which the catalog
+# header files are assembled into postgres.bki. BKI_BOOTSTRAP catalogs
+# must appear first, and pg_statistic before pg_statistic_ext_data, and
+# there are reputedly other, undocumented ordering dependencies.
+CATALOG_HEADERS := \
+ pg_proc.h \
+ pg_type.h \
+ pg_attribute.h \
+ pg_class.h \
+ pg_attrdef.h \
+ pg_constraint.h \
+ pg_inherits.h \
+ pg_index.h \
+ pg_operator.h \
+ pg_opfamily.h \
+ pg_opclass.h \
+ pg_am.h \
+ pg_amop.h \
+ pg_amproc.h \
+ pg_language.h \
+ pg_largeobject_metadata.h \
+ pg_largeobject.h \
+ pg_aggregate.h \
+ pg_statistic.h \
+ pg_statistic_ext.h \
+ pg_statistic_ext_data.h \
+ pg_rewrite.h \
+ pg_trigger.h \
+ pg_event_trigger.h \
+ pg_description.h \
+ pg_cast.h \
+ pg_enum.h \
+ pg_namespace.h \
+ pg_conversion.h \
+ pg_depend.h \
+ pg_database.h \
+ pg_db_role_setting.h \
+ pg_tablespace.h \
+ pg_authid.h \
+ pg_auth_members.h \
+ pg_shdepend.h \
+ pg_shdescription.h \
+ pg_ts_config.h \
+ pg_ts_config_map.h \
+ pg_ts_dict.h \
+ pg_ts_parser.h \
+ pg_ts_template.h \
+ pg_extension.h \
+ pg_foreign_data_wrapper.h \
+ pg_foreign_server.h \
+ pg_user_mapping.h \
+ pg_foreign_table.h \
+ pg_policy.h \
+ pg_replication_origin.h \
+ pg_default_acl.h \
+ pg_init_privs.h \
+ pg_seclabel.h \
+ pg_shseclabel.h \
+ pg_collation.h \
+ pg_parameter_acl.h \
+ pg_partitioned_table.h \
+ pg_range.h \
+ pg_transform.h \
+ pg_sequence.h \
+ pg_publication.h \
+ pg_publication_namespace.h \
+ pg_publication_rel.h \
+ pg_subscription.h \
+ pg_subscription_rel.h
+
+GENERATED_HEADERS := $(CATALOG_HEADERS:%.h=%_d.h)
+
+POSTGRES_BKI_SRCS := $(addprefix $(top_srcdir)/src/include/catalog/, $(CATALOG_HEADERS))
+
+# The .dat files we need can just be listed alphabetically.
+POSTGRES_BKI_DATA = \
+ pg_aggregate.dat \
+ pg_am.dat \
+ pg_amop.dat \
+ pg_amproc.dat \
+ pg_authid.dat \
+ pg_cast.dat \
+ pg_class.dat \
+ pg_collation.dat \
+ pg_conversion.dat \
+ pg_database.dat \
+ pg_language.dat \
+ pg_namespace.dat \
+ pg_opclass.dat \
+ pg_operator.dat \
+ pg_opfamily.dat \
+ pg_proc.dat \
+ pg_range.dat \
+ pg_tablespace.dat \
+ pg_ts_config.dat \
+ pg_ts_config_map.dat \
+ pg_ts_dict.dat \
+ pg_ts_parser.dat \
+ pg_ts_template.dat \
+ pg_type.dat
+
+GENBKI_OUTPUT_FILES = \
+ $(GENERATED_HEADERS) \
+ postgres.bki \
+ system_constraints.sql \
+ schemapg.h \
+ syscache_ids.h \
+ syscache_info.h \
+ system_fk_info.h
+
+all: generated-headers
+
+.PHONY: generated-headers
+
+generated-headers: bki-stamp
+
+# bki-stamp records the last time we ran genbki.pl. We don't rely on
+# the timestamps of the individual output files, because the Perl script
+# won't update them if they didn't change (to avoid unnecessary recompiles).
+# Technically, this should depend on Makefile.global which supplies
+# $(MAJORVERSION); but then genbki.pl would need to be re-run after every
+# configure run, even in distribution tarballs. So depending on configure.ac
+# instead is cheating a bit, but it will achieve the goal of updating the
+# version number when it changes.
+bki-stamp: $(top_srcdir)/src/backend/catalog/genbki.pl $(top_srcdir)/src/backend/catalog/Catalog.pm $(POSTGRES_BKI_SRCS) $(POSTGRES_BKI_DATA) $(top_srcdir)/configure.ac $(top_srcdir)/src/include/access/transam.h
+ $(PERL) $< --include-path=$(top_srcdir)/src/include/ \
+ --set-version=$(MAJORVERSION) $(POSTGRES_BKI_SRCS)
+ touch $@
+
+install: all installdirs
+ $(INSTALL_DATA) postgres.bki '$(DESTDIR)$(datadir)/postgres.bki'
+ $(INSTALL_DATA) system_constraints.sql '$(DESTDIR)$(datadir)/system_constraints.sql'
+# In non-vpath builds, src/include/Makefile already installs all headers.
+ifeq ($(vpath_build),yes)
+ $(INSTALL_DATA) schemapg.h '$(DESTDIR)$(includedir_server)'/catalog/schemapg.h
+ $(INSTALL_DATA) syscache_ids.h '$(DESTDIR)$(includedir_server)'/catalog/syscache_ids.h
+ $(INSTALL_DATA) system_fk_info.h '$(DESTDIR)$(includedir_server)'/catalog/system_fk_info.h
+ for file in $(GENERATED_HEADERS); do \
+ $(INSTALL_DATA) $$file '$(DESTDIR)$(includedir_server)'/catalog/$$file || exit; \
+ done
+endif
+
+installdirs:
+ $(MKDIR_P) '$(DESTDIR)$(datadir)' '$(DESTDIR)$(includedir_server)'
+
+uninstall:
+ rm -f $(addprefix '$(DESTDIR)$(datadir)'/, postgres.bki system_constraints.sql)
+ rm -f $(addprefix '$(DESTDIR)$(includedir_server)'/catalog/, schemapg.h syscache_ids.h system_fk_info.h $(GENERATED_HEADERS))
+
+clean:
+ rm -f bki-stamp $(GENBKI_OUTPUT_FILES)
+
# 'make reformat-dat-files' is a convenience target for rewriting the
# catalog data files in our standard format. This includes collapsing
# out any entries that are redundant with a BKI_DEFAULT annotation.
diff --git a/src/include/catalog/meson.build b/src/include/catalog/meson.build
index 6b3c56c20e8..f70d1daba52 100644
--- a/src/include/catalog/meson.build
+++ b/src/include/catalog/meson.build
@@ -145,8 +145,7 @@ generated_catalog_headers = custom_target('generated_catalog_headers',
generated_headers += generated_catalog_headers.to_list()
# autoconf generates the file there, ensure we get a conflict
-generated_sources_ac += {'src/backend/catalog': output_files + ['bki-stamp']}
-generated_sources_ac += {'src/include/catalog': ['header-stamp']}
+generated_sources_ac += {'src/include/catalog': output_files + ['bki-stamp']}
# 'reformat-dat-files' is a convenience target for rewriting the
# catalog data files in our standard format. This includes collapsing
diff --git a/src/tools/pginclude/cpluspluscheck b/src/tools/pginclude/cpluspluscheck
index 7edfc44b49a..404c6584b16 100755
--- a/src/tools/pginclude/cpluspluscheck
+++ b/src/tools/pginclude/cpluspluscheck
@@ -119,8 +119,6 @@ do
test "$f" = src/include/common/unicode_nonspacing_table.h && continue
test "$f" = src/include/common/unicode_east_asian_fw_table.h && continue
- test "$f" = src/backend/catalog/syscache_ids.h && continue
- test "$f" = src/backend/catalog/syscache_info.h && continue
test "$f" = src/include/catalog/syscache_ids.h && continue
test "$f" = src/include/catalog/syscache_info.h && continue
diff --git a/src/tools/pginclude/headerscheck b/src/tools/pginclude/headerscheck
index 84b892b5c51..a5299bf459f 100755
--- a/src/tools/pginclude/headerscheck
+++ b/src/tools/pginclude/headerscheck
@@ -114,8 +114,6 @@ do
test "$f" = src/include/common/unicode_nonspacing_table.h && continue
test "$f" = src/include/common/unicode_east_asian_fw_table.h && continue
- test "$f" = src/backend/catalog/syscache_ids.h && continue
- test "$f" = src/backend/catalog/syscache_info.h && continue
test "$f" = src/include/catalog/syscache_ids.h && continue
test "$f" = src/include/catalog/syscache_info.h && continue
base-commit: 25799850867292efecf34da73db4ea1ad1aad573
--
2.43.0
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: Put genbki.pl output into src/include/catalog/ directly
@ 2024-02-08 16:38 Tom Lane <[email protected]>
parent: Peter Eisentraut <[email protected]>
1 sibling, 0 replies; 6+ messages in thread
From: Tom Lane @ 2024-02-08 16:38 UTC (permalink / raw)
To: Peter Eisentraut <[email protected]>; +Cc: pgsql-hackers
Peter Eisentraut <[email protected]> writes:
> With the makefile rules, the output of genbki.pl was written to
> src/backend/catalog/, and then the header files were linked to
> src/include/catalog/.
> This patch changes it so that the output files are written directly to
> src/include/catalog/.
Didn't read the patch, but +1 for concept.
regards, tom lane
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: Put genbki.pl output into src/include/catalog/ directly
@ 2024-03-13 11:41 Andreas Karlsson <[email protected]>
parent: Peter Eisentraut <[email protected]>
1 sibling, 1 reply; 6+ messages in thread
From: Andreas Karlsson @ 2024-03-13 11:41 UTC (permalink / raw)
To: Peter Eisentraut <[email protected]>; pgsql-hackers
On 2/8/24 8:58 AM, Peter Eisentraut wrote:
> I think keeping the two build systems aligned this way will be useful
> for longer-term maintenance.
Agreed, so started reviewing the patch. Attached is a rebased version of
the patch to solve a conflict.
Andreas
Attachments:
[text/x-patch] 0001-Put-genbki.pl-output-into-src-include-catalog-direct.patch (15.0K, ../../[email protected]/2-0001-Put-genbki.pl-output-into-src-include-catalog-direct.patch)
download | inline diff:
From 2069c6d6e2ef2bc37c5af0df12c558ead8a99b15 Mon Sep 17 00:00:00 2001
From: Peter Eisentraut <[email protected]>
Date: Thu, 8 Feb 2024 08:31:21 +0100
Subject: [PATCH] Put genbki.pl output into src/include/catalog/ directly
With the makefile rules, the output of genbki.pl was written to
src/backend/catalog/, and then the header files were linked to
src/include/catalog/.
This changes it so that the output files are written directly to
src/include/catalog/. This makes the logic simpler, and it also makes
the behavior consistent with the meson build system. Also, the list
of catalog files is now kept in parallel in
src/include/catalog/{meson.build,Makefile}, while before the makefiles
had it in src/backend/catalog/Makefile.
---
src/backend/Makefile | 2 +-
src/backend/catalog/.gitignore | 8 --
src/backend/catalog/Makefile | 140 +---------------------------
src/include/Makefile | 7 +-
src/include/catalog/.gitignore | 4 +-
src/include/catalog/Makefile | 152 +++++++++++++++++++++++++++++++
src/include/catalog/meson.build | 3 +-
src/tools/pginclude/headerscheck | 2 -
8 files changed, 163 insertions(+), 155 deletions(-)
delete mode 100644 src/backend/catalog/.gitignore
diff --git a/src/backend/Makefile b/src/backend/Makefile
index d66e2a4b9f..3d7be09529 100644
--- a/src/backend/Makefile
+++ b/src/backend/Makefile
@@ -118,7 +118,7 @@ utils/activity/wait_event_types.h: utils/activity/generate-wait_event_types.pl u
# run this unconditionally to avoid needing to know its dependencies here:
submake-catalog-headers:
- $(MAKE) -C catalog generated-header-symlinks
+ $(MAKE) -C ../include/catalog generated-headers
# run this unconditionally to avoid needing to know its dependencies here:
submake-nodes-headers:
diff --git a/src/backend/catalog/.gitignore b/src/backend/catalog/.gitignore
deleted file mode 100644
index b580f734c7..0000000000
--- a/src/backend/catalog/.gitignore
+++ /dev/null
@@ -1,8 +0,0 @@
-/postgres.bki
-/schemapg.h
-/syscache_ids.h
-/syscache_info.h
-/system_fk_info.h
-/system_constraints.sql
-/pg_*_d.h
-/bki-stamp
diff --git a/src/backend/catalog/Makefile b/src/backend/catalog/Makefile
index 196ecafc90..1589a75fd5 100644
--- a/src/backend/catalog/Makefile
+++ b/src/backend/catalog/Makefile
@@ -50,141 +50,8 @@ OBJS = \
include $(top_srcdir)/src/backend/common.mk
-# Note: the order of this list determines the order in which the catalog
-# header files are assembled into postgres.bki. BKI_BOOTSTRAP catalogs
-# must appear first, and pg_statistic before pg_statistic_ext_data, and
-# there are reputedly other, undocumented ordering dependencies.
-CATALOG_HEADERS := \
- pg_proc.h \
- pg_type.h \
- pg_attribute.h \
- pg_class.h \
- pg_attrdef.h \
- pg_constraint.h \
- pg_inherits.h \
- pg_index.h \
- pg_operator.h \
- pg_opfamily.h \
- pg_opclass.h \
- pg_am.h \
- pg_amop.h \
- pg_amproc.h \
- pg_language.h \
- pg_largeobject_metadata.h \
- pg_largeobject.h \
- pg_aggregate.h \
- pg_statistic.h \
- pg_statistic_ext.h \
- pg_statistic_ext_data.h \
- pg_rewrite.h \
- pg_trigger.h \
- pg_event_trigger.h \
- pg_description.h \
- pg_cast.h \
- pg_enum.h \
- pg_namespace.h \
- pg_conversion.h \
- pg_depend.h \
- pg_database.h \
- pg_db_role_setting.h \
- pg_tablespace.h \
- pg_authid.h \
- pg_auth_members.h \
- pg_shdepend.h \
- pg_shdescription.h \
- pg_ts_config.h \
- pg_ts_config_map.h \
- pg_ts_dict.h \
- pg_ts_parser.h \
- pg_ts_template.h \
- pg_extension.h \
- pg_foreign_data_wrapper.h \
- pg_foreign_server.h \
- pg_user_mapping.h \
- pg_foreign_table.h \
- pg_policy.h \
- pg_replication_origin.h \
- pg_default_acl.h \
- pg_init_privs.h \
- pg_seclabel.h \
- pg_shseclabel.h \
- pg_collation.h \
- pg_parameter_acl.h \
- pg_partitioned_table.h \
- pg_range.h \
- pg_transform.h \
- pg_sequence.h \
- pg_publication.h \
- pg_publication_namespace.h \
- pg_publication_rel.h \
- pg_subscription.h \
- pg_subscription_rel.h
-
-GENERATED_HEADERS := $(CATALOG_HEADERS:%.h=%_d.h) schemapg.h syscache_ids.h syscache_info.h system_fk_info.h
-
-POSTGRES_BKI_SRCS := $(addprefix $(top_srcdir)/src/include/catalog/, $(CATALOG_HEADERS))
-
-# The .dat files we need can just be listed alphabetically.
-POSTGRES_BKI_DATA = $(addprefix $(top_srcdir)/src/include/catalog/,\
- pg_aggregate.dat \
- pg_am.dat \
- pg_amop.dat \
- pg_amproc.dat \
- pg_authid.dat \
- pg_cast.dat \
- pg_class.dat \
- pg_collation.dat \
- pg_conversion.dat \
- pg_database.dat \
- pg_language.dat \
- pg_namespace.dat \
- pg_opclass.dat \
- pg_operator.dat \
- pg_opfamily.dat \
- pg_proc.dat \
- pg_range.dat \
- pg_tablespace.dat \
- pg_ts_config.dat \
- pg_ts_config_map.dat \
- pg_ts_dict.dat \
- pg_ts_parser.dat \
- pg_ts_template.dat \
- pg_type.dat \
- )
-
-all: generated-header-symlinks
-
-.PHONY: generated-header-symlinks
-
-generated-header-symlinks: $(top_builddir)/src/include/catalog/header-stamp
-
-# bki-stamp records the last time we ran genbki.pl. We don't rely on
-# the timestamps of the individual output files, because the Perl script
-# won't update them if they didn't change (to avoid unnecessary recompiles).
-# Technically, this should depend on Makefile.global which supplies
-# $(MAJORVERSION); but then genbki.pl would need to be re-run after every
-# configure run, even in distribution tarballs. So depending on configure.ac
-# instead is cheating a bit, but it will achieve the goal of updating the
-# version number when it changes.
-bki-stamp: genbki.pl Catalog.pm $(POSTGRES_BKI_SRCS) $(POSTGRES_BKI_DATA) $(top_srcdir)/configure.ac $(top_srcdir)/src/include/access/transam.h
- $(PERL) $< --include-path=$(top_srcdir)/src/include/ \
- --set-version=$(MAJORVERSION) $(POSTGRES_BKI_SRCS)
- touch $@
-
-# The generated headers must all be symlinked into src/include/.
-# We use header-stamp to record that we've done this because the symlinks
-# themselves may appear older than bki-stamp.
-$(top_builddir)/src/include/catalog/header-stamp: bki-stamp
- cd '$(dir $@)' && for file in $(GENERATED_HEADERS); do \
- rm -f $$file && $(LN_S) "../../../$(subdir)/$$file" . ; \
- done
- touch $@
-
-# Note: installation of generated headers is handled elsewhere
.PHONY: install-data
-install-data: bki-stamp installdirs
- $(INSTALL_DATA) postgres.bki '$(DESTDIR)$(datadir)/postgres.bki'
- $(INSTALL_DATA) system_constraints.sql '$(DESTDIR)$(datadir)/system_constraints.sql'
+install-data: installdirs
$(INSTALL_DATA) $(srcdir)/system_functions.sql '$(DESTDIR)$(datadir)/system_functions.sql'
$(INSTALL_DATA) $(srcdir)/system_views.sql '$(DESTDIR)$(datadir)/system_views.sql'
$(INSTALL_DATA) $(srcdir)/information_schema.sql '$(DESTDIR)$(datadir)/information_schema.sql'
@@ -195,7 +62,4 @@ installdirs:
.PHONY: uninstall-data
uninstall-data:
- rm -f $(addprefix '$(DESTDIR)$(datadir)'/, postgres.bki system_constraints.sql system_functions.sql system_views.sql information_schema.sql sql_features.txt)
-
-clean:
- rm -f bki-stamp postgres.bki system_constraints.sql $(GENERATED_HEADERS)
+ rm -f $(addprefix '$(DESTDIR)$(datadir)'/, system_functions.sql system_views.sql information_schema.sql sql_features.txt)
diff --git a/src/include/Makefile b/src/include/Makefile
index 584d0300d9..b8b576a4de 100644
--- a/src/include/Makefile
+++ b/src/include/Makefile
@@ -54,10 +54,11 @@ install: all installdirs
$(INSTALL_DATA) $(srcdir)/$$dir/*.h '$(DESTDIR)$(includedir_server)'/$$dir || exit; \
done
ifeq ($(vpath_build),yes)
- for file in catalog/schemapg.h catalog/syscache_ids.h catalog/system_fk_info.h catalog/pg_*_d.h storage/lwlocknames.h utils/probes.h utils/wait_event_types.h; do \
+ for file in storage/lwlocknames.h utils/probes.h utils/wait_event_types.h; do \
$(INSTALL_DATA) $$file '$(DESTDIR)$(includedir_server)'/$$file || exit; \
done
endif
+ $(MAKE) -C catalog install
installdirs:
$(MKDIR_P) '$(DESTDIR)$(includedir)/libpq' '$(DESTDIR)$(includedir_internal)/libpq'
@@ -69,14 +70,14 @@ uninstall:
rm -f $(addprefix '$(DESTDIR)$(includedir_internal)'/, c.h port.h postgres_fe.h libpq/pqcomm.h libpq/protocol.h)
# heuristic...
rm -rf $(addprefix '$(DESTDIR)$(includedir_server)'/, $(SUBDIRS) *.h)
+ $(MAKE) -C catalog uninstall
clean:
rm -f utils/fmgroids.h utils/fmgrprotos.h utils/errcodes.h utils/header-stamp
rm -f storage/lwlocknames.h utils/probes.h utils/wait_event_types.h
- rm -f catalog/schemapg.h catalog/syscache_ids.h catalog/syscache_info.h catalog/system_fk_info.h
- rm -f catalog/pg_*_d.h catalog/header-stamp
rm -f nodes/nodetags.h nodes/header-stamp
+ $(MAKE) -C catalog clean
distclean: clean
rm -f pg_config.h pg_config_ext.h pg_config_os.h stamp-h stamp-ext-h
diff --git a/src/include/catalog/.gitignore b/src/include/catalog/.gitignore
index 983574f2c4..b580f734c7 100644
--- a/src/include/catalog/.gitignore
+++ b/src/include/catalog/.gitignore
@@ -1,6 +1,8 @@
+/postgres.bki
/schemapg.h
/syscache_ids.h
/syscache_info.h
/system_fk_info.h
+/system_constraints.sql
/pg_*_d.h
-/header-stamp
+/bki-stamp
diff --git a/src/include/catalog/Makefile b/src/include/catalog/Makefile
index c2b3cf238d..167f91a6e3 100644
--- a/src/include/catalog/Makefile
+++ b/src/include/catalog/Makefile
@@ -13,6 +13,158 @@ subdir = src/include/catalog
top_builddir = ../../..
include $(top_builddir)/src/Makefile.global
+# Note: the order of this list determines the order in which the catalog
+# header files are assembled into postgres.bki. BKI_BOOTSTRAP catalogs
+# must appear first, and pg_statistic before pg_statistic_ext_data, and
+# there are reputedly other, undocumented ordering dependencies.
+CATALOG_HEADERS := \
+ pg_proc.h \
+ pg_type.h \
+ pg_attribute.h \
+ pg_class.h \
+ pg_attrdef.h \
+ pg_constraint.h \
+ pg_inherits.h \
+ pg_index.h \
+ pg_operator.h \
+ pg_opfamily.h \
+ pg_opclass.h \
+ pg_am.h \
+ pg_amop.h \
+ pg_amproc.h \
+ pg_language.h \
+ pg_largeobject_metadata.h \
+ pg_largeobject.h \
+ pg_aggregate.h \
+ pg_statistic.h \
+ pg_statistic_ext.h \
+ pg_statistic_ext_data.h \
+ pg_rewrite.h \
+ pg_trigger.h \
+ pg_event_trigger.h \
+ pg_description.h \
+ pg_cast.h \
+ pg_enum.h \
+ pg_namespace.h \
+ pg_conversion.h \
+ pg_depend.h \
+ pg_database.h \
+ pg_db_role_setting.h \
+ pg_tablespace.h \
+ pg_authid.h \
+ pg_auth_members.h \
+ pg_shdepend.h \
+ pg_shdescription.h \
+ pg_ts_config.h \
+ pg_ts_config_map.h \
+ pg_ts_dict.h \
+ pg_ts_parser.h \
+ pg_ts_template.h \
+ pg_extension.h \
+ pg_foreign_data_wrapper.h \
+ pg_foreign_server.h \
+ pg_user_mapping.h \
+ pg_foreign_table.h \
+ pg_policy.h \
+ pg_replication_origin.h \
+ pg_default_acl.h \
+ pg_init_privs.h \
+ pg_seclabel.h \
+ pg_shseclabel.h \
+ pg_collation.h \
+ pg_parameter_acl.h \
+ pg_partitioned_table.h \
+ pg_range.h \
+ pg_transform.h \
+ pg_sequence.h \
+ pg_publication.h \
+ pg_publication_namespace.h \
+ pg_publication_rel.h \
+ pg_subscription.h \
+ pg_subscription_rel.h
+
+GENERATED_HEADERS := $(CATALOG_HEADERS:%.h=%_d.h)
+
+POSTGRES_BKI_SRCS := $(addprefix $(top_srcdir)/src/include/catalog/, $(CATALOG_HEADERS))
+
+# The .dat files we need can just be listed alphabetically.
+POSTGRES_BKI_DATA = \
+ pg_aggregate.dat \
+ pg_am.dat \
+ pg_amop.dat \
+ pg_amproc.dat \
+ pg_authid.dat \
+ pg_cast.dat \
+ pg_class.dat \
+ pg_collation.dat \
+ pg_conversion.dat \
+ pg_database.dat \
+ pg_language.dat \
+ pg_namespace.dat \
+ pg_opclass.dat \
+ pg_operator.dat \
+ pg_opfamily.dat \
+ pg_proc.dat \
+ pg_range.dat \
+ pg_tablespace.dat \
+ pg_ts_config.dat \
+ pg_ts_config_map.dat \
+ pg_ts_dict.dat \
+ pg_ts_parser.dat \
+ pg_ts_template.dat \
+ pg_type.dat
+
+GENBKI_OUTPUT_FILES = \
+ $(GENERATED_HEADERS) \
+ postgres.bki \
+ system_constraints.sql \
+ schemapg.h \
+ syscache_ids.h \
+ syscache_info.h \
+ system_fk_info.h
+
+all: generated-headers
+
+.PHONY: generated-headers
+
+generated-headers: bki-stamp
+
+# bki-stamp records the last time we ran genbki.pl. We don't rely on
+# the timestamps of the individual output files, because the Perl script
+# won't update them if they didn't change (to avoid unnecessary recompiles).
+# Technically, this should depend on Makefile.global which supplies
+# $(MAJORVERSION); but then genbki.pl would need to be re-run after every
+# configure run, even in distribution tarballs. So depending on configure.ac
+# instead is cheating a bit, but it will achieve the goal of updating the
+# version number when it changes.
+bki-stamp: $(top_srcdir)/src/backend/catalog/genbki.pl $(top_srcdir)/src/backend/catalog/Catalog.pm $(POSTGRES_BKI_SRCS) $(POSTGRES_BKI_DATA) $(top_srcdir)/configure.ac $(top_srcdir)/src/include/access/transam.h
+ $(PERL) $< --include-path=$(top_srcdir)/src/include/ \
+ --set-version=$(MAJORVERSION) $(POSTGRES_BKI_SRCS)
+ touch $@
+
+install: all installdirs
+ $(INSTALL_DATA) postgres.bki '$(DESTDIR)$(datadir)/postgres.bki'
+ $(INSTALL_DATA) system_constraints.sql '$(DESTDIR)$(datadir)/system_constraints.sql'
+# In non-vpath builds, src/include/Makefile already installs all headers.
+ifeq ($(vpath_build),yes)
+ $(INSTALL_DATA) schemapg.h '$(DESTDIR)$(includedir_server)'/catalog/schemapg.h
+ $(INSTALL_DATA) syscache_ids.h '$(DESTDIR)$(includedir_server)'/catalog/syscache_ids.h
+ $(INSTALL_DATA) system_fk_info.h '$(DESTDIR)$(includedir_server)'/catalog/system_fk_info.h
+ for file in $(GENERATED_HEADERS); do \
+ $(INSTALL_DATA) $$file '$(DESTDIR)$(includedir_server)'/catalog/$$file || exit; \
+ done
+endif
+
+installdirs:
+ $(MKDIR_P) '$(DESTDIR)$(datadir)' '$(DESTDIR)$(includedir_server)'
+
+uninstall:
+ rm -f $(addprefix '$(DESTDIR)$(datadir)'/, postgres.bki system_constraints.sql)
+ rm -f $(addprefix '$(DESTDIR)$(includedir_server)'/catalog/, schemapg.h syscache_ids.h system_fk_info.h $(GENERATED_HEADERS))
+
+clean:
+ rm -f bki-stamp $(GENBKI_OUTPUT_FILES)
+
# 'make reformat-dat-files' is a convenience target for rewriting the
# catalog data files in our standard format. This includes collapsing
# out any entries that are redundant with a BKI_DEFAULT annotation.
diff --git a/src/include/catalog/meson.build b/src/include/catalog/meson.build
index 6b3c56c20e..f70d1daba5 100644
--- a/src/include/catalog/meson.build
+++ b/src/include/catalog/meson.build
@@ -145,8 +145,7 @@ generated_catalog_headers = custom_target('generated_catalog_headers',
generated_headers += generated_catalog_headers.to_list()
# autoconf generates the file there, ensure we get a conflict
-generated_sources_ac += {'src/backend/catalog': output_files + ['bki-stamp']}
-generated_sources_ac += {'src/include/catalog': ['header-stamp']}
+generated_sources_ac += {'src/include/catalog': output_files + ['bki-stamp']}
# 'reformat-dat-files' is a convenience target for rewriting the
# catalog data files in our standard format. This includes collapsing
diff --git a/src/tools/pginclude/headerscheck b/src/tools/pginclude/headerscheck
index 5c12ab99b8..a59be39307 100755
--- a/src/tools/pginclude/headerscheck
+++ b/src/tools/pginclude/headerscheck
@@ -142,8 +142,6 @@ do
test "$f" = src/include/common/unicode_nonspacing_table.h && continue
test "$f" = src/include/common/unicode_east_asian_fw_table.h && continue
- test "$f" = src/backend/catalog/syscache_ids.h && continue
- test "$f" = src/backend/catalog/syscache_info.h && continue
test "$f" = src/include/catalog/syscache_ids.h && continue
test "$f" = src/include/catalog/syscache_info.h && continue
--
2.43.0
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: Put genbki.pl output into src/include/catalog/ directly
@ 2024-03-14 01:33 Andreas Karlsson <[email protected]>
parent: Andreas Karlsson <[email protected]>
0 siblings, 1 reply; 6+ messages in thread
From: Andreas Karlsson @ 2024-03-14 01:33 UTC (permalink / raw)
To: Peter Eisentraut <[email protected]>; pgsql-hackers
On 3/13/24 12:41 PM, Andreas Karlsson wrote:
> On 2/8/24 8:58 AM, Peter Eisentraut wrote:
>> I think keeping the two build systems aligned this way will be useful
>> for longer-term maintenance.
>
> Agreed, so started reviewing the patch. Attached is a rebased version of
> the patch to solve a conflict.
I have reviewed the patch now and would say it looks good. I like how we
remove the symlinks plus make things more similar to the meson build so
I think we should merge this.
I tried building, running tests, running make clean, running make
install and tried building with meson (plus checking that meson really
checks for the generated files and actually refuse to build). Everything
worked as expected.
The code changes look clean and mostly consist of moving code. I
personally think this is ready for committer.
Andreas
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: Put genbki.pl output into src/include/catalog/ directly
@ 2024-03-14 06:27 Peter Eisentraut <[email protected]>
parent: Andreas Karlsson <[email protected]>
0 siblings, 0 replies; 6+ messages in thread
From: Peter Eisentraut @ 2024-03-14 06:27 UTC (permalink / raw)
To: Andreas Karlsson <[email protected]>; pgsql-hackers
On 14.03.24 02:33, Andreas Karlsson wrote:
> On 3/13/24 12:41 PM, Andreas Karlsson wrote:
>> On 2/8/24 8:58 AM, Peter Eisentraut wrote:
>>> I think keeping the two build systems aligned this way will be useful
>>> for longer-term maintenance.
>>
>> Agreed, so started reviewing the patch. Attached is a rebased version
>> of the patch to solve a conflict.
>
> I have reviewed the patch now and would say it looks good. I like how we
> remove the symlinks plus make things more similar to the meson build so
> I think we should merge this.
>
> I tried building, running tests, running make clean, running make
> install and tried building with meson (plus checking that meson really
> checks for the generated files and actually refuse to build). Everything
> worked as expected.
>
> The code changes look clean and mostly consist of moving code. I
> personally think this is ready for committer.
Committed, thanks.
^ permalink raw reply [nested|flat] 6+ messages in thread
end of thread, other threads:[~2024-03-14 06:27 UTC | newest]
Thread overview: 6+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2020-08-19 12:34 [PATCH v2 3/5] pg_rewind: Replace the hybrid list+array data structure with simplehash. Heikki Linnakangas <[email protected]>
2024-02-08 07:58 Put genbki.pl output into src/include/catalog/ directly Peter Eisentraut <[email protected]>
2024-02-08 16:38 ` Re: Put genbki.pl output into src/include/catalog/ directly Tom Lane <[email protected]>
2024-03-13 11:41 ` Re: Put genbki.pl output into src/include/catalog/ directly Andreas Karlsson <[email protected]>
2024-03-14 01:33 ` Re: Put genbki.pl output into src/include/catalog/ directly Andreas Karlsson <[email protected]>
2024-03-14 06:27 ` Re: Put genbki.pl output into src/include/catalog/ directly Peter Eisentraut <[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