#include <sys/stat.h>
#include <unistd.h>
-#include "common/hashfn.h"
+#include "common/hashfn_unstable.h"
#include "common/logging.h"
#include "common/parse_manifest.h"
#include "load_manifest.h"
* Define a hash table which we can use to store information about the files
* mentioned in the backup manifest.
*/
-static uint32 hash_string_pointer(char *s);
#define SH_PREFIX manifest_files
#define SH_ELEMENT_TYPE manifest_file
#define SH_KEY_TYPE char *
#define SH_KEY pathname
-#define SH_HASH_KEY(tb, key) hash_string_pointer(key)
+#define SH_HASH_KEY(tb, key) hash_string(key)
#define SH_EQUAL(tb, a, b) (strcmp(a, b) == 0)
#define SH_SCOPE extern
#define SH_RAW_ALLOCATOR pg_malloc0
manifest->last_wal_range->next = range;
manifest->last_wal_range = range;
}
-
-/*
- * Helper function for manifest_files hash table.
- */
-static uint32
-hash_string_pointer(char *s)
-{
- unsigned char *ss = (unsigned char *) s;
-
- return hash_bytes(ss, strlen(s));
-}
#include "catalog/pg_authid_d.h"
#include "common/connect.h"
#include "common/file_utils.h"
-#include "common/hashfn.h"
+#include "common/hashfn_unstable.h"
#include "common/logging.h"
#include "common/string.h"
#include "dumputils.h"
/* version string we expect back from pg_dump */
#define PGDUMP_VERSIONSTR "pg_dump (PostgreSQL) " PG_VERSION "\n"
-static uint32 hash_string_pointer(char *s);
-
typedef struct
{
uint32 status;
#define SH_ELEMENT_TYPE RoleNameEntry
#define SH_KEY_TYPE char *
#define SH_KEY rolename
-#define SH_HASH_KEY(tb, key) hash_string_pointer(key)
+#define SH_HASH_KEY(tb, key) hash_string(key)
#define SH_EQUAL(tb, a, b) (strcmp(a, b) == 0)
#define SH_STORE_HASH
#define SH_GET_HASH(tb, a) (a)->hashval
fprintf(OPF, "-- %s %s\n\n", msg, buf);
}
-/*
- * Helper function for rolename_hash hash table.
- */
-static uint32
-hash_string_pointer(char *s)
-{
- unsigned char *ss = (unsigned char *) s;
-
- return hash_bytes(ss, strlen(s));
-}
-
/*
* read_dumpall_filters - retrieve database identifier patterns from file
*
#include "catalog/pg_tablespace_d.h"
#include "common/file_utils.h"
-#include "common/hashfn.h"
+#include "common/hashfn_unstable.h"
#include "common/string.h"
#include "datapagemap.h"
#include "filemap.h"
* Define a hash table which we can use to store information about the files
* appearing in source and target systems.
*/
-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_HASH_KEY(tb, key) hash_string(key)
#define SH_EQUAL(tb, a, b) (strcmp(a, b) == 0)
#define SH_SCOPE static inline
#define SH_RAW_ALLOCATOR pg_malloc0
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));
-}
#include <time.h>
#include "common/controldata_utils.h"
-#include "common/hashfn.h"
+#include "common/hashfn_unstable.h"
#include "common/logging.h"
#include "common/parse_manifest.h"
#include "fe_utils/simple_list.h"
* Define a hash table which we can use to store information about the files
* mentioned in the backup manifest.
*/
-static uint32 hash_string_pointer(char *s);
#define SH_PREFIX manifest_files
#define SH_ELEMENT_TYPE manifest_file
#define SH_KEY_TYPE char *
#define SH_KEY pathname
-#define SH_HASH_KEY(tb, key) hash_string_pointer(key)
+#define SH_HASH_KEY(tb, key) hash_string(key)
#define SH_EQUAL(tb, a, b) (strcmp(a, b) == 0)
#define SH_SCOPE static inline
#define SH_RAW_ALLOCATOR pg_malloc0
return false;
}
-/*
- * Helper function for manifest_files hash table.
- */
-static uint32
-hash_string_pointer(char *s)
-{
- unsigned char *ss = (unsigned char *) s;
-
- return hash_bytes(ss, strlen(s));
-}
-
/*
* Print a progress report based on the global variables.
*
return fasthash_reduce32(fasthash64(k, len, seed));
}
+/*
+ * Convenience function for hashing NUL-terminated strings
+ */
+static inline uint32
+hash_string(const char *s)
+{
+ fasthash_state hs;
+ size_t s_len;
+
+ fasthash_init(&hs, 0);
+
+ /*
+ * Combine string into the hash and save the length for tweaking the final
+ * mix.
+ */
+ s_len = fasthash_accum_cstring(&hs, s);
+
+ return fasthash_final32(&hs, s_len);
+}
+
#endif /* HASHFN_UNSTABLE_H */