public inbox for [email protected]  
help / color / mirror / Atom feed
[PATCH] hex squash commit
27+ messages / 4 participants
[nested] [flat]

* [PATCH] hex squash commit
@ 2021-01-01 20:04 Bruce Momjian <[email protected]>
  0 siblings, 0 replies; 27+ messages in thread

From: Bruce Momjian @ 2021-01-01 20:04 UTC (permalink / raw)

---
 src/backend/replication/backup_manifest.c |  2 +-
 src/backend/utils/adt/encode.c            | 34 +------------------
 src/backend/utils/adt/varlena.c           |  2 +-
 src/common/Makefile                       |  2 +-
 src/common/{hex_decode.c => hex.c}        | 40 ++++++++++++++++++++---
 src/include/common/hex.h (new)            | 18 ++++++++++
 src/include/common/hex_decode.h (gone)    | 16 ---------
 src/include/utils/builtins.h              |  3 --
 src/tools/msvc/Mkvcbuild.pm               |  2 +-
 9 files changed, 59 insertions(+), 60 deletions(-)

diff --git a/src/backend/replication/backup_manifest.c b/src/backend/replication/backup_manifest.c
index c3f339c556..716f114d78 100644
--- a/src/backend/replication/backup_manifest.c
+++ b/src/backend/replication/backup_manifest.c
@@ -17,7 +17,7 @@
 #include "libpq/pqformat.h"
 #include "mb/pg_wchar.h"
 #include "replication/backup_manifest.h"
-#include "utils/builtins.h"
+#include "common/hex.h"
 #include "utils/json.h"
 
 static void AppendStringToManifest(backup_manifest_info *manifest, char *s);
diff --git a/src/backend/utils/adt/encode.c b/src/backend/utils/adt/encode.c
index a6c65b1657..bca941a496 100644
--- a/src/backend/utils/adt/encode.c
+++ b/src/backend/utils/adt/encode.c
@@ -15,7 +15,7 @@
 
 #include <ctype.h>
 
-#include "common/hex_decode.h"
+#include "common/hex.h"
 #include "mb/pg_wchar.h"
 #include "utils/builtins.h"
 #include "utils/memutils.h"
@@ -141,38 +141,6 @@ binary_decode(PG_FUNCTION_ARGS)
 }
 
 
-/*
- * HEX
- */
-
-static const char hextbl[] = "0123456789abcdef";
-
-uint64
-hex_encode(const char *src, size_t len, char *dst)
-{
-	const char *end = src + len;
-
-	while (src < end)
-	{
-		*dst++ = hextbl[(*src >> 4) & 0xF];
-		*dst++ = hextbl[*src & 0xF];
-		src++;
-	}
-	return (uint64) len * 2;
-}
-
-static uint64
-hex_enc_len(const char *src, size_t srclen)
-{
-	return (uint64) srclen << 1;
-}
-
-static uint64
-hex_dec_len(const char *src, size_t srclen)
-{
-	return (uint64) srclen >> 1;
-}
-
 /*
  * BASE64
  */
diff --git a/src/backend/utils/adt/varlena.c b/src/backend/utils/adt/varlena.c
index 9300d19e0c..79fcdcd178 100644
--- a/src/backend/utils/adt/varlena.c
+++ b/src/backend/utils/adt/varlena.c
@@ -22,7 +22,7 @@
 #include "catalog/pg_type.h"
 #include "common/hashfn.h"
 #include "common/int.h"
-#include "common/hex_decode.h"
+#include "common/hex.h"
 #include "common/unicode_norm.h"
 #include "lib/hyperloglog.h"
 #include "libpq/pqformat.h"
diff --git a/src/common/Makefile b/src/common/Makefile
index f624977939..93eb27a2aa 100644
--- a/src/common/Makefile
+++ b/src/common/Makefile
@@ -58,7 +58,7 @@ OBJS_COMMON = \
 	file_perm.o \
 	file_utils.o \
 	hashfn.o \
-	hex_decode.o \
+	hex.o \
 	ip.o \
 	jsonapi.o \
 	keywords.o \
diff --git a/src/common/hex_decode.c b/src/common/hex.c
similarity index 79%
rename from src/common/hex_decode.c
rename to src/common/hex.c
index 3ecdc73b5c..97f57bcc32 100644
--- a/src/common/hex_decode.c
+++ b/src/common/hex.c
@@ -1,7 +1,7 @@
 /*-------------------------------------------------------------------------
  *
- * hex_decode.c
- *		hex decoding
+ * hex.c
+ *		hex processing
  *
  *
  * Portions Copyright (c) 1996-2020, PostgreSQL Global Development Group
@@ -9,7 +9,7 @@
  *
  *
  * IDENTIFICATION
- *	  src/common/hex_decode.c
+ *	  src/common/hex.c
  *
  *-------------------------------------------------------------------------
  */
@@ -26,7 +26,7 @@
 #else
 #include "mb/pg_wchar.h"
 #endif
-#include "common/hex_decode.h"
+#include "common/hex.h"
 
 
 static const int8 hexlookup[128] = {
@@ -40,6 +40,26 @@ static const int8 hexlookup[128] = {
 	-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
 };
 
+/*
+ * HEX
+ */
+
+static const char hextbl[] = "0123456789abcdef";
+
+uint64
+hex_encode(const char *src, size_t len, char *dst)
+{
+	const char *end = src + len;
+
+	while (src < end)
+	{
+		*dst++ = hextbl[(*src >> 4) & 0xF];
+		*dst++ = hextbl[*src & 0xF];
+		src++;
+	}
+	return (uint64) len * 2;
+}
+
 static inline char
 get_hex(const char *cp)
 {
@@ -104,3 +124,15 @@ hex_decode(const char *src, size_t len, char *dst)
 
 	return p - dst;
 }
+
+uint64
+hex_enc_len(const char *src, size_t srclen)
+{
+	return (uint64) srclen << 1;
+}
+
+uint64
+hex_dec_len(const char *src, size_t srclen)
+{
+	return (uint64) srclen >> 1;
+}
diff --git a/src/include/common/hex.h b/src/include/common/hex.h
new file mode 100644
index 0000000000..76154b65af
--- /dev/null
+++ b/src/include/common/hex.h
@@ -0,0 +1,18 @@
+/*
+ *	hex.h
+ *		hex processing
+ *
+ *	Portions Copyright (c) 1996-2020, PostgreSQL Global Development Group
+ *	Portions Copyright (c) 1994, Regents of the University of California
+ *
+ *	src/include/common/hex.h
+ */
+#ifndef COMMON_HEX_H
+#define COMMON_HEX_H
+
+extern uint64 hex_decode(const char *src, size_t len, char *dst);
+extern uint64 hex_encode(const char *src, size_t len, char *dst);
+extern uint64 hex_enc_len(const char *src, size_t srclen);
+extern uint64 hex_dec_len(const char *src, size_t srclen);
+
+#endif							/* COMMON_HEX_H */
diff --git a/src/include/common/hex_decode.h b/src/include/common/hex_decode.h
deleted file mode 100644
index 1f99f069b2..0000000000
--- a/src/include/common/hex_decode.h
+++ /dev/null
@@ -1,16 +0,0 @@
-/*
- *	hex_decode.h
- *		hex decoding
- *
- *	Portions Copyright (c) 1996-2020, PostgreSQL Global Development Group
- *	Portions Copyright (c) 1994, Regents of the University of California
- *
- *	src/include/common/hex_decode.h
- */
-#ifndef COMMON_HEX_DECODE_H
-#define COMMON_HEX_DECODE_H
-
-extern uint64 hex_decode(const char *src, size_t len, char *dst);
-
-
-#endif							/* COMMON_HEX_DECODE_H */
diff --git a/src/include/utils/builtins.h b/src/include/utils/builtins.h
index 19271e0696..11ba6ae565 100644
--- a/src/include/utils/builtins.h
+++ b/src/include/utils/builtins.h
@@ -31,9 +31,6 @@ extern void domain_check(Datum value, bool isnull, Oid domainType,
 extern int	errdatatype(Oid datatypeOid);
 extern int	errdomainconstraint(Oid datatypeOid, const char *conname);
 
-/* encode.c */
-extern uint64 hex_encode(const char *src, size_t len, char *dst);
-
 /* int.c */
 extern int2vector *buildint2vector(const int16 *int2s, int n);
 
diff --git a/src/tools/msvc/Mkvcbuild.pm b/src/tools/msvc/Mkvcbuild.pm
index 7f014a12c9..60b216cce0 100644
--- a/src/tools/msvc/Mkvcbuild.pm
+++ b/src/tools/msvc/Mkvcbuild.pm
@@ -121,7 +121,7 @@ sub mkvcbuild
 	our @pgcommonallfiles = qw(
 	  archive.c base64.c checksum_helper.c
 	  config_info.c controldata_utils.c d2s.c encnames.c exec.c
-	  f2s.c file_perm.c file_utils.c hashfn.c hex_decode.c ip.c jsonapi.c
+	  f2s.c file_perm.c file_utils.c hashfn.c hex.c ip.c jsonapi.c
 	  keywords.c kwlookup.c link-canary.c md5_common.c
 	  pg_get_line.c pg_lzcompress.c pgfnames.c psprintf.c relpath.c rmtree.c
 	  saslprep.c scram-common.c string.c stringinfo.c unicode_norm.c username.c
-- 
2.20.1


--IJpNTDwzlM2Ie8A6--





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

* [PATCH] hex squash commit
@ 2021-01-01 20:04 Bruce Momjian <[email protected]>
  0 siblings, 0 replies; 27+ messages in thread

From: Bruce Momjian @ 2021-01-01 20:04 UTC (permalink / raw)

---
 src/backend/replication/backup_manifest.c |  2 +-
 src/backend/utils/adt/encode.c            | 34 +------------------
 src/backend/utils/adt/varlena.c           |  2 +-
 src/common/Makefile                       |  2 +-
 src/common/{hex_decode.c => hex.c}        | 40 ++++++++++++++++++++---
 src/include/common/hex.h (new)            | 18 ++++++++++
 src/include/common/hex_decode.h (gone)    | 16 ---------
 src/include/utils/builtins.h              |  3 --
 src/tools/msvc/Mkvcbuild.pm               |  2 +-
 9 files changed, 59 insertions(+), 60 deletions(-)

diff --git a/src/backend/replication/backup_manifest.c b/src/backend/replication/backup_manifest.c
index c3f339c556..716f114d78 100644
--- a/src/backend/replication/backup_manifest.c
+++ b/src/backend/replication/backup_manifest.c
@@ -17,7 +17,7 @@
 #include "libpq/pqformat.h"
 #include "mb/pg_wchar.h"
 #include "replication/backup_manifest.h"
-#include "utils/builtins.h"
+#include "common/hex.h"
 #include "utils/json.h"
 
 static void AppendStringToManifest(backup_manifest_info *manifest, char *s);
diff --git a/src/backend/utils/adt/encode.c b/src/backend/utils/adt/encode.c
index a6c65b1657..bca941a496 100644
--- a/src/backend/utils/adt/encode.c
+++ b/src/backend/utils/adt/encode.c
@@ -15,7 +15,7 @@
 
 #include <ctype.h>
 
-#include "common/hex_decode.h"
+#include "common/hex.h"
 #include "mb/pg_wchar.h"
 #include "utils/builtins.h"
 #include "utils/memutils.h"
@@ -141,38 +141,6 @@ binary_decode(PG_FUNCTION_ARGS)
 }
 
 
-/*
- * HEX
- */
-
-static const char hextbl[] = "0123456789abcdef";
-
-uint64
-hex_encode(const char *src, size_t len, char *dst)
-{
-	const char *end = src + len;
-
-	while (src < end)
-	{
-		*dst++ = hextbl[(*src >> 4) & 0xF];
-		*dst++ = hextbl[*src & 0xF];
-		src++;
-	}
-	return (uint64) len * 2;
-}
-
-static uint64
-hex_enc_len(const char *src, size_t srclen)
-{
-	return (uint64) srclen << 1;
-}
-
-static uint64
-hex_dec_len(const char *src, size_t srclen)
-{
-	return (uint64) srclen >> 1;
-}
-
 /*
  * BASE64
  */
diff --git a/src/backend/utils/adt/varlena.c b/src/backend/utils/adt/varlena.c
index 9300d19e0c..79fcdcd178 100644
--- a/src/backend/utils/adt/varlena.c
+++ b/src/backend/utils/adt/varlena.c
@@ -22,7 +22,7 @@
 #include "catalog/pg_type.h"
 #include "common/hashfn.h"
 #include "common/int.h"
-#include "common/hex_decode.h"
+#include "common/hex.h"
 #include "common/unicode_norm.h"
 #include "lib/hyperloglog.h"
 #include "libpq/pqformat.h"
diff --git a/src/common/Makefile b/src/common/Makefile
index f624977939..93eb27a2aa 100644
--- a/src/common/Makefile
+++ b/src/common/Makefile
@@ -58,7 +58,7 @@ OBJS_COMMON = \
 	file_perm.o \
 	file_utils.o \
 	hashfn.o \
-	hex_decode.o \
+	hex.o \
 	ip.o \
 	jsonapi.o \
 	keywords.o \
diff --git a/src/common/hex_decode.c b/src/common/hex.c
similarity index 79%
rename from src/common/hex_decode.c
rename to src/common/hex.c
index 3ecdc73b5c..97f57bcc32 100644
--- a/src/common/hex_decode.c
+++ b/src/common/hex.c
@@ -1,7 +1,7 @@
 /*-------------------------------------------------------------------------
  *
- * hex_decode.c
- *		hex decoding
+ * hex.c
+ *		hex processing
  *
  *
  * Portions Copyright (c) 1996-2020, PostgreSQL Global Development Group
@@ -9,7 +9,7 @@
  *
  *
  * IDENTIFICATION
- *	  src/common/hex_decode.c
+ *	  src/common/hex.c
  *
  *-------------------------------------------------------------------------
  */
@@ -26,7 +26,7 @@
 #else
 #include "mb/pg_wchar.h"
 #endif
-#include "common/hex_decode.h"
+#include "common/hex.h"
 
 
 static const int8 hexlookup[128] = {
@@ -40,6 +40,26 @@ static const int8 hexlookup[128] = {
 	-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
 };
 
+/*
+ * HEX
+ */
+
+static const char hextbl[] = "0123456789abcdef";
+
+uint64
+hex_encode(const char *src, size_t len, char *dst)
+{
+	const char *end = src + len;
+
+	while (src < end)
+	{
+		*dst++ = hextbl[(*src >> 4) & 0xF];
+		*dst++ = hextbl[*src & 0xF];
+		src++;
+	}
+	return (uint64) len * 2;
+}
+
 static inline char
 get_hex(const char *cp)
 {
@@ -104,3 +124,15 @@ hex_decode(const char *src, size_t len, char *dst)
 
 	return p - dst;
 }
+
+uint64
+hex_enc_len(const char *src, size_t srclen)
+{
+	return (uint64) srclen << 1;
+}
+
+uint64
+hex_dec_len(const char *src, size_t srclen)
+{
+	return (uint64) srclen >> 1;
+}
diff --git a/src/include/common/hex.h b/src/include/common/hex.h
new file mode 100644
index 0000000000..76154b65af
--- /dev/null
+++ b/src/include/common/hex.h
@@ -0,0 +1,18 @@
+/*
+ *	hex.h
+ *		hex processing
+ *
+ *	Portions Copyright (c) 1996-2020, PostgreSQL Global Development Group
+ *	Portions Copyright (c) 1994, Regents of the University of California
+ *
+ *	src/include/common/hex.h
+ */
+#ifndef COMMON_HEX_H
+#define COMMON_HEX_H
+
+extern uint64 hex_decode(const char *src, size_t len, char *dst);
+extern uint64 hex_encode(const char *src, size_t len, char *dst);
+extern uint64 hex_enc_len(const char *src, size_t srclen);
+extern uint64 hex_dec_len(const char *src, size_t srclen);
+
+#endif							/* COMMON_HEX_H */
diff --git a/src/include/common/hex_decode.h b/src/include/common/hex_decode.h
deleted file mode 100644
index 1f99f069b2..0000000000
--- a/src/include/common/hex_decode.h
+++ /dev/null
@@ -1,16 +0,0 @@
-/*
- *	hex_decode.h
- *		hex decoding
- *
- *	Portions Copyright (c) 1996-2020, PostgreSQL Global Development Group
- *	Portions Copyright (c) 1994, Regents of the University of California
- *
- *	src/include/common/hex_decode.h
- */
-#ifndef COMMON_HEX_DECODE_H
-#define COMMON_HEX_DECODE_H
-
-extern uint64 hex_decode(const char *src, size_t len, char *dst);
-
-
-#endif							/* COMMON_HEX_DECODE_H */
diff --git a/src/include/utils/builtins.h b/src/include/utils/builtins.h
index 19271e0696..11ba6ae565 100644
--- a/src/include/utils/builtins.h
+++ b/src/include/utils/builtins.h
@@ -31,9 +31,6 @@ extern void domain_check(Datum value, bool isnull, Oid domainType,
 extern int	errdatatype(Oid datatypeOid);
 extern int	errdomainconstraint(Oid datatypeOid, const char *conname);
 
-/* encode.c */
-extern uint64 hex_encode(const char *src, size_t len, char *dst);
-
 /* int.c */
 extern int2vector *buildint2vector(const int16 *int2s, int n);
 
diff --git a/src/tools/msvc/Mkvcbuild.pm b/src/tools/msvc/Mkvcbuild.pm
index 7f014a12c9..60b216cce0 100644
--- a/src/tools/msvc/Mkvcbuild.pm
+++ b/src/tools/msvc/Mkvcbuild.pm
@@ -121,7 +121,7 @@ sub mkvcbuild
 	our @pgcommonallfiles = qw(
 	  archive.c base64.c checksum_helper.c
 	  config_info.c controldata_utils.c d2s.c encnames.c exec.c
-	  f2s.c file_perm.c file_utils.c hashfn.c hex_decode.c ip.c jsonapi.c
+	  f2s.c file_perm.c file_utils.c hashfn.c hex.c ip.c jsonapi.c
 	  keywords.c kwlookup.c link-canary.c md5_common.c
 	  pg_get_line.c pg_lzcompress.c pgfnames.c psprintf.c relpath.c rmtree.c
 	  saslprep.c scram-common.c string.c stringinfo.c unicode_norm.c username.c
-- 
2.20.1


--IJpNTDwzlM2Ie8A6--





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

* [PATCH] hex squash commit
@ 2021-01-01 20:04 Bruce Momjian <[email protected]>
  0 siblings, 0 replies; 27+ messages in thread

From: Bruce Momjian @ 2021-01-01 20:04 UTC (permalink / raw)

---
 src/backend/replication/backup_manifest.c |  2 +-
 src/backend/utils/adt/encode.c            | 34 +------------------
 src/backend/utils/adt/varlena.c           |  2 +-
 src/common/Makefile                       |  2 +-
 src/common/{hex_decode.c => hex.c}        | 40 ++++++++++++++++++++---
 src/include/common/hex.h (new)            | 18 ++++++++++
 src/include/common/hex_decode.h (gone)    | 16 ---------
 src/include/utils/builtins.h              |  3 --
 src/tools/msvc/Mkvcbuild.pm               |  2 +-
 9 files changed, 59 insertions(+), 60 deletions(-)

diff --git a/src/backend/replication/backup_manifest.c b/src/backend/replication/backup_manifest.c
index c3f339c556..716f114d78 100644
--- a/src/backend/replication/backup_manifest.c
+++ b/src/backend/replication/backup_manifest.c
@@ -17,7 +17,7 @@
 #include "libpq/pqformat.h"
 #include "mb/pg_wchar.h"
 #include "replication/backup_manifest.h"
-#include "utils/builtins.h"
+#include "common/hex.h"
 #include "utils/json.h"
 
 static void AppendStringToManifest(backup_manifest_info *manifest, char *s);
diff --git a/src/backend/utils/adt/encode.c b/src/backend/utils/adt/encode.c
index a6c65b1657..bca941a496 100644
--- a/src/backend/utils/adt/encode.c
+++ b/src/backend/utils/adt/encode.c
@@ -15,7 +15,7 @@
 
 #include <ctype.h>
 
-#include "common/hex_decode.h"
+#include "common/hex.h"
 #include "mb/pg_wchar.h"
 #include "utils/builtins.h"
 #include "utils/memutils.h"
@@ -141,38 +141,6 @@ binary_decode(PG_FUNCTION_ARGS)
 }
 
 
-/*
- * HEX
- */
-
-static const char hextbl[] = "0123456789abcdef";
-
-uint64
-hex_encode(const char *src, size_t len, char *dst)
-{
-	const char *end = src + len;
-
-	while (src < end)
-	{
-		*dst++ = hextbl[(*src >> 4) & 0xF];
-		*dst++ = hextbl[*src & 0xF];
-		src++;
-	}
-	return (uint64) len * 2;
-}
-
-static uint64
-hex_enc_len(const char *src, size_t srclen)
-{
-	return (uint64) srclen << 1;
-}
-
-static uint64
-hex_dec_len(const char *src, size_t srclen)
-{
-	return (uint64) srclen >> 1;
-}
-
 /*
  * BASE64
  */
diff --git a/src/backend/utils/adt/varlena.c b/src/backend/utils/adt/varlena.c
index 9300d19e0c..79fcdcd178 100644
--- a/src/backend/utils/adt/varlena.c
+++ b/src/backend/utils/adt/varlena.c
@@ -22,7 +22,7 @@
 #include "catalog/pg_type.h"
 #include "common/hashfn.h"
 #include "common/int.h"
-#include "common/hex_decode.h"
+#include "common/hex.h"
 #include "common/unicode_norm.h"
 #include "lib/hyperloglog.h"
 #include "libpq/pqformat.h"
diff --git a/src/common/Makefile b/src/common/Makefile
index f624977939..93eb27a2aa 100644
--- a/src/common/Makefile
+++ b/src/common/Makefile
@@ -58,7 +58,7 @@ OBJS_COMMON = \
 	file_perm.o \
 	file_utils.o \
 	hashfn.o \
-	hex_decode.o \
+	hex.o \
 	ip.o \
 	jsonapi.o \
 	keywords.o \
diff --git a/src/common/hex_decode.c b/src/common/hex.c
similarity index 79%
rename from src/common/hex_decode.c
rename to src/common/hex.c
index 3ecdc73b5c..97f57bcc32 100644
--- a/src/common/hex_decode.c
+++ b/src/common/hex.c
@@ -1,7 +1,7 @@
 /*-------------------------------------------------------------------------
  *
- * hex_decode.c
- *		hex decoding
+ * hex.c
+ *		hex processing
  *
  *
  * Portions Copyright (c) 1996-2020, PostgreSQL Global Development Group
@@ -9,7 +9,7 @@
  *
  *
  * IDENTIFICATION
- *	  src/common/hex_decode.c
+ *	  src/common/hex.c
  *
  *-------------------------------------------------------------------------
  */
@@ -26,7 +26,7 @@
 #else
 #include "mb/pg_wchar.h"
 #endif
-#include "common/hex_decode.h"
+#include "common/hex.h"
 
 
 static const int8 hexlookup[128] = {
@@ -40,6 +40,26 @@ static const int8 hexlookup[128] = {
 	-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
 };
 
+/*
+ * HEX
+ */
+
+static const char hextbl[] = "0123456789abcdef";
+
+uint64
+hex_encode(const char *src, size_t len, char *dst)
+{
+	const char *end = src + len;
+
+	while (src < end)
+	{
+		*dst++ = hextbl[(*src >> 4) & 0xF];
+		*dst++ = hextbl[*src & 0xF];
+		src++;
+	}
+	return (uint64) len * 2;
+}
+
 static inline char
 get_hex(const char *cp)
 {
@@ -104,3 +124,15 @@ hex_decode(const char *src, size_t len, char *dst)
 
 	return p - dst;
 }
+
+uint64
+hex_enc_len(const char *src, size_t srclen)
+{
+	return (uint64) srclen << 1;
+}
+
+uint64
+hex_dec_len(const char *src, size_t srclen)
+{
+	return (uint64) srclen >> 1;
+}
diff --git a/src/include/common/hex.h b/src/include/common/hex.h
new file mode 100644
index 0000000000..76154b65af
--- /dev/null
+++ b/src/include/common/hex.h
@@ -0,0 +1,18 @@
+/*
+ *	hex.h
+ *		hex processing
+ *
+ *	Portions Copyright (c) 1996-2020, PostgreSQL Global Development Group
+ *	Portions Copyright (c) 1994, Regents of the University of California
+ *
+ *	src/include/common/hex.h
+ */
+#ifndef COMMON_HEX_H
+#define COMMON_HEX_H
+
+extern uint64 hex_decode(const char *src, size_t len, char *dst);
+extern uint64 hex_encode(const char *src, size_t len, char *dst);
+extern uint64 hex_enc_len(const char *src, size_t srclen);
+extern uint64 hex_dec_len(const char *src, size_t srclen);
+
+#endif							/* COMMON_HEX_H */
diff --git a/src/include/common/hex_decode.h b/src/include/common/hex_decode.h
deleted file mode 100644
index 1f99f069b2..0000000000
--- a/src/include/common/hex_decode.h
+++ /dev/null
@@ -1,16 +0,0 @@
-/*
- *	hex_decode.h
- *		hex decoding
- *
- *	Portions Copyright (c) 1996-2020, PostgreSQL Global Development Group
- *	Portions Copyright (c) 1994, Regents of the University of California
- *
- *	src/include/common/hex_decode.h
- */
-#ifndef COMMON_HEX_DECODE_H
-#define COMMON_HEX_DECODE_H
-
-extern uint64 hex_decode(const char *src, size_t len, char *dst);
-
-
-#endif							/* COMMON_HEX_DECODE_H */
diff --git a/src/include/utils/builtins.h b/src/include/utils/builtins.h
index 19271e0696..11ba6ae565 100644
--- a/src/include/utils/builtins.h
+++ b/src/include/utils/builtins.h
@@ -31,9 +31,6 @@ extern void domain_check(Datum value, bool isnull, Oid domainType,
 extern int	errdatatype(Oid datatypeOid);
 extern int	errdomainconstraint(Oid datatypeOid, const char *conname);
 
-/* encode.c */
-extern uint64 hex_encode(const char *src, size_t len, char *dst);
-
 /* int.c */
 extern int2vector *buildint2vector(const int16 *int2s, int n);
 
diff --git a/src/tools/msvc/Mkvcbuild.pm b/src/tools/msvc/Mkvcbuild.pm
index 7f014a12c9..60b216cce0 100644
--- a/src/tools/msvc/Mkvcbuild.pm
+++ b/src/tools/msvc/Mkvcbuild.pm
@@ -121,7 +121,7 @@ sub mkvcbuild
 	our @pgcommonallfiles = qw(
 	  archive.c base64.c checksum_helper.c
 	  config_info.c controldata_utils.c d2s.c encnames.c exec.c
-	  f2s.c file_perm.c file_utils.c hashfn.c hex_decode.c ip.c jsonapi.c
+	  f2s.c file_perm.c file_utils.c hashfn.c hex.c ip.c jsonapi.c
 	  keywords.c kwlookup.c link-canary.c md5_common.c
 	  pg_get_line.c pg_lzcompress.c pgfnames.c psprintf.c relpath.c rmtree.c
 	  saslprep.c scram-common.c string.c stringinfo.c unicode_norm.c username.c
-- 
2.20.1


--IJpNTDwzlM2Ie8A6--





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

* [PATCH] hex squash commit
@ 2021-01-01 20:04 Bruce Momjian <[email protected]>
  0 siblings, 0 replies; 27+ messages in thread

From: Bruce Momjian @ 2021-01-01 20:04 UTC (permalink / raw)

---
 src/backend/replication/backup_manifest.c |  2 +-
 src/backend/utils/adt/encode.c            | 34 +------------------
 src/backend/utils/adt/varlena.c           |  2 +-
 src/common/Makefile                       |  2 +-
 src/common/{hex_decode.c => hex.c}        | 40 ++++++++++++++++++++---
 src/include/common/hex.h (new)            | 18 ++++++++++
 src/include/common/hex_decode.h (gone)    | 16 ---------
 src/include/utils/builtins.h              |  3 --
 src/tools/msvc/Mkvcbuild.pm               |  2 +-
 9 files changed, 59 insertions(+), 60 deletions(-)

diff --git a/src/backend/replication/backup_manifest.c b/src/backend/replication/backup_manifest.c
index c3f339c556..716f114d78 100644
--- a/src/backend/replication/backup_manifest.c
+++ b/src/backend/replication/backup_manifest.c
@@ -17,7 +17,7 @@
 #include "libpq/pqformat.h"
 #include "mb/pg_wchar.h"
 #include "replication/backup_manifest.h"
-#include "utils/builtins.h"
+#include "common/hex.h"
 #include "utils/json.h"
 
 static void AppendStringToManifest(backup_manifest_info *manifest, char *s);
diff --git a/src/backend/utils/adt/encode.c b/src/backend/utils/adt/encode.c
index a6c65b1657..bca941a496 100644
--- a/src/backend/utils/adt/encode.c
+++ b/src/backend/utils/adt/encode.c
@@ -15,7 +15,7 @@
 
 #include <ctype.h>
 
-#include "common/hex_decode.h"
+#include "common/hex.h"
 #include "mb/pg_wchar.h"
 #include "utils/builtins.h"
 #include "utils/memutils.h"
@@ -141,38 +141,6 @@ binary_decode(PG_FUNCTION_ARGS)
 }
 
 
-/*
- * HEX
- */
-
-static const char hextbl[] = "0123456789abcdef";
-
-uint64
-hex_encode(const char *src, size_t len, char *dst)
-{
-	const char *end = src + len;
-
-	while (src < end)
-	{
-		*dst++ = hextbl[(*src >> 4) & 0xF];
-		*dst++ = hextbl[*src & 0xF];
-		src++;
-	}
-	return (uint64) len * 2;
-}
-
-static uint64
-hex_enc_len(const char *src, size_t srclen)
-{
-	return (uint64) srclen << 1;
-}
-
-static uint64
-hex_dec_len(const char *src, size_t srclen)
-{
-	return (uint64) srclen >> 1;
-}
-
 /*
  * BASE64
  */
diff --git a/src/backend/utils/adt/varlena.c b/src/backend/utils/adt/varlena.c
index 9300d19e0c..79fcdcd178 100644
--- a/src/backend/utils/adt/varlena.c
+++ b/src/backend/utils/adt/varlena.c
@@ -22,7 +22,7 @@
 #include "catalog/pg_type.h"
 #include "common/hashfn.h"
 #include "common/int.h"
-#include "common/hex_decode.h"
+#include "common/hex.h"
 #include "common/unicode_norm.h"
 #include "lib/hyperloglog.h"
 #include "libpq/pqformat.h"
diff --git a/src/common/Makefile b/src/common/Makefile
index f624977939..93eb27a2aa 100644
--- a/src/common/Makefile
+++ b/src/common/Makefile
@@ -58,7 +58,7 @@ OBJS_COMMON = \
 	file_perm.o \
 	file_utils.o \
 	hashfn.o \
-	hex_decode.o \
+	hex.o \
 	ip.o \
 	jsonapi.o \
 	keywords.o \
diff --git a/src/common/hex_decode.c b/src/common/hex.c
similarity index 79%
rename from src/common/hex_decode.c
rename to src/common/hex.c
index 3ecdc73b5c..97f57bcc32 100644
--- a/src/common/hex_decode.c
+++ b/src/common/hex.c
@@ -1,7 +1,7 @@
 /*-------------------------------------------------------------------------
  *
- * hex_decode.c
- *		hex decoding
+ * hex.c
+ *		hex processing
  *
  *
  * Portions Copyright (c) 1996-2020, PostgreSQL Global Development Group
@@ -9,7 +9,7 @@
  *
  *
  * IDENTIFICATION
- *	  src/common/hex_decode.c
+ *	  src/common/hex.c
  *
  *-------------------------------------------------------------------------
  */
@@ -26,7 +26,7 @@
 #else
 #include "mb/pg_wchar.h"
 #endif
-#include "common/hex_decode.h"
+#include "common/hex.h"
 
 
 static const int8 hexlookup[128] = {
@@ -40,6 +40,26 @@ static const int8 hexlookup[128] = {
 	-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
 };
 
+/*
+ * HEX
+ */
+
+static const char hextbl[] = "0123456789abcdef";
+
+uint64
+hex_encode(const char *src, size_t len, char *dst)
+{
+	const char *end = src + len;
+
+	while (src < end)
+	{
+		*dst++ = hextbl[(*src >> 4) & 0xF];
+		*dst++ = hextbl[*src & 0xF];
+		src++;
+	}
+	return (uint64) len * 2;
+}
+
 static inline char
 get_hex(const char *cp)
 {
@@ -104,3 +124,15 @@ hex_decode(const char *src, size_t len, char *dst)
 
 	return p - dst;
 }
+
+uint64
+hex_enc_len(const char *src, size_t srclen)
+{
+	return (uint64) srclen << 1;
+}
+
+uint64
+hex_dec_len(const char *src, size_t srclen)
+{
+	return (uint64) srclen >> 1;
+}
diff --git a/src/include/common/hex.h b/src/include/common/hex.h
new file mode 100644
index 0000000000..76154b65af
--- /dev/null
+++ b/src/include/common/hex.h
@@ -0,0 +1,18 @@
+/*
+ *	hex.h
+ *		hex processing
+ *
+ *	Portions Copyright (c) 1996-2020, PostgreSQL Global Development Group
+ *	Portions Copyright (c) 1994, Regents of the University of California
+ *
+ *	src/include/common/hex.h
+ */
+#ifndef COMMON_HEX_H
+#define COMMON_HEX_H
+
+extern uint64 hex_decode(const char *src, size_t len, char *dst);
+extern uint64 hex_encode(const char *src, size_t len, char *dst);
+extern uint64 hex_enc_len(const char *src, size_t srclen);
+extern uint64 hex_dec_len(const char *src, size_t srclen);
+
+#endif							/* COMMON_HEX_H */
diff --git a/src/include/common/hex_decode.h b/src/include/common/hex_decode.h
deleted file mode 100644
index 1f99f069b2..0000000000
--- a/src/include/common/hex_decode.h
+++ /dev/null
@@ -1,16 +0,0 @@
-/*
- *	hex_decode.h
- *		hex decoding
- *
- *	Portions Copyright (c) 1996-2020, PostgreSQL Global Development Group
- *	Portions Copyright (c) 1994, Regents of the University of California
- *
- *	src/include/common/hex_decode.h
- */
-#ifndef COMMON_HEX_DECODE_H
-#define COMMON_HEX_DECODE_H
-
-extern uint64 hex_decode(const char *src, size_t len, char *dst);
-
-
-#endif							/* COMMON_HEX_DECODE_H */
diff --git a/src/include/utils/builtins.h b/src/include/utils/builtins.h
index 19271e0696..11ba6ae565 100644
--- a/src/include/utils/builtins.h
+++ b/src/include/utils/builtins.h
@@ -31,9 +31,6 @@ extern void domain_check(Datum value, bool isnull, Oid domainType,
 extern int	errdatatype(Oid datatypeOid);
 extern int	errdomainconstraint(Oid datatypeOid, const char *conname);
 
-/* encode.c */
-extern uint64 hex_encode(const char *src, size_t len, char *dst);
-
 /* int.c */
 extern int2vector *buildint2vector(const int16 *int2s, int n);
 
diff --git a/src/tools/msvc/Mkvcbuild.pm b/src/tools/msvc/Mkvcbuild.pm
index 7f014a12c9..60b216cce0 100644
--- a/src/tools/msvc/Mkvcbuild.pm
+++ b/src/tools/msvc/Mkvcbuild.pm
@@ -121,7 +121,7 @@ sub mkvcbuild
 	our @pgcommonallfiles = qw(
 	  archive.c base64.c checksum_helper.c
 	  config_info.c controldata_utils.c d2s.c encnames.c exec.c
-	  f2s.c file_perm.c file_utils.c hashfn.c hex_decode.c ip.c jsonapi.c
+	  f2s.c file_perm.c file_utils.c hashfn.c hex.c ip.c jsonapi.c
 	  keywords.c kwlookup.c link-canary.c md5_common.c
 	  pg_get_line.c pg_lzcompress.c pgfnames.c psprintf.c relpath.c rmtree.c
 	  saslprep.c scram-common.c string.c stringinfo.c unicode_norm.c username.c
-- 
2.20.1


--IJpNTDwzlM2Ie8A6--





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

* [PATCH] hex squash commit
@ 2021-01-01 20:04 Bruce Momjian <[email protected]>
  0 siblings, 0 replies; 27+ messages in thread

From: Bruce Momjian @ 2021-01-01 20:04 UTC (permalink / raw)

---
 src/backend/replication/backup_manifest.c |  2 +-
 src/backend/utils/adt/encode.c            | 34 +------------------
 src/backend/utils/adt/varlena.c           |  2 +-
 src/common/Makefile                       |  2 +-
 src/common/{hex_decode.c => hex.c}        | 40 ++++++++++++++++++++---
 src/include/common/hex.h (new)            | 18 ++++++++++
 src/include/common/hex_decode.h (gone)    | 16 ---------
 src/include/utils/builtins.h              |  3 --
 src/tools/msvc/Mkvcbuild.pm               |  2 +-
 9 files changed, 59 insertions(+), 60 deletions(-)

diff --git a/src/backend/replication/backup_manifest.c b/src/backend/replication/backup_manifest.c
index c3f339c556..716f114d78 100644
--- a/src/backend/replication/backup_manifest.c
+++ b/src/backend/replication/backup_manifest.c
@@ -17,7 +17,7 @@
 #include "libpq/pqformat.h"
 #include "mb/pg_wchar.h"
 #include "replication/backup_manifest.h"
-#include "utils/builtins.h"
+#include "common/hex.h"
 #include "utils/json.h"
 
 static void AppendStringToManifest(backup_manifest_info *manifest, char *s);
diff --git a/src/backend/utils/adt/encode.c b/src/backend/utils/adt/encode.c
index a6c65b1657..bca941a496 100644
--- a/src/backend/utils/adt/encode.c
+++ b/src/backend/utils/adt/encode.c
@@ -15,7 +15,7 @@
 
 #include <ctype.h>
 
-#include "common/hex_decode.h"
+#include "common/hex.h"
 #include "mb/pg_wchar.h"
 #include "utils/builtins.h"
 #include "utils/memutils.h"
@@ -141,38 +141,6 @@ binary_decode(PG_FUNCTION_ARGS)
 }
 
 
-/*
- * HEX
- */
-
-static const char hextbl[] = "0123456789abcdef";
-
-uint64
-hex_encode(const char *src, size_t len, char *dst)
-{
-	const char *end = src + len;
-
-	while (src < end)
-	{
-		*dst++ = hextbl[(*src >> 4) & 0xF];
-		*dst++ = hextbl[*src & 0xF];
-		src++;
-	}
-	return (uint64) len * 2;
-}
-
-static uint64
-hex_enc_len(const char *src, size_t srclen)
-{
-	return (uint64) srclen << 1;
-}
-
-static uint64
-hex_dec_len(const char *src, size_t srclen)
-{
-	return (uint64) srclen >> 1;
-}
-
 /*
  * BASE64
  */
diff --git a/src/backend/utils/adt/varlena.c b/src/backend/utils/adt/varlena.c
index 9300d19e0c..79fcdcd178 100644
--- a/src/backend/utils/adt/varlena.c
+++ b/src/backend/utils/adt/varlena.c
@@ -22,7 +22,7 @@
 #include "catalog/pg_type.h"
 #include "common/hashfn.h"
 #include "common/int.h"
-#include "common/hex_decode.h"
+#include "common/hex.h"
 #include "common/unicode_norm.h"
 #include "lib/hyperloglog.h"
 #include "libpq/pqformat.h"
diff --git a/src/common/Makefile b/src/common/Makefile
index f624977939..93eb27a2aa 100644
--- a/src/common/Makefile
+++ b/src/common/Makefile
@@ -58,7 +58,7 @@ OBJS_COMMON = \
 	file_perm.o \
 	file_utils.o \
 	hashfn.o \
-	hex_decode.o \
+	hex.o \
 	ip.o \
 	jsonapi.o \
 	keywords.o \
diff --git a/src/common/hex_decode.c b/src/common/hex.c
similarity index 79%
rename from src/common/hex_decode.c
rename to src/common/hex.c
index 3ecdc73b5c..97f57bcc32 100644
--- a/src/common/hex_decode.c
+++ b/src/common/hex.c
@@ -1,7 +1,7 @@
 /*-------------------------------------------------------------------------
  *
- * hex_decode.c
- *		hex decoding
+ * hex.c
+ *		hex processing
  *
  *
  * Portions Copyright (c) 1996-2020, PostgreSQL Global Development Group
@@ -9,7 +9,7 @@
  *
  *
  * IDENTIFICATION
- *	  src/common/hex_decode.c
+ *	  src/common/hex.c
  *
  *-------------------------------------------------------------------------
  */
@@ -26,7 +26,7 @@
 #else
 #include "mb/pg_wchar.h"
 #endif
-#include "common/hex_decode.h"
+#include "common/hex.h"
 
 
 static const int8 hexlookup[128] = {
@@ -40,6 +40,26 @@ static const int8 hexlookup[128] = {
 	-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
 };
 
+/*
+ * HEX
+ */
+
+static const char hextbl[] = "0123456789abcdef";
+
+uint64
+hex_encode(const char *src, size_t len, char *dst)
+{
+	const char *end = src + len;
+
+	while (src < end)
+	{
+		*dst++ = hextbl[(*src >> 4) & 0xF];
+		*dst++ = hextbl[*src & 0xF];
+		src++;
+	}
+	return (uint64) len * 2;
+}
+
 static inline char
 get_hex(const char *cp)
 {
@@ -104,3 +124,15 @@ hex_decode(const char *src, size_t len, char *dst)
 
 	return p - dst;
 }
+
+uint64
+hex_enc_len(const char *src, size_t srclen)
+{
+	return (uint64) srclen << 1;
+}
+
+uint64
+hex_dec_len(const char *src, size_t srclen)
+{
+	return (uint64) srclen >> 1;
+}
diff --git a/src/include/common/hex.h b/src/include/common/hex.h
new file mode 100644
index 0000000000..76154b65af
--- /dev/null
+++ b/src/include/common/hex.h
@@ -0,0 +1,18 @@
+/*
+ *	hex.h
+ *		hex processing
+ *
+ *	Portions Copyright (c) 1996-2020, PostgreSQL Global Development Group
+ *	Portions Copyright (c) 1994, Regents of the University of California
+ *
+ *	src/include/common/hex.h
+ */
+#ifndef COMMON_HEX_H
+#define COMMON_HEX_H
+
+extern uint64 hex_decode(const char *src, size_t len, char *dst);
+extern uint64 hex_encode(const char *src, size_t len, char *dst);
+extern uint64 hex_enc_len(const char *src, size_t srclen);
+extern uint64 hex_dec_len(const char *src, size_t srclen);
+
+#endif							/* COMMON_HEX_H */
diff --git a/src/include/common/hex_decode.h b/src/include/common/hex_decode.h
deleted file mode 100644
index 1f99f069b2..0000000000
--- a/src/include/common/hex_decode.h
+++ /dev/null
@@ -1,16 +0,0 @@
-/*
- *	hex_decode.h
- *		hex decoding
- *
- *	Portions Copyright (c) 1996-2020, PostgreSQL Global Development Group
- *	Portions Copyright (c) 1994, Regents of the University of California
- *
- *	src/include/common/hex_decode.h
- */
-#ifndef COMMON_HEX_DECODE_H
-#define COMMON_HEX_DECODE_H
-
-extern uint64 hex_decode(const char *src, size_t len, char *dst);
-
-
-#endif							/* COMMON_HEX_DECODE_H */
diff --git a/src/include/utils/builtins.h b/src/include/utils/builtins.h
index 19271e0696..11ba6ae565 100644
--- a/src/include/utils/builtins.h
+++ b/src/include/utils/builtins.h
@@ -31,9 +31,6 @@ extern void domain_check(Datum value, bool isnull, Oid domainType,
 extern int	errdatatype(Oid datatypeOid);
 extern int	errdomainconstraint(Oid datatypeOid, const char *conname);
 
-/* encode.c */
-extern uint64 hex_encode(const char *src, size_t len, char *dst);
-
 /* int.c */
 extern int2vector *buildint2vector(const int16 *int2s, int n);
 
diff --git a/src/tools/msvc/Mkvcbuild.pm b/src/tools/msvc/Mkvcbuild.pm
index 7f014a12c9..60b216cce0 100644
--- a/src/tools/msvc/Mkvcbuild.pm
+++ b/src/tools/msvc/Mkvcbuild.pm
@@ -121,7 +121,7 @@ sub mkvcbuild
 	our @pgcommonallfiles = qw(
 	  archive.c base64.c checksum_helper.c
 	  config_info.c controldata_utils.c d2s.c encnames.c exec.c
-	  f2s.c file_perm.c file_utils.c hashfn.c hex_decode.c ip.c jsonapi.c
+	  f2s.c file_perm.c file_utils.c hashfn.c hex.c ip.c jsonapi.c
 	  keywords.c kwlookup.c link-canary.c md5_common.c
 	  pg_get_line.c pg_lzcompress.c pgfnames.c psprintf.c relpath.c rmtree.c
 	  saslprep.c scram-common.c string.c stringinfo.c unicode_norm.c username.c
-- 
2.20.1


--IJpNTDwzlM2Ie8A6--





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

* [PATCH] hex squash commit
@ 2021-01-01 20:04 Bruce Momjian <[email protected]>
  0 siblings, 0 replies; 27+ messages in thread

From: Bruce Momjian @ 2021-01-01 20:04 UTC (permalink / raw)

---
 src/backend/replication/backup_manifest.c |  2 +-
 src/backend/utils/adt/encode.c            | 34 +------------------
 src/backend/utils/adt/varlena.c           |  2 +-
 src/common/Makefile                       |  2 +-
 src/common/{hex_decode.c => hex.c}        | 40 ++++++++++++++++++++---
 src/include/common/hex.h (new)            | 18 ++++++++++
 src/include/common/hex_decode.h (gone)    | 16 ---------
 src/include/utils/builtins.h              |  3 --
 src/tools/msvc/Mkvcbuild.pm               |  2 +-
 9 files changed, 59 insertions(+), 60 deletions(-)

diff --git a/src/backend/replication/backup_manifest.c b/src/backend/replication/backup_manifest.c
index c3f339c556..716f114d78 100644
--- a/src/backend/replication/backup_manifest.c
+++ b/src/backend/replication/backup_manifest.c
@@ -17,7 +17,7 @@
 #include "libpq/pqformat.h"
 #include "mb/pg_wchar.h"
 #include "replication/backup_manifest.h"
-#include "utils/builtins.h"
+#include "common/hex.h"
 #include "utils/json.h"
 
 static void AppendStringToManifest(backup_manifest_info *manifest, char *s);
diff --git a/src/backend/utils/adt/encode.c b/src/backend/utils/adt/encode.c
index a6c65b1657..bca941a496 100644
--- a/src/backend/utils/adt/encode.c
+++ b/src/backend/utils/adt/encode.c
@@ -15,7 +15,7 @@
 
 #include <ctype.h>
 
-#include "common/hex_decode.h"
+#include "common/hex.h"
 #include "mb/pg_wchar.h"
 #include "utils/builtins.h"
 #include "utils/memutils.h"
@@ -141,38 +141,6 @@ binary_decode(PG_FUNCTION_ARGS)
 }
 
 
-/*
- * HEX
- */
-
-static const char hextbl[] = "0123456789abcdef";
-
-uint64
-hex_encode(const char *src, size_t len, char *dst)
-{
-	const char *end = src + len;
-
-	while (src < end)
-	{
-		*dst++ = hextbl[(*src >> 4) & 0xF];
-		*dst++ = hextbl[*src & 0xF];
-		src++;
-	}
-	return (uint64) len * 2;
-}
-
-static uint64
-hex_enc_len(const char *src, size_t srclen)
-{
-	return (uint64) srclen << 1;
-}
-
-static uint64
-hex_dec_len(const char *src, size_t srclen)
-{
-	return (uint64) srclen >> 1;
-}
-
 /*
  * BASE64
  */
diff --git a/src/backend/utils/adt/varlena.c b/src/backend/utils/adt/varlena.c
index 9300d19e0c..79fcdcd178 100644
--- a/src/backend/utils/adt/varlena.c
+++ b/src/backend/utils/adt/varlena.c
@@ -22,7 +22,7 @@
 #include "catalog/pg_type.h"
 #include "common/hashfn.h"
 #include "common/int.h"
-#include "common/hex_decode.h"
+#include "common/hex.h"
 #include "common/unicode_norm.h"
 #include "lib/hyperloglog.h"
 #include "libpq/pqformat.h"
diff --git a/src/common/Makefile b/src/common/Makefile
index f624977939..93eb27a2aa 100644
--- a/src/common/Makefile
+++ b/src/common/Makefile
@@ -58,7 +58,7 @@ OBJS_COMMON = \
 	file_perm.o \
 	file_utils.o \
 	hashfn.o \
-	hex_decode.o \
+	hex.o \
 	ip.o \
 	jsonapi.o \
 	keywords.o \
diff --git a/src/common/hex_decode.c b/src/common/hex.c
similarity index 79%
rename from src/common/hex_decode.c
rename to src/common/hex.c
index 3ecdc73b5c..97f57bcc32 100644
--- a/src/common/hex_decode.c
+++ b/src/common/hex.c
@@ -1,7 +1,7 @@
 /*-------------------------------------------------------------------------
  *
- * hex_decode.c
- *		hex decoding
+ * hex.c
+ *		hex processing
  *
  *
  * Portions Copyright (c) 1996-2020, PostgreSQL Global Development Group
@@ -9,7 +9,7 @@
  *
  *
  * IDENTIFICATION
- *	  src/common/hex_decode.c
+ *	  src/common/hex.c
  *
  *-------------------------------------------------------------------------
  */
@@ -26,7 +26,7 @@
 #else
 #include "mb/pg_wchar.h"
 #endif
-#include "common/hex_decode.h"
+#include "common/hex.h"
 
 
 static const int8 hexlookup[128] = {
@@ -40,6 +40,26 @@ static const int8 hexlookup[128] = {
 	-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
 };
 
+/*
+ * HEX
+ */
+
+static const char hextbl[] = "0123456789abcdef";
+
+uint64
+hex_encode(const char *src, size_t len, char *dst)
+{
+	const char *end = src + len;
+
+	while (src < end)
+	{
+		*dst++ = hextbl[(*src >> 4) & 0xF];
+		*dst++ = hextbl[*src & 0xF];
+		src++;
+	}
+	return (uint64) len * 2;
+}
+
 static inline char
 get_hex(const char *cp)
 {
@@ -104,3 +124,15 @@ hex_decode(const char *src, size_t len, char *dst)
 
 	return p - dst;
 }
+
+uint64
+hex_enc_len(const char *src, size_t srclen)
+{
+	return (uint64) srclen << 1;
+}
+
+uint64
+hex_dec_len(const char *src, size_t srclen)
+{
+	return (uint64) srclen >> 1;
+}
diff --git a/src/include/common/hex.h b/src/include/common/hex.h
new file mode 100644
index 0000000000..76154b65af
--- /dev/null
+++ b/src/include/common/hex.h
@@ -0,0 +1,18 @@
+/*
+ *	hex.h
+ *		hex processing
+ *
+ *	Portions Copyright (c) 1996-2020, PostgreSQL Global Development Group
+ *	Portions Copyright (c) 1994, Regents of the University of California
+ *
+ *	src/include/common/hex.h
+ */
+#ifndef COMMON_HEX_H
+#define COMMON_HEX_H
+
+extern uint64 hex_decode(const char *src, size_t len, char *dst);
+extern uint64 hex_encode(const char *src, size_t len, char *dst);
+extern uint64 hex_enc_len(const char *src, size_t srclen);
+extern uint64 hex_dec_len(const char *src, size_t srclen);
+
+#endif							/* COMMON_HEX_H */
diff --git a/src/include/common/hex_decode.h b/src/include/common/hex_decode.h
deleted file mode 100644
index 1f99f069b2..0000000000
--- a/src/include/common/hex_decode.h
+++ /dev/null
@@ -1,16 +0,0 @@
-/*
- *	hex_decode.h
- *		hex decoding
- *
- *	Portions Copyright (c) 1996-2020, PostgreSQL Global Development Group
- *	Portions Copyright (c) 1994, Regents of the University of California
- *
- *	src/include/common/hex_decode.h
- */
-#ifndef COMMON_HEX_DECODE_H
-#define COMMON_HEX_DECODE_H
-
-extern uint64 hex_decode(const char *src, size_t len, char *dst);
-
-
-#endif							/* COMMON_HEX_DECODE_H */
diff --git a/src/include/utils/builtins.h b/src/include/utils/builtins.h
index 19271e0696..11ba6ae565 100644
--- a/src/include/utils/builtins.h
+++ b/src/include/utils/builtins.h
@@ -31,9 +31,6 @@ extern void domain_check(Datum value, bool isnull, Oid domainType,
 extern int	errdatatype(Oid datatypeOid);
 extern int	errdomainconstraint(Oid datatypeOid, const char *conname);
 
-/* encode.c */
-extern uint64 hex_encode(const char *src, size_t len, char *dst);
-
 /* int.c */
 extern int2vector *buildint2vector(const int16 *int2s, int n);
 
diff --git a/src/tools/msvc/Mkvcbuild.pm b/src/tools/msvc/Mkvcbuild.pm
index 7f014a12c9..60b216cce0 100644
--- a/src/tools/msvc/Mkvcbuild.pm
+++ b/src/tools/msvc/Mkvcbuild.pm
@@ -121,7 +121,7 @@ sub mkvcbuild
 	our @pgcommonallfiles = qw(
 	  archive.c base64.c checksum_helper.c
 	  config_info.c controldata_utils.c d2s.c encnames.c exec.c
-	  f2s.c file_perm.c file_utils.c hashfn.c hex_decode.c ip.c jsonapi.c
+	  f2s.c file_perm.c file_utils.c hashfn.c hex.c ip.c jsonapi.c
 	  keywords.c kwlookup.c link-canary.c md5_common.c
 	  pg_get_line.c pg_lzcompress.c pgfnames.c psprintf.c relpath.c rmtree.c
 	  saslprep.c scram-common.c string.c stringinfo.c unicode_norm.c username.c
-- 
2.20.1


--IJpNTDwzlM2Ie8A6--





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

* [PATCH] hex squash commit
@ 2021-01-01 20:04 Bruce Momjian <[email protected]>
  0 siblings, 0 replies; 27+ messages in thread

From: Bruce Momjian @ 2021-01-01 20:04 UTC (permalink / raw)

---
 src/backend/replication/backup_manifest.c |  2 +-
 src/backend/utils/adt/encode.c            | 34 +------------------
 src/backend/utils/adt/varlena.c           |  2 +-
 src/common/Makefile                       |  2 +-
 src/common/{hex_decode.c => hex.c}        | 40 ++++++++++++++++++++---
 src/include/common/hex.h (new)            | 18 ++++++++++
 src/include/common/hex_decode.h (gone)    | 16 ---------
 src/include/utils/builtins.h              |  3 --
 src/tools/msvc/Mkvcbuild.pm               |  2 +-
 9 files changed, 59 insertions(+), 60 deletions(-)

diff --git a/src/backend/replication/backup_manifest.c b/src/backend/replication/backup_manifest.c
index c3f339c556..716f114d78 100644
--- a/src/backend/replication/backup_manifest.c
+++ b/src/backend/replication/backup_manifest.c
@@ -17,7 +17,7 @@
 #include "libpq/pqformat.h"
 #include "mb/pg_wchar.h"
 #include "replication/backup_manifest.h"
-#include "utils/builtins.h"
+#include "common/hex.h"
 #include "utils/json.h"
 
 static void AppendStringToManifest(backup_manifest_info *manifest, char *s);
diff --git a/src/backend/utils/adt/encode.c b/src/backend/utils/adt/encode.c
index a6c65b1657..bca941a496 100644
--- a/src/backend/utils/adt/encode.c
+++ b/src/backend/utils/adt/encode.c
@@ -15,7 +15,7 @@
 
 #include <ctype.h>
 
-#include "common/hex_decode.h"
+#include "common/hex.h"
 #include "mb/pg_wchar.h"
 #include "utils/builtins.h"
 #include "utils/memutils.h"
@@ -141,38 +141,6 @@ binary_decode(PG_FUNCTION_ARGS)
 }
 
 
-/*
- * HEX
- */
-
-static const char hextbl[] = "0123456789abcdef";
-
-uint64
-hex_encode(const char *src, size_t len, char *dst)
-{
-	const char *end = src + len;
-
-	while (src < end)
-	{
-		*dst++ = hextbl[(*src >> 4) & 0xF];
-		*dst++ = hextbl[*src & 0xF];
-		src++;
-	}
-	return (uint64) len * 2;
-}
-
-static uint64
-hex_enc_len(const char *src, size_t srclen)
-{
-	return (uint64) srclen << 1;
-}
-
-static uint64
-hex_dec_len(const char *src, size_t srclen)
-{
-	return (uint64) srclen >> 1;
-}
-
 /*
  * BASE64
  */
diff --git a/src/backend/utils/adt/varlena.c b/src/backend/utils/adt/varlena.c
index 9300d19e0c..79fcdcd178 100644
--- a/src/backend/utils/adt/varlena.c
+++ b/src/backend/utils/adt/varlena.c
@@ -22,7 +22,7 @@
 #include "catalog/pg_type.h"
 #include "common/hashfn.h"
 #include "common/int.h"
-#include "common/hex_decode.h"
+#include "common/hex.h"
 #include "common/unicode_norm.h"
 #include "lib/hyperloglog.h"
 #include "libpq/pqformat.h"
diff --git a/src/common/Makefile b/src/common/Makefile
index f624977939..93eb27a2aa 100644
--- a/src/common/Makefile
+++ b/src/common/Makefile
@@ -58,7 +58,7 @@ OBJS_COMMON = \
 	file_perm.o \
 	file_utils.o \
 	hashfn.o \
-	hex_decode.o \
+	hex.o \
 	ip.o \
 	jsonapi.o \
 	keywords.o \
diff --git a/src/common/hex_decode.c b/src/common/hex.c
similarity index 79%
rename from src/common/hex_decode.c
rename to src/common/hex.c
index 3ecdc73b5c..97f57bcc32 100644
--- a/src/common/hex_decode.c
+++ b/src/common/hex.c
@@ -1,7 +1,7 @@
 /*-------------------------------------------------------------------------
  *
- * hex_decode.c
- *		hex decoding
+ * hex.c
+ *		hex processing
  *
  *
  * Portions Copyright (c) 1996-2020, PostgreSQL Global Development Group
@@ -9,7 +9,7 @@
  *
  *
  * IDENTIFICATION
- *	  src/common/hex_decode.c
+ *	  src/common/hex.c
  *
  *-------------------------------------------------------------------------
  */
@@ -26,7 +26,7 @@
 #else
 #include "mb/pg_wchar.h"
 #endif
-#include "common/hex_decode.h"
+#include "common/hex.h"
 
 
 static const int8 hexlookup[128] = {
@@ -40,6 +40,26 @@ static const int8 hexlookup[128] = {
 	-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
 };
 
+/*
+ * HEX
+ */
+
+static const char hextbl[] = "0123456789abcdef";
+
+uint64
+hex_encode(const char *src, size_t len, char *dst)
+{
+	const char *end = src + len;
+
+	while (src < end)
+	{
+		*dst++ = hextbl[(*src >> 4) & 0xF];
+		*dst++ = hextbl[*src & 0xF];
+		src++;
+	}
+	return (uint64) len * 2;
+}
+
 static inline char
 get_hex(const char *cp)
 {
@@ -104,3 +124,15 @@ hex_decode(const char *src, size_t len, char *dst)
 
 	return p - dst;
 }
+
+uint64
+hex_enc_len(const char *src, size_t srclen)
+{
+	return (uint64) srclen << 1;
+}
+
+uint64
+hex_dec_len(const char *src, size_t srclen)
+{
+	return (uint64) srclen >> 1;
+}
diff --git a/src/include/common/hex.h b/src/include/common/hex.h
new file mode 100644
index 0000000000..76154b65af
--- /dev/null
+++ b/src/include/common/hex.h
@@ -0,0 +1,18 @@
+/*
+ *	hex.h
+ *		hex processing
+ *
+ *	Portions Copyright (c) 1996-2020, PostgreSQL Global Development Group
+ *	Portions Copyright (c) 1994, Regents of the University of California
+ *
+ *	src/include/common/hex.h
+ */
+#ifndef COMMON_HEX_H
+#define COMMON_HEX_H
+
+extern uint64 hex_decode(const char *src, size_t len, char *dst);
+extern uint64 hex_encode(const char *src, size_t len, char *dst);
+extern uint64 hex_enc_len(const char *src, size_t srclen);
+extern uint64 hex_dec_len(const char *src, size_t srclen);
+
+#endif							/* COMMON_HEX_H */
diff --git a/src/include/common/hex_decode.h b/src/include/common/hex_decode.h
deleted file mode 100644
index 1f99f069b2..0000000000
--- a/src/include/common/hex_decode.h
+++ /dev/null
@@ -1,16 +0,0 @@
-/*
- *	hex_decode.h
- *		hex decoding
- *
- *	Portions Copyright (c) 1996-2020, PostgreSQL Global Development Group
- *	Portions Copyright (c) 1994, Regents of the University of California
- *
- *	src/include/common/hex_decode.h
- */
-#ifndef COMMON_HEX_DECODE_H
-#define COMMON_HEX_DECODE_H
-
-extern uint64 hex_decode(const char *src, size_t len, char *dst);
-
-
-#endif							/* COMMON_HEX_DECODE_H */
diff --git a/src/include/utils/builtins.h b/src/include/utils/builtins.h
index 19271e0696..11ba6ae565 100644
--- a/src/include/utils/builtins.h
+++ b/src/include/utils/builtins.h
@@ -31,9 +31,6 @@ extern void domain_check(Datum value, bool isnull, Oid domainType,
 extern int	errdatatype(Oid datatypeOid);
 extern int	errdomainconstraint(Oid datatypeOid, const char *conname);
 
-/* encode.c */
-extern uint64 hex_encode(const char *src, size_t len, char *dst);
-
 /* int.c */
 extern int2vector *buildint2vector(const int16 *int2s, int n);
 
diff --git a/src/tools/msvc/Mkvcbuild.pm b/src/tools/msvc/Mkvcbuild.pm
index 7f014a12c9..60b216cce0 100644
--- a/src/tools/msvc/Mkvcbuild.pm
+++ b/src/tools/msvc/Mkvcbuild.pm
@@ -121,7 +121,7 @@ sub mkvcbuild
 	our @pgcommonallfiles = qw(
 	  archive.c base64.c checksum_helper.c
 	  config_info.c controldata_utils.c d2s.c encnames.c exec.c
-	  f2s.c file_perm.c file_utils.c hashfn.c hex_decode.c ip.c jsonapi.c
+	  f2s.c file_perm.c file_utils.c hashfn.c hex.c ip.c jsonapi.c
 	  keywords.c kwlookup.c link-canary.c md5_common.c
 	  pg_get_line.c pg_lzcompress.c pgfnames.c psprintf.c relpath.c rmtree.c
 	  saslprep.c scram-common.c string.c stringinfo.c unicode_norm.c username.c
-- 
2.20.1


--IJpNTDwzlM2Ie8A6--





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

* [PATCH] hex squash commit
@ 2021-01-01 20:04 Bruce Momjian <[email protected]>
  0 siblings, 0 replies; 27+ messages in thread

From: Bruce Momjian @ 2021-01-01 20:04 UTC (permalink / raw)

---
 src/backend/replication/backup_manifest.c |  2 +-
 src/backend/utils/adt/encode.c            | 34 +------------------
 src/backend/utils/adt/varlena.c           |  2 +-
 src/common/Makefile                       |  2 +-
 src/common/{hex_decode.c => hex.c}        | 40 ++++++++++++++++++++---
 src/include/common/hex.h (new)            | 18 ++++++++++
 src/include/common/hex_decode.h (gone)    | 16 ---------
 src/include/utils/builtins.h              |  3 --
 src/tools/msvc/Mkvcbuild.pm               |  2 +-
 9 files changed, 59 insertions(+), 60 deletions(-)

diff --git a/src/backend/replication/backup_manifest.c b/src/backend/replication/backup_manifest.c
index c3f339c556..716f114d78 100644
--- a/src/backend/replication/backup_manifest.c
+++ b/src/backend/replication/backup_manifest.c
@@ -17,7 +17,7 @@
 #include "libpq/pqformat.h"
 #include "mb/pg_wchar.h"
 #include "replication/backup_manifest.h"
-#include "utils/builtins.h"
+#include "common/hex.h"
 #include "utils/json.h"
 
 static void AppendStringToManifest(backup_manifest_info *manifest, char *s);
diff --git a/src/backend/utils/adt/encode.c b/src/backend/utils/adt/encode.c
index a6c65b1657..bca941a496 100644
--- a/src/backend/utils/adt/encode.c
+++ b/src/backend/utils/adt/encode.c
@@ -15,7 +15,7 @@
 
 #include <ctype.h>
 
-#include "common/hex_decode.h"
+#include "common/hex.h"
 #include "mb/pg_wchar.h"
 #include "utils/builtins.h"
 #include "utils/memutils.h"
@@ -141,38 +141,6 @@ binary_decode(PG_FUNCTION_ARGS)
 }
 
 
-/*
- * HEX
- */
-
-static const char hextbl[] = "0123456789abcdef";
-
-uint64
-hex_encode(const char *src, size_t len, char *dst)
-{
-	const char *end = src + len;
-
-	while (src < end)
-	{
-		*dst++ = hextbl[(*src >> 4) & 0xF];
-		*dst++ = hextbl[*src & 0xF];
-		src++;
-	}
-	return (uint64) len * 2;
-}
-
-static uint64
-hex_enc_len(const char *src, size_t srclen)
-{
-	return (uint64) srclen << 1;
-}
-
-static uint64
-hex_dec_len(const char *src, size_t srclen)
-{
-	return (uint64) srclen >> 1;
-}
-
 /*
  * BASE64
  */
diff --git a/src/backend/utils/adt/varlena.c b/src/backend/utils/adt/varlena.c
index 9300d19e0c..79fcdcd178 100644
--- a/src/backend/utils/adt/varlena.c
+++ b/src/backend/utils/adt/varlena.c
@@ -22,7 +22,7 @@
 #include "catalog/pg_type.h"
 #include "common/hashfn.h"
 #include "common/int.h"
-#include "common/hex_decode.h"
+#include "common/hex.h"
 #include "common/unicode_norm.h"
 #include "lib/hyperloglog.h"
 #include "libpq/pqformat.h"
diff --git a/src/common/Makefile b/src/common/Makefile
index f624977939..93eb27a2aa 100644
--- a/src/common/Makefile
+++ b/src/common/Makefile
@@ -58,7 +58,7 @@ OBJS_COMMON = \
 	file_perm.o \
 	file_utils.o \
 	hashfn.o \
-	hex_decode.o \
+	hex.o \
 	ip.o \
 	jsonapi.o \
 	keywords.o \
diff --git a/src/common/hex_decode.c b/src/common/hex.c
similarity index 79%
rename from src/common/hex_decode.c
rename to src/common/hex.c
index 3ecdc73b5c..97f57bcc32 100644
--- a/src/common/hex_decode.c
+++ b/src/common/hex.c
@@ -1,7 +1,7 @@
 /*-------------------------------------------------------------------------
  *
- * hex_decode.c
- *		hex decoding
+ * hex.c
+ *		hex processing
  *
  *
  * Portions Copyright (c) 1996-2020, PostgreSQL Global Development Group
@@ -9,7 +9,7 @@
  *
  *
  * IDENTIFICATION
- *	  src/common/hex_decode.c
+ *	  src/common/hex.c
  *
  *-------------------------------------------------------------------------
  */
@@ -26,7 +26,7 @@
 #else
 #include "mb/pg_wchar.h"
 #endif
-#include "common/hex_decode.h"
+#include "common/hex.h"
 
 
 static const int8 hexlookup[128] = {
@@ -40,6 +40,26 @@ static const int8 hexlookup[128] = {
 	-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
 };
 
+/*
+ * HEX
+ */
+
+static const char hextbl[] = "0123456789abcdef";
+
+uint64
+hex_encode(const char *src, size_t len, char *dst)
+{
+	const char *end = src + len;
+
+	while (src < end)
+	{
+		*dst++ = hextbl[(*src >> 4) & 0xF];
+		*dst++ = hextbl[*src & 0xF];
+		src++;
+	}
+	return (uint64) len * 2;
+}
+
 static inline char
 get_hex(const char *cp)
 {
@@ -104,3 +124,15 @@ hex_decode(const char *src, size_t len, char *dst)
 
 	return p - dst;
 }
+
+uint64
+hex_enc_len(const char *src, size_t srclen)
+{
+	return (uint64) srclen << 1;
+}
+
+uint64
+hex_dec_len(const char *src, size_t srclen)
+{
+	return (uint64) srclen >> 1;
+}
diff --git a/src/include/common/hex.h b/src/include/common/hex.h
new file mode 100644
index 0000000000..76154b65af
--- /dev/null
+++ b/src/include/common/hex.h
@@ -0,0 +1,18 @@
+/*
+ *	hex.h
+ *		hex processing
+ *
+ *	Portions Copyright (c) 1996-2020, PostgreSQL Global Development Group
+ *	Portions Copyright (c) 1994, Regents of the University of California
+ *
+ *	src/include/common/hex.h
+ */
+#ifndef COMMON_HEX_H
+#define COMMON_HEX_H
+
+extern uint64 hex_decode(const char *src, size_t len, char *dst);
+extern uint64 hex_encode(const char *src, size_t len, char *dst);
+extern uint64 hex_enc_len(const char *src, size_t srclen);
+extern uint64 hex_dec_len(const char *src, size_t srclen);
+
+#endif							/* COMMON_HEX_H */
diff --git a/src/include/common/hex_decode.h b/src/include/common/hex_decode.h
deleted file mode 100644
index 1f99f069b2..0000000000
--- a/src/include/common/hex_decode.h
+++ /dev/null
@@ -1,16 +0,0 @@
-/*
- *	hex_decode.h
- *		hex decoding
- *
- *	Portions Copyright (c) 1996-2020, PostgreSQL Global Development Group
- *	Portions Copyright (c) 1994, Regents of the University of California
- *
- *	src/include/common/hex_decode.h
- */
-#ifndef COMMON_HEX_DECODE_H
-#define COMMON_HEX_DECODE_H
-
-extern uint64 hex_decode(const char *src, size_t len, char *dst);
-
-
-#endif							/* COMMON_HEX_DECODE_H */
diff --git a/src/include/utils/builtins.h b/src/include/utils/builtins.h
index 19271e0696..11ba6ae565 100644
--- a/src/include/utils/builtins.h
+++ b/src/include/utils/builtins.h
@@ -31,9 +31,6 @@ extern void domain_check(Datum value, bool isnull, Oid domainType,
 extern int	errdatatype(Oid datatypeOid);
 extern int	errdomainconstraint(Oid datatypeOid, const char *conname);
 
-/* encode.c */
-extern uint64 hex_encode(const char *src, size_t len, char *dst);
-
 /* int.c */
 extern int2vector *buildint2vector(const int16 *int2s, int n);
 
diff --git a/src/tools/msvc/Mkvcbuild.pm b/src/tools/msvc/Mkvcbuild.pm
index 7f014a12c9..60b216cce0 100644
--- a/src/tools/msvc/Mkvcbuild.pm
+++ b/src/tools/msvc/Mkvcbuild.pm
@@ -121,7 +121,7 @@ sub mkvcbuild
 	our @pgcommonallfiles = qw(
 	  archive.c base64.c checksum_helper.c
 	  config_info.c controldata_utils.c d2s.c encnames.c exec.c
-	  f2s.c file_perm.c file_utils.c hashfn.c hex_decode.c ip.c jsonapi.c
+	  f2s.c file_perm.c file_utils.c hashfn.c hex.c ip.c jsonapi.c
 	  keywords.c kwlookup.c link-canary.c md5_common.c
 	  pg_get_line.c pg_lzcompress.c pgfnames.c psprintf.c relpath.c rmtree.c
 	  saslprep.c scram-common.c string.c stringinfo.c unicode_norm.c username.c
-- 
2.20.1


--IJpNTDwzlM2Ie8A6--





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

* [PATCH] hex squash commit
@ 2021-01-01 20:04 Bruce Momjian <[email protected]>
  0 siblings, 0 replies; 27+ messages in thread

From: Bruce Momjian @ 2021-01-01 20:04 UTC (permalink / raw)

---
 src/backend/replication/backup_manifest.c |  2 +-
 src/backend/utils/adt/encode.c            | 34 +------------------
 src/backend/utils/adt/varlena.c           |  2 +-
 src/common/Makefile                       |  2 +-
 src/common/{hex_decode.c => hex.c}        | 40 ++++++++++++++++++++---
 src/include/common/hex.h (new)            | 18 ++++++++++
 src/include/common/hex_decode.h (gone)    | 16 ---------
 src/include/utils/builtins.h              |  3 --
 src/tools/msvc/Mkvcbuild.pm               |  2 +-
 9 files changed, 59 insertions(+), 60 deletions(-)

diff --git a/src/backend/replication/backup_manifest.c b/src/backend/replication/backup_manifest.c
index c3f339c556..716f114d78 100644
--- a/src/backend/replication/backup_manifest.c
+++ b/src/backend/replication/backup_manifest.c
@@ -17,7 +17,7 @@
 #include "libpq/pqformat.h"
 #include "mb/pg_wchar.h"
 #include "replication/backup_manifest.h"
-#include "utils/builtins.h"
+#include "common/hex.h"
 #include "utils/json.h"
 
 static void AppendStringToManifest(backup_manifest_info *manifest, char *s);
diff --git a/src/backend/utils/adt/encode.c b/src/backend/utils/adt/encode.c
index a6c65b1657..bca941a496 100644
--- a/src/backend/utils/adt/encode.c
+++ b/src/backend/utils/adt/encode.c
@@ -15,7 +15,7 @@
 
 #include <ctype.h>
 
-#include "common/hex_decode.h"
+#include "common/hex.h"
 #include "mb/pg_wchar.h"
 #include "utils/builtins.h"
 #include "utils/memutils.h"
@@ -141,38 +141,6 @@ binary_decode(PG_FUNCTION_ARGS)
 }
 
 
-/*
- * HEX
- */
-
-static const char hextbl[] = "0123456789abcdef";
-
-uint64
-hex_encode(const char *src, size_t len, char *dst)
-{
-	const char *end = src + len;
-
-	while (src < end)
-	{
-		*dst++ = hextbl[(*src >> 4) & 0xF];
-		*dst++ = hextbl[*src & 0xF];
-		src++;
-	}
-	return (uint64) len * 2;
-}
-
-static uint64
-hex_enc_len(const char *src, size_t srclen)
-{
-	return (uint64) srclen << 1;
-}
-
-static uint64
-hex_dec_len(const char *src, size_t srclen)
-{
-	return (uint64) srclen >> 1;
-}
-
 /*
  * BASE64
  */
diff --git a/src/backend/utils/adt/varlena.c b/src/backend/utils/adt/varlena.c
index 9300d19e0c..79fcdcd178 100644
--- a/src/backend/utils/adt/varlena.c
+++ b/src/backend/utils/adt/varlena.c
@@ -22,7 +22,7 @@
 #include "catalog/pg_type.h"
 #include "common/hashfn.h"
 #include "common/int.h"
-#include "common/hex_decode.h"
+#include "common/hex.h"
 #include "common/unicode_norm.h"
 #include "lib/hyperloglog.h"
 #include "libpq/pqformat.h"
diff --git a/src/common/Makefile b/src/common/Makefile
index f624977939..93eb27a2aa 100644
--- a/src/common/Makefile
+++ b/src/common/Makefile
@@ -58,7 +58,7 @@ OBJS_COMMON = \
 	file_perm.o \
 	file_utils.o \
 	hashfn.o \
-	hex_decode.o \
+	hex.o \
 	ip.o \
 	jsonapi.o \
 	keywords.o \
diff --git a/src/common/hex_decode.c b/src/common/hex.c
similarity index 79%
rename from src/common/hex_decode.c
rename to src/common/hex.c
index 3ecdc73b5c..97f57bcc32 100644
--- a/src/common/hex_decode.c
+++ b/src/common/hex.c
@@ -1,7 +1,7 @@
 /*-------------------------------------------------------------------------
  *
- * hex_decode.c
- *		hex decoding
+ * hex.c
+ *		hex processing
  *
  *
  * Portions Copyright (c) 1996-2020, PostgreSQL Global Development Group
@@ -9,7 +9,7 @@
  *
  *
  * IDENTIFICATION
- *	  src/common/hex_decode.c
+ *	  src/common/hex.c
  *
  *-------------------------------------------------------------------------
  */
@@ -26,7 +26,7 @@
 #else
 #include "mb/pg_wchar.h"
 #endif
-#include "common/hex_decode.h"
+#include "common/hex.h"
 
 
 static const int8 hexlookup[128] = {
@@ -40,6 +40,26 @@ static const int8 hexlookup[128] = {
 	-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
 };
 
+/*
+ * HEX
+ */
+
+static const char hextbl[] = "0123456789abcdef";
+
+uint64
+hex_encode(const char *src, size_t len, char *dst)
+{
+	const char *end = src + len;
+
+	while (src < end)
+	{
+		*dst++ = hextbl[(*src >> 4) & 0xF];
+		*dst++ = hextbl[*src & 0xF];
+		src++;
+	}
+	return (uint64) len * 2;
+}
+
 static inline char
 get_hex(const char *cp)
 {
@@ -104,3 +124,15 @@ hex_decode(const char *src, size_t len, char *dst)
 
 	return p - dst;
 }
+
+uint64
+hex_enc_len(const char *src, size_t srclen)
+{
+	return (uint64) srclen << 1;
+}
+
+uint64
+hex_dec_len(const char *src, size_t srclen)
+{
+	return (uint64) srclen >> 1;
+}
diff --git a/src/include/common/hex.h b/src/include/common/hex.h
new file mode 100644
index 0000000000..76154b65af
--- /dev/null
+++ b/src/include/common/hex.h
@@ -0,0 +1,18 @@
+/*
+ *	hex.h
+ *		hex processing
+ *
+ *	Portions Copyright (c) 1996-2020, PostgreSQL Global Development Group
+ *	Portions Copyright (c) 1994, Regents of the University of California
+ *
+ *	src/include/common/hex.h
+ */
+#ifndef COMMON_HEX_H
+#define COMMON_HEX_H
+
+extern uint64 hex_decode(const char *src, size_t len, char *dst);
+extern uint64 hex_encode(const char *src, size_t len, char *dst);
+extern uint64 hex_enc_len(const char *src, size_t srclen);
+extern uint64 hex_dec_len(const char *src, size_t srclen);
+
+#endif							/* COMMON_HEX_H */
diff --git a/src/include/common/hex_decode.h b/src/include/common/hex_decode.h
deleted file mode 100644
index 1f99f069b2..0000000000
--- a/src/include/common/hex_decode.h
+++ /dev/null
@@ -1,16 +0,0 @@
-/*
- *	hex_decode.h
- *		hex decoding
- *
- *	Portions Copyright (c) 1996-2020, PostgreSQL Global Development Group
- *	Portions Copyright (c) 1994, Regents of the University of California
- *
- *	src/include/common/hex_decode.h
- */
-#ifndef COMMON_HEX_DECODE_H
-#define COMMON_HEX_DECODE_H
-
-extern uint64 hex_decode(const char *src, size_t len, char *dst);
-
-
-#endif							/* COMMON_HEX_DECODE_H */
diff --git a/src/include/utils/builtins.h b/src/include/utils/builtins.h
index 19271e0696..11ba6ae565 100644
--- a/src/include/utils/builtins.h
+++ b/src/include/utils/builtins.h
@@ -31,9 +31,6 @@ extern void domain_check(Datum value, bool isnull, Oid domainType,
 extern int	errdatatype(Oid datatypeOid);
 extern int	errdomainconstraint(Oid datatypeOid, const char *conname);
 
-/* encode.c */
-extern uint64 hex_encode(const char *src, size_t len, char *dst);
-
 /* int.c */
 extern int2vector *buildint2vector(const int16 *int2s, int n);
 
diff --git a/src/tools/msvc/Mkvcbuild.pm b/src/tools/msvc/Mkvcbuild.pm
index 7f014a12c9..60b216cce0 100644
--- a/src/tools/msvc/Mkvcbuild.pm
+++ b/src/tools/msvc/Mkvcbuild.pm
@@ -121,7 +121,7 @@ sub mkvcbuild
 	our @pgcommonallfiles = qw(
 	  archive.c base64.c checksum_helper.c
 	  config_info.c controldata_utils.c d2s.c encnames.c exec.c
-	  f2s.c file_perm.c file_utils.c hashfn.c hex_decode.c ip.c jsonapi.c
+	  f2s.c file_perm.c file_utils.c hashfn.c hex.c ip.c jsonapi.c
 	  keywords.c kwlookup.c link-canary.c md5_common.c
 	  pg_get_line.c pg_lzcompress.c pgfnames.c psprintf.c relpath.c rmtree.c
 	  saslprep.c scram-common.c string.c stringinfo.c unicode_norm.c username.c
-- 
2.20.1


--IJpNTDwzlM2Ie8A6--





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

* [PATCH] hex squash commit
@ 2021-01-01 20:04 Bruce Momjian <[email protected]>
  0 siblings, 0 replies; 27+ messages in thread

From: Bruce Momjian @ 2021-01-01 20:04 UTC (permalink / raw)

---
 src/backend/replication/backup_manifest.c |  2 +-
 src/backend/utils/adt/encode.c            | 34 +------------------
 src/backend/utils/adt/varlena.c           |  2 +-
 src/common/Makefile                       |  2 +-
 src/common/{hex_decode.c => hex.c}        | 40 ++++++++++++++++++++---
 src/include/common/hex.h (new)            | 18 ++++++++++
 src/include/common/hex_decode.h (gone)    | 16 ---------
 src/include/utils/builtins.h              |  3 --
 src/tools/msvc/Mkvcbuild.pm               |  2 +-
 9 files changed, 59 insertions(+), 60 deletions(-)

diff --git a/src/backend/replication/backup_manifest.c b/src/backend/replication/backup_manifest.c
index c3f339c556..716f114d78 100644
--- a/src/backend/replication/backup_manifest.c
+++ b/src/backend/replication/backup_manifest.c
@@ -17,7 +17,7 @@
 #include "libpq/pqformat.h"
 #include "mb/pg_wchar.h"
 #include "replication/backup_manifest.h"
-#include "utils/builtins.h"
+#include "common/hex.h"
 #include "utils/json.h"
 
 static void AppendStringToManifest(backup_manifest_info *manifest, char *s);
diff --git a/src/backend/utils/adt/encode.c b/src/backend/utils/adt/encode.c
index a6c65b1657..bca941a496 100644
--- a/src/backend/utils/adt/encode.c
+++ b/src/backend/utils/adt/encode.c
@@ -15,7 +15,7 @@
 
 #include <ctype.h>
 
-#include "common/hex_decode.h"
+#include "common/hex.h"
 #include "mb/pg_wchar.h"
 #include "utils/builtins.h"
 #include "utils/memutils.h"
@@ -141,38 +141,6 @@ binary_decode(PG_FUNCTION_ARGS)
 }
 
 
-/*
- * HEX
- */
-
-static const char hextbl[] = "0123456789abcdef";
-
-uint64
-hex_encode(const char *src, size_t len, char *dst)
-{
-	const char *end = src + len;
-
-	while (src < end)
-	{
-		*dst++ = hextbl[(*src >> 4) & 0xF];
-		*dst++ = hextbl[*src & 0xF];
-		src++;
-	}
-	return (uint64) len * 2;
-}
-
-static uint64
-hex_enc_len(const char *src, size_t srclen)
-{
-	return (uint64) srclen << 1;
-}
-
-static uint64
-hex_dec_len(const char *src, size_t srclen)
-{
-	return (uint64) srclen >> 1;
-}
-
 /*
  * BASE64
  */
diff --git a/src/backend/utils/adt/varlena.c b/src/backend/utils/adt/varlena.c
index 9300d19e0c..79fcdcd178 100644
--- a/src/backend/utils/adt/varlena.c
+++ b/src/backend/utils/adt/varlena.c
@@ -22,7 +22,7 @@
 #include "catalog/pg_type.h"
 #include "common/hashfn.h"
 #include "common/int.h"
-#include "common/hex_decode.h"
+#include "common/hex.h"
 #include "common/unicode_norm.h"
 #include "lib/hyperloglog.h"
 #include "libpq/pqformat.h"
diff --git a/src/common/Makefile b/src/common/Makefile
index f624977939..93eb27a2aa 100644
--- a/src/common/Makefile
+++ b/src/common/Makefile
@@ -58,7 +58,7 @@ OBJS_COMMON = \
 	file_perm.o \
 	file_utils.o \
 	hashfn.o \
-	hex_decode.o \
+	hex.o \
 	ip.o \
 	jsonapi.o \
 	keywords.o \
diff --git a/src/common/hex_decode.c b/src/common/hex.c
similarity index 79%
rename from src/common/hex_decode.c
rename to src/common/hex.c
index 3ecdc73b5c..97f57bcc32 100644
--- a/src/common/hex_decode.c
+++ b/src/common/hex.c
@@ -1,7 +1,7 @@
 /*-------------------------------------------------------------------------
  *
- * hex_decode.c
- *		hex decoding
+ * hex.c
+ *		hex processing
  *
  *
  * Portions Copyright (c) 1996-2020, PostgreSQL Global Development Group
@@ -9,7 +9,7 @@
  *
  *
  * IDENTIFICATION
- *	  src/common/hex_decode.c
+ *	  src/common/hex.c
  *
  *-------------------------------------------------------------------------
  */
@@ -26,7 +26,7 @@
 #else
 #include "mb/pg_wchar.h"
 #endif
-#include "common/hex_decode.h"
+#include "common/hex.h"
 
 
 static const int8 hexlookup[128] = {
@@ -40,6 +40,26 @@ static const int8 hexlookup[128] = {
 	-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
 };
 
+/*
+ * HEX
+ */
+
+static const char hextbl[] = "0123456789abcdef";
+
+uint64
+hex_encode(const char *src, size_t len, char *dst)
+{
+	const char *end = src + len;
+
+	while (src < end)
+	{
+		*dst++ = hextbl[(*src >> 4) & 0xF];
+		*dst++ = hextbl[*src & 0xF];
+		src++;
+	}
+	return (uint64) len * 2;
+}
+
 static inline char
 get_hex(const char *cp)
 {
@@ -104,3 +124,15 @@ hex_decode(const char *src, size_t len, char *dst)
 
 	return p - dst;
 }
+
+uint64
+hex_enc_len(const char *src, size_t srclen)
+{
+	return (uint64) srclen << 1;
+}
+
+uint64
+hex_dec_len(const char *src, size_t srclen)
+{
+	return (uint64) srclen >> 1;
+}
diff --git a/src/include/common/hex.h b/src/include/common/hex.h
new file mode 100644
index 0000000000..76154b65af
--- /dev/null
+++ b/src/include/common/hex.h
@@ -0,0 +1,18 @@
+/*
+ *	hex.h
+ *		hex processing
+ *
+ *	Portions Copyright (c) 1996-2020, PostgreSQL Global Development Group
+ *	Portions Copyright (c) 1994, Regents of the University of California
+ *
+ *	src/include/common/hex.h
+ */
+#ifndef COMMON_HEX_H
+#define COMMON_HEX_H
+
+extern uint64 hex_decode(const char *src, size_t len, char *dst);
+extern uint64 hex_encode(const char *src, size_t len, char *dst);
+extern uint64 hex_enc_len(const char *src, size_t srclen);
+extern uint64 hex_dec_len(const char *src, size_t srclen);
+
+#endif							/* COMMON_HEX_H */
diff --git a/src/include/common/hex_decode.h b/src/include/common/hex_decode.h
deleted file mode 100644
index 1f99f069b2..0000000000
--- a/src/include/common/hex_decode.h
+++ /dev/null
@@ -1,16 +0,0 @@
-/*
- *	hex_decode.h
- *		hex decoding
- *
- *	Portions Copyright (c) 1996-2020, PostgreSQL Global Development Group
- *	Portions Copyright (c) 1994, Regents of the University of California
- *
- *	src/include/common/hex_decode.h
- */
-#ifndef COMMON_HEX_DECODE_H
-#define COMMON_HEX_DECODE_H
-
-extern uint64 hex_decode(const char *src, size_t len, char *dst);
-
-
-#endif							/* COMMON_HEX_DECODE_H */
diff --git a/src/include/utils/builtins.h b/src/include/utils/builtins.h
index 19271e0696..11ba6ae565 100644
--- a/src/include/utils/builtins.h
+++ b/src/include/utils/builtins.h
@@ -31,9 +31,6 @@ extern void domain_check(Datum value, bool isnull, Oid domainType,
 extern int	errdatatype(Oid datatypeOid);
 extern int	errdomainconstraint(Oid datatypeOid, const char *conname);
 
-/* encode.c */
-extern uint64 hex_encode(const char *src, size_t len, char *dst);
-
 /* int.c */
 extern int2vector *buildint2vector(const int16 *int2s, int n);
 
diff --git a/src/tools/msvc/Mkvcbuild.pm b/src/tools/msvc/Mkvcbuild.pm
index 7f014a12c9..60b216cce0 100644
--- a/src/tools/msvc/Mkvcbuild.pm
+++ b/src/tools/msvc/Mkvcbuild.pm
@@ -121,7 +121,7 @@ sub mkvcbuild
 	our @pgcommonallfiles = qw(
 	  archive.c base64.c checksum_helper.c
 	  config_info.c controldata_utils.c d2s.c encnames.c exec.c
-	  f2s.c file_perm.c file_utils.c hashfn.c hex_decode.c ip.c jsonapi.c
+	  f2s.c file_perm.c file_utils.c hashfn.c hex.c ip.c jsonapi.c
 	  keywords.c kwlookup.c link-canary.c md5_common.c
 	  pg_get_line.c pg_lzcompress.c pgfnames.c psprintf.c relpath.c rmtree.c
 	  saslprep.c scram-common.c string.c stringinfo.c unicode_norm.c username.c
-- 
2.20.1


--IJpNTDwzlM2Ie8A6--





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

* [PATCH] hex squash commit
@ 2021-01-01 20:04 Bruce Momjian <[email protected]>
  0 siblings, 0 replies; 27+ messages in thread

From: Bruce Momjian @ 2021-01-01 20:04 UTC (permalink / raw)

---
 src/backend/replication/backup_manifest.c |  2 +-
 src/backend/utils/adt/encode.c            | 34 +------------------
 src/backend/utils/adt/varlena.c           |  2 +-
 src/common/Makefile                       |  2 +-
 src/common/{hex_decode.c => hex.c}        | 40 ++++++++++++++++++++---
 src/include/common/hex.h (new)            | 18 ++++++++++
 src/include/common/hex_decode.h (gone)    | 16 ---------
 src/include/utils/builtins.h              |  3 --
 src/tools/msvc/Mkvcbuild.pm               |  2 +-
 9 files changed, 59 insertions(+), 60 deletions(-)

diff --git a/src/backend/replication/backup_manifest.c b/src/backend/replication/backup_manifest.c
index c3f339c556..716f114d78 100644
--- a/src/backend/replication/backup_manifest.c
+++ b/src/backend/replication/backup_manifest.c
@@ -17,7 +17,7 @@
 #include "libpq/pqformat.h"
 #include "mb/pg_wchar.h"
 #include "replication/backup_manifest.h"
-#include "utils/builtins.h"
+#include "common/hex.h"
 #include "utils/json.h"
 
 static void AppendStringToManifest(backup_manifest_info *manifest, char *s);
diff --git a/src/backend/utils/adt/encode.c b/src/backend/utils/adt/encode.c
index a6c65b1657..bca941a496 100644
--- a/src/backend/utils/adt/encode.c
+++ b/src/backend/utils/adt/encode.c
@@ -15,7 +15,7 @@
 
 #include <ctype.h>
 
-#include "common/hex_decode.h"
+#include "common/hex.h"
 #include "mb/pg_wchar.h"
 #include "utils/builtins.h"
 #include "utils/memutils.h"
@@ -141,38 +141,6 @@ binary_decode(PG_FUNCTION_ARGS)
 }
 
 
-/*
- * HEX
- */
-
-static const char hextbl[] = "0123456789abcdef";
-
-uint64
-hex_encode(const char *src, size_t len, char *dst)
-{
-	const char *end = src + len;
-
-	while (src < end)
-	{
-		*dst++ = hextbl[(*src >> 4) & 0xF];
-		*dst++ = hextbl[*src & 0xF];
-		src++;
-	}
-	return (uint64) len * 2;
-}
-
-static uint64
-hex_enc_len(const char *src, size_t srclen)
-{
-	return (uint64) srclen << 1;
-}
-
-static uint64
-hex_dec_len(const char *src, size_t srclen)
-{
-	return (uint64) srclen >> 1;
-}
-
 /*
  * BASE64
  */
diff --git a/src/backend/utils/adt/varlena.c b/src/backend/utils/adt/varlena.c
index 9300d19e0c..79fcdcd178 100644
--- a/src/backend/utils/adt/varlena.c
+++ b/src/backend/utils/adt/varlena.c
@@ -22,7 +22,7 @@
 #include "catalog/pg_type.h"
 #include "common/hashfn.h"
 #include "common/int.h"
-#include "common/hex_decode.h"
+#include "common/hex.h"
 #include "common/unicode_norm.h"
 #include "lib/hyperloglog.h"
 #include "libpq/pqformat.h"
diff --git a/src/common/Makefile b/src/common/Makefile
index f624977939..93eb27a2aa 100644
--- a/src/common/Makefile
+++ b/src/common/Makefile
@@ -58,7 +58,7 @@ OBJS_COMMON = \
 	file_perm.o \
 	file_utils.o \
 	hashfn.o \
-	hex_decode.o \
+	hex.o \
 	ip.o \
 	jsonapi.o \
 	keywords.o \
diff --git a/src/common/hex_decode.c b/src/common/hex.c
similarity index 79%
rename from src/common/hex_decode.c
rename to src/common/hex.c
index 3ecdc73b5c..97f57bcc32 100644
--- a/src/common/hex_decode.c
+++ b/src/common/hex.c
@@ -1,7 +1,7 @@
 /*-------------------------------------------------------------------------
  *
- * hex_decode.c
- *		hex decoding
+ * hex.c
+ *		hex processing
  *
  *
  * Portions Copyright (c) 1996-2020, PostgreSQL Global Development Group
@@ -9,7 +9,7 @@
  *
  *
  * IDENTIFICATION
- *	  src/common/hex_decode.c
+ *	  src/common/hex.c
  *
  *-------------------------------------------------------------------------
  */
@@ -26,7 +26,7 @@
 #else
 #include "mb/pg_wchar.h"
 #endif
-#include "common/hex_decode.h"
+#include "common/hex.h"
 
 
 static const int8 hexlookup[128] = {
@@ -40,6 +40,26 @@ static const int8 hexlookup[128] = {
 	-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
 };
 
+/*
+ * HEX
+ */
+
+static const char hextbl[] = "0123456789abcdef";
+
+uint64
+hex_encode(const char *src, size_t len, char *dst)
+{
+	const char *end = src + len;
+
+	while (src < end)
+	{
+		*dst++ = hextbl[(*src >> 4) & 0xF];
+		*dst++ = hextbl[*src & 0xF];
+		src++;
+	}
+	return (uint64) len * 2;
+}
+
 static inline char
 get_hex(const char *cp)
 {
@@ -104,3 +124,15 @@ hex_decode(const char *src, size_t len, char *dst)
 
 	return p - dst;
 }
+
+uint64
+hex_enc_len(const char *src, size_t srclen)
+{
+	return (uint64) srclen << 1;
+}
+
+uint64
+hex_dec_len(const char *src, size_t srclen)
+{
+	return (uint64) srclen >> 1;
+}
diff --git a/src/include/common/hex.h b/src/include/common/hex.h
new file mode 100644
index 0000000000..76154b65af
--- /dev/null
+++ b/src/include/common/hex.h
@@ -0,0 +1,18 @@
+/*
+ *	hex.h
+ *		hex processing
+ *
+ *	Portions Copyright (c) 1996-2020, PostgreSQL Global Development Group
+ *	Portions Copyright (c) 1994, Regents of the University of California
+ *
+ *	src/include/common/hex.h
+ */
+#ifndef COMMON_HEX_H
+#define COMMON_HEX_H
+
+extern uint64 hex_decode(const char *src, size_t len, char *dst);
+extern uint64 hex_encode(const char *src, size_t len, char *dst);
+extern uint64 hex_enc_len(const char *src, size_t srclen);
+extern uint64 hex_dec_len(const char *src, size_t srclen);
+
+#endif							/* COMMON_HEX_H */
diff --git a/src/include/common/hex_decode.h b/src/include/common/hex_decode.h
deleted file mode 100644
index 1f99f069b2..0000000000
--- a/src/include/common/hex_decode.h
+++ /dev/null
@@ -1,16 +0,0 @@
-/*
- *	hex_decode.h
- *		hex decoding
- *
- *	Portions Copyright (c) 1996-2020, PostgreSQL Global Development Group
- *	Portions Copyright (c) 1994, Regents of the University of California
- *
- *	src/include/common/hex_decode.h
- */
-#ifndef COMMON_HEX_DECODE_H
-#define COMMON_HEX_DECODE_H
-
-extern uint64 hex_decode(const char *src, size_t len, char *dst);
-
-
-#endif							/* COMMON_HEX_DECODE_H */
diff --git a/src/include/utils/builtins.h b/src/include/utils/builtins.h
index 19271e0696..11ba6ae565 100644
--- a/src/include/utils/builtins.h
+++ b/src/include/utils/builtins.h
@@ -31,9 +31,6 @@ extern void domain_check(Datum value, bool isnull, Oid domainType,
 extern int	errdatatype(Oid datatypeOid);
 extern int	errdomainconstraint(Oid datatypeOid, const char *conname);
 
-/* encode.c */
-extern uint64 hex_encode(const char *src, size_t len, char *dst);
-
 /* int.c */
 extern int2vector *buildint2vector(const int16 *int2s, int n);
 
diff --git a/src/tools/msvc/Mkvcbuild.pm b/src/tools/msvc/Mkvcbuild.pm
index 7f014a12c9..60b216cce0 100644
--- a/src/tools/msvc/Mkvcbuild.pm
+++ b/src/tools/msvc/Mkvcbuild.pm
@@ -121,7 +121,7 @@ sub mkvcbuild
 	our @pgcommonallfiles = qw(
 	  archive.c base64.c checksum_helper.c
 	  config_info.c controldata_utils.c d2s.c encnames.c exec.c
-	  f2s.c file_perm.c file_utils.c hashfn.c hex_decode.c ip.c jsonapi.c
+	  f2s.c file_perm.c file_utils.c hashfn.c hex.c ip.c jsonapi.c
 	  keywords.c kwlookup.c link-canary.c md5_common.c
 	  pg_get_line.c pg_lzcompress.c pgfnames.c psprintf.c relpath.c rmtree.c
 	  saslprep.c scram-common.c string.c stringinfo.c unicode_norm.c username.c
-- 
2.20.1


--IJpNTDwzlM2Ie8A6--





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

* [PATCH] hex squash commit
@ 2021-01-01 20:04 Bruce Momjian <[email protected]>
  0 siblings, 0 replies; 27+ messages in thread

From: Bruce Momjian @ 2021-01-01 20:04 UTC (permalink / raw)

---
 src/backend/replication/backup_manifest.c |  2 +-
 src/backend/utils/adt/encode.c            | 34 +------------------
 src/backend/utils/adt/varlena.c           |  2 +-
 src/common/Makefile                       |  2 +-
 src/common/{hex_decode.c => hex.c}        | 40 ++++++++++++++++++++---
 src/include/common/hex.h (new)            | 18 ++++++++++
 src/include/common/hex_decode.h (gone)    | 16 ---------
 src/include/utils/builtins.h              |  3 --
 src/tools/msvc/Mkvcbuild.pm               |  2 +-
 9 files changed, 59 insertions(+), 60 deletions(-)

diff --git a/src/backend/replication/backup_manifest.c b/src/backend/replication/backup_manifest.c
index c3f339c556..716f114d78 100644
--- a/src/backend/replication/backup_manifest.c
+++ b/src/backend/replication/backup_manifest.c
@@ -17,7 +17,7 @@
 #include "libpq/pqformat.h"
 #include "mb/pg_wchar.h"
 #include "replication/backup_manifest.h"
-#include "utils/builtins.h"
+#include "common/hex.h"
 #include "utils/json.h"
 
 static void AppendStringToManifest(backup_manifest_info *manifest, char *s);
diff --git a/src/backend/utils/adt/encode.c b/src/backend/utils/adt/encode.c
index a6c65b1657..bca941a496 100644
--- a/src/backend/utils/adt/encode.c
+++ b/src/backend/utils/adt/encode.c
@@ -15,7 +15,7 @@
 
 #include <ctype.h>
 
-#include "common/hex_decode.h"
+#include "common/hex.h"
 #include "mb/pg_wchar.h"
 #include "utils/builtins.h"
 #include "utils/memutils.h"
@@ -141,38 +141,6 @@ binary_decode(PG_FUNCTION_ARGS)
 }
 
 
-/*
- * HEX
- */
-
-static const char hextbl[] = "0123456789abcdef";
-
-uint64
-hex_encode(const char *src, size_t len, char *dst)
-{
-	const char *end = src + len;
-
-	while (src < end)
-	{
-		*dst++ = hextbl[(*src >> 4) & 0xF];
-		*dst++ = hextbl[*src & 0xF];
-		src++;
-	}
-	return (uint64) len * 2;
-}
-
-static uint64
-hex_enc_len(const char *src, size_t srclen)
-{
-	return (uint64) srclen << 1;
-}
-
-static uint64
-hex_dec_len(const char *src, size_t srclen)
-{
-	return (uint64) srclen >> 1;
-}
-
 /*
  * BASE64
  */
diff --git a/src/backend/utils/adt/varlena.c b/src/backend/utils/adt/varlena.c
index 9300d19e0c..79fcdcd178 100644
--- a/src/backend/utils/adt/varlena.c
+++ b/src/backend/utils/adt/varlena.c
@@ -22,7 +22,7 @@
 #include "catalog/pg_type.h"
 #include "common/hashfn.h"
 #include "common/int.h"
-#include "common/hex_decode.h"
+#include "common/hex.h"
 #include "common/unicode_norm.h"
 #include "lib/hyperloglog.h"
 #include "libpq/pqformat.h"
diff --git a/src/common/Makefile b/src/common/Makefile
index f624977939..93eb27a2aa 100644
--- a/src/common/Makefile
+++ b/src/common/Makefile
@@ -58,7 +58,7 @@ OBJS_COMMON = \
 	file_perm.o \
 	file_utils.o \
 	hashfn.o \
-	hex_decode.o \
+	hex.o \
 	ip.o \
 	jsonapi.o \
 	keywords.o \
diff --git a/src/common/hex_decode.c b/src/common/hex.c
similarity index 79%
rename from src/common/hex_decode.c
rename to src/common/hex.c
index 3ecdc73b5c..97f57bcc32 100644
--- a/src/common/hex_decode.c
+++ b/src/common/hex.c
@@ -1,7 +1,7 @@
 /*-------------------------------------------------------------------------
  *
- * hex_decode.c
- *		hex decoding
+ * hex.c
+ *		hex processing
  *
  *
  * Portions Copyright (c) 1996-2020, PostgreSQL Global Development Group
@@ -9,7 +9,7 @@
  *
  *
  * IDENTIFICATION
- *	  src/common/hex_decode.c
+ *	  src/common/hex.c
  *
  *-------------------------------------------------------------------------
  */
@@ -26,7 +26,7 @@
 #else
 #include "mb/pg_wchar.h"
 #endif
-#include "common/hex_decode.h"
+#include "common/hex.h"
 
 
 static const int8 hexlookup[128] = {
@@ -40,6 +40,26 @@ static const int8 hexlookup[128] = {
 	-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
 };
 
+/*
+ * HEX
+ */
+
+static const char hextbl[] = "0123456789abcdef";
+
+uint64
+hex_encode(const char *src, size_t len, char *dst)
+{
+	const char *end = src + len;
+
+	while (src < end)
+	{
+		*dst++ = hextbl[(*src >> 4) & 0xF];
+		*dst++ = hextbl[*src & 0xF];
+		src++;
+	}
+	return (uint64) len * 2;
+}
+
 static inline char
 get_hex(const char *cp)
 {
@@ -104,3 +124,15 @@ hex_decode(const char *src, size_t len, char *dst)
 
 	return p - dst;
 }
+
+uint64
+hex_enc_len(const char *src, size_t srclen)
+{
+	return (uint64) srclen << 1;
+}
+
+uint64
+hex_dec_len(const char *src, size_t srclen)
+{
+	return (uint64) srclen >> 1;
+}
diff --git a/src/include/common/hex.h b/src/include/common/hex.h
new file mode 100644
index 0000000000..76154b65af
--- /dev/null
+++ b/src/include/common/hex.h
@@ -0,0 +1,18 @@
+/*
+ *	hex.h
+ *		hex processing
+ *
+ *	Portions Copyright (c) 1996-2020, PostgreSQL Global Development Group
+ *	Portions Copyright (c) 1994, Regents of the University of California
+ *
+ *	src/include/common/hex.h
+ */
+#ifndef COMMON_HEX_H
+#define COMMON_HEX_H
+
+extern uint64 hex_decode(const char *src, size_t len, char *dst);
+extern uint64 hex_encode(const char *src, size_t len, char *dst);
+extern uint64 hex_enc_len(const char *src, size_t srclen);
+extern uint64 hex_dec_len(const char *src, size_t srclen);
+
+#endif							/* COMMON_HEX_H */
diff --git a/src/include/common/hex_decode.h b/src/include/common/hex_decode.h
deleted file mode 100644
index 1f99f069b2..0000000000
--- a/src/include/common/hex_decode.h
+++ /dev/null
@@ -1,16 +0,0 @@
-/*
- *	hex_decode.h
- *		hex decoding
- *
- *	Portions Copyright (c) 1996-2020, PostgreSQL Global Development Group
- *	Portions Copyright (c) 1994, Regents of the University of California
- *
- *	src/include/common/hex_decode.h
- */
-#ifndef COMMON_HEX_DECODE_H
-#define COMMON_HEX_DECODE_H
-
-extern uint64 hex_decode(const char *src, size_t len, char *dst);
-
-
-#endif							/* COMMON_HEX_DECODE_H */
diff --git a/src/include/utils/builtins.h b/src/include/utils/builtins.h
index 19271e0696..11ba6ae565 100644
--- a/src/include/utils/builtins.h
+++ b/src/include/utils/builtins.h
@@ -31,9 +31,6 @@ extern void domain_check(Datum value, bool isnull, Oid domainType,
 extern int	errdatatype(Oid datatypeOid);
 extern int	errdomainconstraint(Oid datatypeOid, const char *conname);
 
-/* encode.c */
-extern uint64 hex_encode(const char *src, size_t len, char *dst);
-
 /* int.c */
 extern int2vector *buildint2vector(const int16 *int2s, int n);
 
diff --git a/src/tools/msvc/Mkvcbuild.pm b/src/tools/msvc/Mkvcbuild.pm
index 7f014a12c9..60b216cce0 100644
--- a/src/tools/msvc/Mkvcbuild.pm
+++ b/src/tools/msvc/Mkvcbuild.pm
@@ -121,7 +121,7 @@ sub mkvcbuild
 	our @pgcommonallfiles = qw(
 	  archive.c base64.c checksum_helper.c
 	  config_info.c controldata_utils.c d2s.c encnames.c exec.c
-	  f2s.c file_perm.c file_utils.c hashfn.c hex_decode.c ip.c jsonapi.c
+	  f2s.c file_perm.c file_utils.c hashfn.c hex.c ip.c jsonapi.c
 	  keywords.c kwlookup.c link-canary.c md5_common.c
 	  pg_get_line.c pg_lzcompress.c pgfnames.c psprintf.c relpath.c rmtree.c
 	  saslprep.c scram-common.c string.c stringinfo.c unicode_norm.c username.c
-- 
2.20.1


--IJpNTDwzlM2Ie8A6--





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

* [PATCH] hex squash commit
@ 2021-01-01 20:04 Bruce Momjian <[email protected]>
  0 siblings, 0 replies; 27+ messages in thread

From: Bruce Momjian @ 2021-01-01 20:04 UTC (permalink / raw)

---
 src/backend/replication/backup_manifest.c |  2 +-
 src/backend/utils/adt/encode.c            | 34 +------------------
 src/backend/utils/adt/varlena.c           |  2 +-
 src/common/Makefile                       |  2 +-
 src/common/{hex_decode.c => hex.c}        | 40 ++++++++++++++++++++---
 src/include/common/hex.h (new)            | 18 ++++++++++
 src/include/common/hex_decode.h (gone)    | 16 ---------
 src/include/utils/builtins.h              |  3 --
 src/tools/msvc/Mkvcbuild.pm               |  2 +-
 9 files changed, 59 insertions(+), 60 deletions(-)

diff --git a/src/backend/replication/backup_manifest.c b/src/backend/replication/backup_manifest.c
index c3f339c556..716f114d78 100644
--- a/src/backend/replication/backup_manifest.c
+++ b/src/backend/replication/backup_manifest.c
@@ -17,7 +17,7 @@
 #include "libpq/pqformat.h"
 #include "mb/pg_wchar.h"
 #include "replication/backup_manifest.h"
-#include "utils/builtins.h"
+#include "common/hex.h"
 #include "utils/json.h"
 
 static void AppendStringToManifest(backup_manifest_info *manifest, char *s);
diff --git a/src/backend/utils/adt/encode.c b/src/backend/utils/adt/encode.c
index a6c65b1657..bca941a496 100644
--- a/src/backend/utils/adt/encode.c
+++ b/src/backend/utils/adt/encode.c
@@ -15,7 +15,7 @@
 
 #include <ctype.h>
 
-#include "common/hex_decode.h"
+#include "common/hex.h"
 #include "mb/pg_wchar.h"
 #include "utils/builtins.h"
 #include "utils/memutils.h"
@@ -141,38 +141,6 @@ binary_decode(PG_FUNCTION_ARGS)
 }
 
 
-/*
- * HEX
- */
-
-static const char hextbl[] = "0123456789abcdef";
-
-uint64
-hex_encode(const char *src, size_t len, char *dst)
-{
-	const char *end = src + len;
-
-	while (src < end)
-	{
-		*dst++ = hextbl[(*src >> 4) & 0xF];
-		*dst++ = hextbl[*src & 0xF];
-		src++;
-	}
-	return (uint64) len * 2;
-}
-
-static uint64
-hex_enc_len(const char *src, size_t srclen)
-{
-	return (uint64) srclen << 1;
-}
-
-static uint64
-hex_dec_len(const char *src, size_t srclen)
-{
-	return (uint64) srclen >> 1;
-}
-
 /*
  * BASE64
  */
diff --git a/src/backend/utils/adt/varlena.c b/src/backend/utils/adt/varlena.c
index 9300d19e0c..79fcdcd178 100644
--- a/src/backend/utils/adt/varlena.c
+++ b/src/backend/utils/adt/varlena.c
@@ -22,7 +22,7 @@
 #include "catalog/pg_type.h"
 #include "common/hashfn.h"
 #include "common/int.h"
-#include "common/hex_decode.h"
+#include "common/hex.h"
 #include "common/unicode_norm.h"
 #include "lib/hyperloglog.h"
 #include "libpq/pqformat.h"
diff --git a/src/common/Makefile b/src/common/Makefile
index f624977939..93eb27a2aa 100644
--- a/src/common/Makefile
+++ b/src/common/Makefile
@@ -58,7 +58,7 @@ OBJS_COMMON = \
 	file_perm.o \
 	file_utils.o \
 	hashfn.o \
-	hex_decode.o \
+	hex.o \
 	ip.o \
 	jsonapi.o \
 	keywords.o \
diff --git a/src/common/hex_decode.c b/src/common/hex.c
similarity index 79%
rename from src/common/hex_decode.c
rename to src/common/hex.c
index 3ecdc73b5c..97f57bcc32 100644
--- a/src/common/hex_decode.c
+++ b/src/common/hex.c
@@ -1,7 +1,7 @@
 /*-------------------------------------------------------------------------
  *
- * hex_decode.c
- *		hex decoding
+ * hex.c
+ *		hex processing
  *
  *
  * Portions Copyright (c) 1996-2020, PostgreSQL Global Development Group
@@ -9,7 +9,7 @@
  *
  *
  * IDENTIFICATION
- *	  src/common/hex_decode.c
+ *	  src/common/hex.c
  *
  *-------------------------------------------------------------------------
  */
@@ -26,7 +26,7 @@
 #else
 #include "mb/pg_wchar.h"
 #endif
-#include "common/hex_decode.h"
+#include "common/hex.h"
 
 
 static const int8 hexlookup[128] = {
@@ -40,6 +40,26 @@ static const int8 hexlookup[128] = {
 	-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
 };
 
+/*
+ * HEX
+ */
+
+static const char hextbl[] = "0123456789abcdef";
+
+uint64
+hex_encode(const char *src, size_t len, char *dst)
+{
+	const char *end = src + len;
+
+	while (src < end)
+	{
+		*dst++ = hextbl[(*src >> 4) & 0xF];
+		*dst++ = hextbl[*src & 0xF];
+		src++;
+	}
+	return (uint64) len * 2;
+}
+
 static inline char
 get_hex(const char *cp)
 {
@@ -104,3 +124,15 @@ hex_decode(const char *src, size_t len, char *dst)
 
 	return p - dst;
 }
+
+uint64
+hex_enc_len(const char *src, size_t srclen)
+{
+	return (uint64) srclen << 1;
+}
+
+uint64
+hex_dec_len(const char *src, size_t srclen)
+{
+	return (uint64) srclen >> 1;
+}
diff --git a/src/include/common/hex.h b/src/include/common/hex.h
new file mode 100644
index 0000000000..76154b65af
--- /dev/null
+++ b/src/include/common/hex.h
@@ -0,0 +1,18 @@
+/*
+ *	hex.h
+ *		hex processing
+ *
+ *	Portions Copyright (c) 1996-2020, PostgreSQL Global Development Group
+ *	Portions Copyright (c) 1994, Regents of the University of California
+ *
+ *	src/include/common/hex.h
+ */
+#ifndef COMMON_HEX_H
+#define COMMON_HEX_H
+
+extern uint64 hex_decode(const char *src, size_t len, char *dst);
+extern uint64 hex_encode(const char *src, size_t len, char *dst);
+extern uint64 hex_enc_len(const char *src, size_t srclen);
+extern uint64 hex_dec_len(const char *src, size_t srclen);
+
+#endif							/* COMMON_HEX_H */
diff --git a/src/include/common/hex_decode.h b/src/include/common/hex_decode.h
deleted file mode 100644
index 1f99f069b2..0000000000
--- a/src/include/common/hex_decode.h
+++ /dev/null
@@ -1,16 +0,0 @@
-/*
- *	hex_decode.h
- *		hex decoding
- *
- *	Portions Copyright (c) 1996-2020, PostgreSQL Global Development Group
- *	Portions Copyright (c) 1994, Regents of the University of California
- *
- *	src/include/common/hex_decode.h
- */
-#ifndef COMMON_HEX_DECODE_H
-#define COMMON_HEX_DECODE_H
-
-extern uint64 hex_decode(const char *src, size_t len, char *dst);
-
-
-#endif							/* COMMON_HEX_DECODE_H */
diff --git a/src/include/utils/builtins.h b/src/include/utils/builtins.h
index 19271e0696..11ba6ae565 100644
--- a/src/include/utils/builtins.h
+++ b/src/include/utils/builtins.h
@@ -31,9 +31,6 @@ extern void domain_check(Datum value, bool isnull, Oid domainType,
 extern int	errdatatype(Oid datatypeOid);
 extern int	errdomainconstraint(Oid datatypeOid, const char *conname);
 
-/* encode.c */
-extern uint64 hex_encode(const char *src, size_t len, char *dst);
-
 /* int.c */
 extern int2vector *buildint2vector(const int16 *int2s, int n);
 
diff --git a/src/tools/msvc/Mkvcbuild.pm b/src/tools/msvc/Mkvcbuild.pm
index 7f014a12c9..60b216cce0 100644
--- a/src/tools/msvc/Mkvcbuild.pm
+++ b/src/tools/msvc/Mkvcbuild.pm
@@ -121,7 +121,7 @@ sub mkvcbuild
 	our @pgcommonallfiles = qw(
 	  archive.c base64.c checksum_helper.c
 	  config_info.c controldata_utils.c d2s.c encnames.c exec.c
-	  f2s.c file_perm.c file_utils.c hashfn.c hex_decode.c ip.c jsonapi.c
+	  f2s.c file_perm.c file_utils.c hashfn.c hex.c ip.c jsonapi.c
 	  keywords.c kwlookup.c link-canary.c md5_common.c
 	  pg_get_line.c pg_lzcompress.c pgfnames.c psprintf.c relpath.c rmtree.c
 	  saslprep.c scram-common.c string.c stringinfo.c unicode_norm.c username.c
-- 
2.20.1


--IJpNTDwzlM2Ie8A6--





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

* [PATCH] hex squash commit
@ 2021-01-01 20:04 Bruce Momjian <[email protected]>
  0 siblings, 0 replies; 27+ messages in thread

From: Bruce Momjian @ 2021-01-01 20:04 UTC (permalink / raw)

---
 src/backend/replication/backup_manifest.c |  2 +-
 src/backend/utils/adt/encode.c            | 34 +------------------
 src/backend/utils/adt/varlena.c           |  2 +-
 src/common/Makefile                       |  2 +-
 src/common/{hex_decode.c => hex.c}        | 40 ++++++++++++++++++++---
 src/include/common/hex.h (new)            | 18 ++++++++++
 src/include/common/hex_decode.h (gone)    | 16 ---------
 src/include/utils/builtins.h              |  3 --
 src/tools/msvc/Mkvcbuild.pm               |  2 +-
 9 files changed, 59 insertions(+), 60 deletions(-)

diff --git a/src/backend/replication/backup_manifest.c b/src/backend/replication/backup_manifest.c
index c3f339c556..716f114d78 100644
--- a/src/backend/replication/backup_manifest.c
+++ b/src/backend/replication/backup_manifest.c
@@ -17,7 +17,7 @@
 #include "libpq/pqformat.h"
 #include "mb/pg_wchar.h"
 #include "replication/backup_manifest.h"
-#include "utils/builtins.h"
+#include "common/hex.h"
 #include "utils/json.h"
 
 static void AppendStringToManifest(backup_manifest_info *manifest, char *s);
diff --git a/src/backend/utils/adt/encode.c b/src/backend/utils/adt/encode.c
index a6c65b1657..bca941a496 100644
--- a/src/backend/utils/adt/encode.c
+++ b/src/backend/utils/adt/encode.c
@@ -15,7 +15,7 @@
 
 #include <ctype.h>
 
-#include "common/hex_decode.h"
+#include "common/hex.h"
 #include "mb/pg_wchar.h"
 #include "utils/builtins.h"
 #include "utils/memutils.h"
@@ -141,38 +141,6 @@ binary_decode(PG_FUNCTION_ARGS)
 }
 
 
-/*
- * HEX
- */
-
-static const char hextbl[] = "0123456789abcdef";
-
-uint64
-hex_encode(const char *src, size_t len, char *dst)
-{
-	const char *end = src + len;
-
-	while (src < end)
-	{
-		*dst++ = hextbl[(*src >> 4) & 0xF];
-		*dst++ = hextbl[*src & 0xF];
-		src++;
-	}
-	return (uint64) len * 2;
-}
-
-static uint64
-hex_enc_len(const char *src, size_t srclen)
-{
-	return (uint64) srclen << 1;
-}
-
-static uint64
-hex_dec_len(const char *src, size_t srclen)
-{
-	return (uint64) srclen >> 1;
-}
-
 /*
  * BASE64
  */
diff --git a/src/backend/utils/adt/varlena.c b/src/backend/utils/adt/varlena.c
index 9300d19e0c..79fcdcd178 100644
--- a/src/backend/utils/adt/varlena.c
+++ b/src/backend/utils/adt/varlena.c
@@ -22,7 +22,7 @@
 #include "catalog/pg_type.h"
 #include "common/hashfn.h"
 #include "common/int.h"
-#include "common/hex_decode.h"
+#include "common/hex.h"
 #include "common/unicode_norm.h"
 #include "lib/hyperloglog.h"
 #include "libpq/pqformat.h"
diff --git a/src/common/Makefile b/src/common/Makefile
index f624977939..93eb27a2aa 100644
--- a/src/common/Makefile
+++ b/src/common/Makefile
@@ -58,7 +58,7 @@ OBJS_COMMON = \
 	file_perm.o \
 	file_utils.o \
 	hashfn.o \
-	hex_decode.o \
+	hex.o \
 	ip.o \
 	jsonapi.o \
 	keywords.o \
diff --git a/src/common/hex_decode.c b/src/common/hex.c
similarity index 79%
rename from src/common/hex_decode.c
rename to src/common/hex.c
index 3ecdc73b5c..97f57bcc32 100644
--- a/src/common/hex_decode.c
+++ b/src/common/hex.c
@@ -1,7 +1,7 @@
 /*-------------------------------------------------------------------------
  *
- * hex_decode.c
- *		hex decoding
+ * hex.c
+ *		hex processing
  *
  *
  * Portions Copyright (c) 1996-2020, PostgreSQL Global Development Group
@@ -9,7 +9,7 @@
  *
  *
  * IDENTIFICATION
- *	  src/common/hex_decode.c
+ *	  src/common/hex.c
  *
  *-------------------------------------------------------------------------
  */
@@ -26,7 +26,7 @@
 #else
 #include "mb/pg_wchar.h"
 #endif
-#include "common/hex_decode.h"
+#include "common/hex.h"
 
 
 static const int8 hexlookup[128] = {
@@ -40,6 +40,26 @@ static const int8 hexlookup[128] = {
 	-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
 };
 
+/*
+ * HEX
+ */
+
+static const char hextbl[] = "0123456789abcdef";
+
+uint64
+hex_encode(const char *src, size_t len, char *dst)
+{
+	const char *end = src + len;
+
+	while (src < end)
+	{
+		*dst++ = hextbl[(*src >> 4) & 0xF];
+		*dst++ = hextbl[*src & 0xF];
+		src++;
+	}
+	return (uint64) len * 2;
+}
+
 static inline char
 get_hex(const char *cp)
 {
@@ -104,3 +124,15 @@ hex_decode(const char *src, size_t len, char *dst)
 
 	return p - dst;
 }
+
+uint64
+hex_enc_len(const char *src, size_t srclen)
+{
+	return (uint64) srclen << 1;
+}
+
+uint64
+hex_dec_len(const char *src, size_t srclen)
+{
+	return (uint64) srclen >> 1;
+}
diff --git a/src/include/common/hex.h b/src/include/common/hex.h
new file mode 100644
index 0000000000..76154b65af
--- /dev/null
+++ b/src/include/common/hex.h
@@ -0,0 +1,18 @@
+/*
+ *	hex.h
+ *		hex processing
+ *
+ *	Portions Copyright (c) 1996-2020, PostgreSQL Global Development Group
+ *	Portions Copyright (c) 1994, Regents of the University of California
+ *
+ *	src/include/common/hex.h
+ */
+#ifndef COMMON_HEX_H
+#define COMMON_HEX_H
+
+extern uint64 hex_decode(const char *src, size_t len, char *dst);
+extern uint64 hex_encode(const char *src, size_t len, char *dst);
+extern uint64 hex_enc_len(const char *src, size_t srclen);
+extern uint64 hex_dec_len(const char *src, size_t srclen);
+
+#endif							/* COMMON_HEX_H */
diff --git a/src/include/common/hex_decode.h b/src/include/common/hex_decode.h
deleted file mode 100644
index 1f99f069b2..0000000000
--- a/src/include/common/hex_decode.h
+++ /dev/null
@@ -1,16 +0,0 @@
-/*
- *	hex_decode.h
- *		hex decoding
- *
- *	Portions Copyright (c) 1996-2020, PostgreSQL Global Development Group
- *	Portions Copyright (c) 1994, Regents of the University of California
- *
- *	src/include/common/hex_decode.h
- */
-#ifndef COMMON_HEX_DECODE_H
-#define COMMON_HEX_DECODE_H
-
-extern uint64 hex_decode(const char *src, size_t len, char *dst);
-
-
-#endif							/* COMMON_HEX_DECODE_H */
diff --git a/src/include/utils/builtins.h b/src/include/utils/builtins.h
index 19271e0696..11ba6ae565 100644
--- a/src/include/utils/builtins.h
+++ b/src/include/utils/builtins.h
@@ -31,9 +31,6 @@ extern void domain_check(Datum value, bool isnull, Oid domainType,
 extern int	errdatatype(Oid datatypeOid);
 extern int	errdomainconstraint(Oid datatypeOid, const char *conname);
 
-/* encode.c */
-extern uint64 hex_encode(const char *src, size_t len, char *dst);
-
 /* int.c */
 extern int2vector *buildint2vector(const int16 *int2s, int n);
 
diff --git a/src/tools/msvc/Mkvcbuild.pm b/src/tools/msvc/Mkvcbuild.pm
index 7f014a12c9..60b216cce0 100644
--- a/src/tools/msvc/Mkvcbuild.pm
+++ b/src/tools/msvc/Mkvcbuild.pm
@@ -121,7 +121,7 @@ sub mkvcbuild
 	our @pgcommonallfiles = qw(
 	  archive.c base64.c checksum_helper.c
 	  config_info.c controldata_utils.c d2s.c encnames.c exec.c
-	  f2s.c file_perm.c file_utils.c hashfn.c hex_decode.c ip.c jsonapi.c
+	  f2s.c file_perm.c file_utils.c hashfn.c hex.c ip.c jsonapi.c
 	  keywords.c kwlookup.c link-canary.c md5_common.c
 	  pg_get_line.c pg_lzcompress.c pgfnames.c psprintf.c relpath.c rmtree.c
 	  saslprep.c scram-common.c string.c stringinfo.c unicode_norm.c username.c
-- 
2.20.1


--IJpNTDwzlM2Ie8A6--





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

* [PATCH] hex squash commit
@ 2021-01-01 20:04 Bruce Momjian <[email protected]>
  0 siblings, 0 replies; 27+ messages in thread

From: Bruce Momjian @ 2021-01-01 20:04 UTC (permalink / raw)

---
 src/backend/replication/backup_manifest.c |  2 +-
 src/backend/utils/adt/encode.c            | 34 +------------------
 src/backend/utils/adt/varlena.c           |  2 +-
 src/common/Makefile                       |  2 +-
 src/common/{hex_decode.c => hex.c}        | 40 ++++++++++++++++++++---
 src/include/common/hex.h (new)            | 18 ++++++++++
 src/include/common/hex_decode.h (gone)    | 16 ---------
 src/include/utils/builtins.h              |  3 --
 src/tools/msvc/Mkvcbuild.pm               |  2 +-
 9 files changed, 59 insertions(+), 60 deletions(-)

diff --git a/src/backend/replication/backup_manifest.c b/src/backend/replication/backup_manifest.c
index c3f339c556..716f114d78 100644
--- a/src/backend/replication/backup_manifest.c
+++ b/src/backend/replication/backup_manifest.c
@@ -17,7 +17,7 @@
 #include "libpq/pqformat.h"
 #include "mb/pg_wchar.h"
 #include "replication/backup_manifest.h"
-#include "utils/builtins.h"
+#include "common/hex.h"
 #include "utils/json.h"
 
 static void AppendStringToManifest(backup_manifest_info *manifest, char *s);
diff --git a/src/backend/utils/adt/encode.c b/src/backend/utils/adt/encode.c
index a6c65b1657..bca941a496 100644
--- a/src/backend/utils/adt/encode.c
+++ b/src/backend/utils/adt/encode.c
@@ -15,7 +15,7 @@
 
 #include <ctype.h>
 
-#include "common/hex_decode.h"
+#include "common/hex.h"
 #include "mb/pg_wchar.h"
 #include "utils/builtins.h"
 #include "utils/memutils.h"
@@ -141,38 +141,6 @@ binary_decode(PG_FUNCTION_ARGS)
 }
 
 
-/*
- * HEX
- */
-
-static const char hextbl[] = "0123456789abcdef";
-
-uint64
-hex_encode(const char *src, size_t len, char *dst)
-{
-	const char *end = src + len;
-
-	while (src < end)
-	{
-		*dst++ = hextbl[(*src >> 4) & 0xF];
-		*dst++ = hextbl[*src & 0xF];
-		src++;
-	}
-	return (uint64) len * 2;
-}
-
-static uint64
-hex_enc_len(const char *src, size_t srclen)
-{
-	return (uint64) srclen << 1;
-}
-
-static uint64
-hex_dec_len(const char *src, size_t srclen)
-{
-	return (uint64) srclen >> 1;
-}
-
 /*
  * BASE64
  */
diff --git a/src/backend/utils/adt/varlena.c b/src/backend/utils/adt/varlena.c
index 9300d19e0c..79fcdcd178 100644
--- a/src/backend/utils/adt/varlena.c
+++ b/src/backend/utils/adt/varlena.c
@@ -22,7 +22,7 @@
 #include "catalog/pg_type.h"
 #include "common/hashfn.h"
 #include "common/int.h"
-#include "common/hex_decode.h"
+#include "common/hex.h"
 #include "common/unicode_norm.h"
 #include "lib/hyperloglog.h"
 #include "libpq/pqformat.h"
diff --git a/src/common/Makefile b/src/common/Makefile
index f624977939..93eb27a2aa 100644
--- a/src/common/Makefile
+++ b/src/common/Makefile
@@ -58,7 +58,7 @@ OBJS_COMMON = \
 	file_perm.o \
 	file_utils.o \
 	hashfn.o \
-	hex_decode.o \
+	hex.o \
 	ip.o \
 	jsonapi.o \
 	keywords.o \
diff --git a/src/common/hex_decode.c b/src/common/hex.c
similarity index 79%
rename from src/common/hex_decode.c
rename to src/common/hex.c
index 3ecdc73b5c..97f57bcc32 100644
--- a/src/common/hex_decode.c
+++ b/src/common/hex.c
@@ -1,7 +1,7 @@
 /*-------------------------------------------------------------------------
  *
- * hex_decode.c
- *		hex decoding
+ * hex.c
+ *		hex processing
  *
  *
  * Portions Copyright (c) 1996-2020, PostgreSQL Global Development Group
@@ -9,7 +9,7 @@
  *
  *
  * IDENTIFICATION
- *	  src/common/hex_decode.c
+ *	  src/common/hex.c
  *
  *-------------------------------------------------------------------------
  */
@@ -26,7 +26,7 @@
 #else
 #include "mb/pg_wchar.h"
 #endif
-#include "common/hex_decode.h"
+#include "common/hex.h"
 
 
 static const int8 hexlookup[128] = {
@@ -40,6 +40,26 @@ static const int8 hexlookup[128] = {
 	-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
 };
 
+/*
+ * HEX
+ */
+
+static const char hextbl[] = "0123456789abcdef";
+
+uint64
+hex_encode(const char *src, size_t len, char *dst)
+{
+	const char *end = src + len;
+
+	while (src < end)
+	{
+		*dst++ = hextbl[(*src >> 4) & 0xF];
+		*dst++ = hextbl[*src & 0xF];
+		src++;
+	}
+	return (uint64) len * 2;
+}
+
 static inline char
 get_hex(const char *cp)
 {
@@ -104,3 +124,15 @@ hex_decode(const char *src, size_t len, char *dst)
 
 	return p - dst;
 }
+
+uint64
+hex_enc_len(const char *src, size_t srclen)
+{
+	return (uint64) srclen << 1;
+}
+
+uint64
+hex_dec_len(const char *src, size_t srclen)
+{
+	return (uint64) srclen >> 1;
+}
diff --git a/src/include/common/hex.h b/src/include/common/hex.h
new file mode 100644
index 0000000000..76154b65af
--- /dev/null
+++ b/src/include/common/hex.h
@@ -0,0 +1,18 @@
+/*
+ *	hex.h
+ *		hex processing
+ *
+ *	Portions Copyright (c) 1996-2020, PostgreSQL Global Development Group
+ *	Portions Copyright (c) 1994, Regents of the University of California
+ *
+ *	src/include/common/hex.h
+ */
+#ifndef COMMON_HEX_H
+#define COMMON_HEX_H
+
+extern uint64 hex_decode(const char *src, size_t len, char *dst);
+extern uint64 hex_encode(const char *src, size_t len, char *dst);
+extern uint64 hex_enc_len(const char *src, size_t srclen);
+extern uint64 hex_dec_len(const char *src, size_t srclen);
+
+#endif							/* COMMON_HEX_H */
diff --git a/src/include/common/hex_decode.h b/src/include/common/hex_decode.h
deleted file mode 100644
index 1f99f069b2..0000000000
--- a/src/include/common/hex_decode.h
+++ /dev/null
@@ -1,16 +0,0 @@
-/*
- *	hex_decode.h
- *		hex decoding
- *
- *	Portions Copyright (c) 1996-2020, PostgreSQL Global Development Group
- *	Portions Copyright (c) 1994, Regents of the University of California
- *
- *	src/include/common/hex_decode.h
- */
-#ifndef COMMON_HEX_DECODE_H
-#define COMMON_HEX_DECODE_H
-
-extern uint64 hex_decode(const char *src, size_t len, char *dst);
-
-
-#endif							/* COMMON_HEX_DECODE_H */
diff --git a/src/include/utils/builtins.h b/src/include/utils/builtins.h
index 19271e0696..11ba6ae565 100644
--- a/src/include/utils/builtins.h
+++ b/src/include/utils/builtins.h
@@ -31,9 +31,6 @@ extern void domain_check(Datum value, bool isnull, Oid domainType,
 extern int	errdatatype(Oid datatypeOid);
 extern int	errdomainconstraint(Oid datatypeOid, const char *conname);
 
-/* encode.c */
-extern uint64 hex_encode(const char *src, size_t len, char *dst);
-
 /* int.c */
 extern int2vector *buildint2vector(const int16 *int2s, int n);
 
diff --git a/src/tools/msvc/Mkvcbuild.pm b/src/tools/msvc/Mkvcbuild.pm
index 7f014a12c9..60b216cce0 100644
--- a/src/tools/msvc/Mkvcbuild.pm
+++ b/src/tools/msvc/Mkvcbuild.pm
@@ -121,7 +121,7 @@ sub mkvcbuild
 	our @pgcommonallfiles = qw(
 	  archive.c base64.c checksum_helper.c
 	  config_info.c controldata_utils.c d2s.c encnames.c exec.c
-	  f2s.c file_perm.c file_utils.c hashfn.c hex_decode.c ip.c jsonapi.c
+	  f2s.c file_perm.c file_utils.c hashfn.c hex.c ip.c jsonapi.c
 	  keywords.c kwlookup.c link-canary.c md5_common.c
 	  pg_get_line.c pg_lzcompress.c pgfnames.c psprintf.c relpath.c rmtree.c
 	  saslprep.c scram-common.c string.c stringinfo.c unicode_norm.c username.c
-- 
2.20.1


--IJpNTDwzlM2Ie8A6--





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

* [PATCH] hex squash commit
@ 2021-01-01 20:04 Bruce Momjian <[email protected]>
  0 siblings, 0 replies; 27+ messages in thread

From: Bruce Momjian @ 2021-01-01 20:04 UTC (permalink / raw)

---
 src/backend/replication/backup_manifest.c |  2 +-
 src/backend/utils/adt/encode.c            | 34 +------------------
 src/backend/utils/adt/varlena.c           |  2 +-
 src/common/Makefile                       |  2 +-
 src/common/{hex_decode.c => hex.c}        | 40 ++++++++++++++++++++---
 src/include/common/hex.h (new)            | 18 ++++++++++
 src/include/common/hex_decode.h (gone)    | 16 ---------
 src/include/utils/builtins.h              |  3 --
 src/tools/msvc/Mkvcbuild.pm               |  2 +-
 9 files changed, 59 insertions(+), 60 deletions(-)

diff --git a/src/backend/replication/backup_manifest.c b/src/backend/replication/backup_manifest.c
index c3f339c556..716f114d78 100644
--- a/src/backend/replication/backup_manifest.c
+++ b/src/backend/replication/backup_manifest.c
@@ -17,7 +17,7 @@
 #include "libpq/pqformat.h"
 #include "mb/pg_wchar.h"
 #include "replication/backup_manifest.h"
-#include "utils/builtins.h"
+#include "common/hex.h"
 #include "utils/json.h"
 
 static void AppendStringToManifest(backup_manifest_info *manifest, char *s);
diff --git a/src/backend/utils/adt/encode.c b/src/backend/utils/adt/encode.c
index a6c65b1657..bca941a496 100644
--- a/src/backend/utils/adt/encode.c
+++ b/src/backend/utils/adt/encode.c
@@ -15,7 +15,7 @@
 
 #include <ctype.h>
 
-#include "common/hex_decode.h"
+#include "common/hex.h"
 #include "mb/pg_wchar.h"
 #include "utils/builtins.h"
 #include "utils/memutils.h"
@@ -141,38 +141,6 @@ binary_decode(PG_FUNCTION_ARGS)
 }
 
 
-/*
- * HEX
- */
-
-static const char hextbl[] = "0123456789abcdef";
-
-uint64
-hex_encode(const char *src, size_t len, char *dst)
-{
-	const char *end = src + len;
-
-	while (src < end)
-	{
-		*dst++ = hextbl[(*src >> 4) & 0xF];
-		*dst++ = hextbl[*src & 0xF];
-		src++;
-	}
-	return (uint64) len * 2;
-}
-
-static uint64
-hex_enc_len(const char *src, size_t srclen)
-{
-	return (uint64) srclen << 1;
-}
-
-static uint64
-hex_dec_len(const char *src, size_t srclen)
-{
-	return (uint64) srclen >> 1;
-}
-
 /*
  * BASE64
  */
diff --git a/src/backend/utils/adt/varlena.c b/src/backend/utils/adt/varlena.c
index 9300d19e0c..79fcdcd178 100644
--- a/src/backend/utils/adt/varlena.c
+++ b/src/backend/utils/adt/varlena.c
@@ -22,7 +22,7 @@
 #include "catalog/pg_type.h"
 #include "common/hashfn.h"
 #include "common/int.h"
-#include "common/hex_decode.h"
+#include "common/hex.h"
 #include "common/unicode_norm.h"
 #include "lib/hyperloglog.h"
 #include "libpq/pqformat.h"
diff --git a/src/common/Makefile b/src/common/Makefile
index f624977939..93eb27a2aa 100644
--- a/src/common/Makefile
+++ b/src/common/Makefile
@@ -58,7 +58,7 @@ OBJS_COMMON = \
 	file_perm.o \
 	file_utils.o \
 	hashfn.o \
-	hex_decode.o \
+	hex.o \
 	ip.o \
 	jsonapi.o \
 	keywords.o \
diff --git a/src/common/hex_decode.c b/src/common/hex.c
similarity index 79%
rename from src/common/hex_decode.c
rename to src/common/hex.c
index 3ecdc73b5c..97f57bcc32 100644
--- a/src/common/hex_decode.c
+++ b/src/common/hex.c
@@ -1,7 +1,7 @@
 /*-------------------------------------------------------------------------
  *
- * hex_decode.c
- *		hex decoding
+ * hex.c
+ *		hex processing
  *
  *
  * Portions Copyright (c) 1996-2020, PostgreSQL Global Development Group
@@ -9,7 +9,7 @@
  *
  *
  * IDENTIFICATION
- *	  src/common/hex_decode.c
+ *	  src/common/hex.c
  *
  *-------------------------------------------------------------------------
  */
@@ -26,7 +26,7 @@
 #else
 #include "mb/pg_wchar.h"
 #endif
-#include "common/hex_decode.h"
+#include "common/hex.h"
 
 
 static const int8 hexlookup[128] = {
@@ -40,6 +40,26 @@ static const int8 hexlookup[128] = {
 	-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
 };
 
+/*
+ * HEX
+ */
+
+static const char hextbl[] = "0123456789abcdef";
+
+uint64
+hex_encode(const char *src, size_t len, char *dst)
+{
+	const char *end = src + len;
+
+	while (src < end)
+	{
+		*dst++ = hextbl[(*src >> 4) & 0xF];
+		*dst++ = hextbl[*src & 0xF];
+		src++;
+	}
+	return (uint64) len * 2;
+}
+
 static inline char
 get_hex(const char *cp)
 {
@@ -104,3 +124,15 @@ hex_decode(const char *src, size_t len, char *dst)
 
 	return p - dst;
 }
+
+uint64
+hex_enc_len(const char *src, size_t srclen)
+{
+	return (uint64) srclen << 1;
+}
+
+uint64
+hex_dec_len(const char *src, size_t srclen)
+{
+	return (uint64) srclen >> 1;
+}
diff --git a/src/include/common/hex.h b/src/include/common/hex.h
new file mode 100644
index 0000000000..76154b65af
--- /dev/null
+++ b/src/include/common/hex.h
@@ -0,0 +1,18 @@
+/*
+ *	hex.h
+ *		hex processing
+ *
+ *	Portions Copyright (c) 1996-2020, PostgreSQL Global Development Group
+ *	Portions Copyright (c) 1994, Regents of the University of California
+ *
+ *	src/include/common/hex.h
+ */
+#ifndef COMMON_HEX_H
+#define COMMON_HEX_H
+
+extern uint64 hex_decode(const char *src, size_t len, char *dst);
+extern uint64 hex_encode(const char *src, size_t len, char *dst);
+extern uint64 hex_enc_len(const char *src, size_t srclen);
+extern uint64 hex_dec_len(const char *src, size_t srclen);
+
+#endif							/* COMMON_HEX_H */
diff --git a/src/include/common/hex_decode.h b/src/include/common/hex_decode.h
deleted file mode 100644
index 1f99f069b2..0000000000
--- a/src/include/common/hex_decode.h
+++ /dev/null
@@ -1,16 +0,0 @@
-/*
- *	hex_decode.h
- *		hex decoding
- *
- *	Portions Copyright (c) 1996-2020, PostgreSQL Global Development Group
- *	Portions Copyright (c) 1994, Regents of the University of California
- *
- *	src/include/common/hex_decode.h
- */
-#ifndef COMMON_HEX_DECODE_H
-#define COMMON_HEX_DECODE_H
-
-extern uint64 hex_decode(const char *src, size_t len, char *dst);
-
-
-#endif							/* COMMON_HEX_DECODE_H */
diff --git a/src/include/utils/builtins.h b/src/include/utils/builtins.h
index 19271e0696..11ba6ae565 100644
--- a/src/include/utils/builtins.h
+++ b/src/include/utils/builtins.h
@@ -31,9 +31,6 @@ extern void domain_check(Datum value, bool isnull, Oid domainType,
 extern int	errdatatype(Oid datatypeOid);
 extern int	errdomainconstraint(Oid datatypeOid, const char *conname);
 
-/* encode.c */
-extern uint64 hex_encode(const char *src, size_t len, char *dst);
-
 /* int.c */
 extern int2vector *buildint2vector(const int16 *int2s, int n);
 
diff --git a/src/tools/msvc/Mkvcbuild.pm b/src/tools/msvc/Mkvcbuild.pm
index 7f014a12c9..60b216cce0 100644
--- a/src/tools/msvc/Mkvcbuild.pm
+++ b/src/tools/msvc/Mkvcbuild.pm
@@ -121,7 +121,7 @@ sub mkvcbuild
 	our @pgcommonallfiles = qw(
 	  archive.c base64.c checksum_helper.c
 	  config_info.c controldata_utils.c d2s.c encnames.c exec.c
-	  f2s.c file_perm.c file_utils.c hashfn.c hex_decode.c ip.c jsonapi.c
+	  f2s.c file_perm.c file_utils.c hashfn.c hex.c ip.c jsonapi.c
 	  keywords.c kwlookup.c link-canary.c md5_common.c
 	  pg_get_line.c pg_lzcompress.c pgfnames.c psprintf.c relpath.c rmtree.c
 	  saslprep.c scram-common.c string.c stringinfo.c unicode_norm.c username.c
-- 
2.20.1


--IJpNTDwzlM2Ie8A6--





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

* [PATCH] hex squash commit
@ 2021-01-01 20:04 Bruce Momjian <[email protected]>
  0 siblings, 0 replies; 27+ messages in thread

From: Bruce Momjian @ 2021-01-01 20:04 UTC (permalink / raw)

---
 src/backend/replication/backup_manifest.c |  2 +-
 src/backend/utils/adt/encode.c            | 34 +------------------
 src/backend/utils/adt/varlena.c           |  2 +-
 src/common/Makefile                       |  2 +-
 src/common/{hex_decode.c => hex.c}        | 40 ++++++++++++++++++++---
 src/include/common/hex.h (new)            | 18 ++++++++++
 src/include/common/hex_decode.h (gone)    | 16 ---------
 src/include/utils/builtins.h              |  3 --
 src/tools/msvc/Mkvcbuild.pm               |  2 +-
 9 files changed, 59 insertions(+), 60 deletions(-)

diff --git a/src/backend/replication/backup_manifest.c b/src/backend/replication/backup_manifest.c
index c3f339c556..716f114d78 100644
--- a/src/backend/replication/backup_manifest.c
+++ b/src/backend/replication/backup_manifest.c
@@ -17,7 +17,7 @@
 #include "libpq/pqformat.h"
 #include "mb/pg_wchar.h"
 #include "replication/backup_manifest.h"
-#include "utils/builtins.h"
+#include "common/hex.h"
 #include "utils/json.h"
 
 static void AppendStringToManifest(backup_manifest_info *manifest, char *s);
diff --git a/src/backend/utils/adt/encode.c b/src/backend/utils/adt/encode.c
index a6c65b1657..bca941a496 100644
--- a/src/backend/utils/adt/encode.c
+++ b/src/backend/utils/adt/encode.c
@@ -15,7 +15,7 @@
 
 #include <ctype.h>
 
-#include "common/hex_decode.h"
+#include "common/hex.h"
 #include "mb/pg_wchar.h"
 #include "utils/builtins.h"
 #include "utils/memutils.h"
@@ -141,38 +141,6 @@ binary_decode(PG_FUNCTION_ARGS)
 }
 
 
-/*
- * HEX
- */
-
-static const char hextbl[] = "0123456789abcdef";
-
-uint64
-hex_encode(const char *src, size_t len, char *dst)
-{
-	const char *end = src + len;
-
-	while (src < end)
-	{
-		*dst++ = hextbl[(*src >> 4) & 0xF];
-		*dst++ = hextbl[*src & 0xF];
-		src++;
-	}
-	return (uint64) len * 2;
-}
-
-static uint64
-hex_enc_len(const char *src, size_t srclen)
-{
-	return (uint64) srclen << 1;
-}
-
-static uint64
-hex_dec_len(const char *src, size_t srclen)
-{
-	return (uint64) srclen >> 1;
-}
-
 /*
  * BASE64
  */
diff --git a/src/backend/utils/adt/varlena.c b/src/backend/utils/adt/varlena.c
index 9300d19e0c..79fcdcd178 100644
--- a/src/backend/utils/adt/varlena.c
+++ b/src/backend/utils/adt/varlena.c
@@ -22,7 +22,7 @@
 #include "catalog/pg_type.h"
 #include "common/hashfn.h"
 #include "common/int.h"
-#include "common/hex_decode.h"
+#include "common/hex.h"
 #include "common/unicode_norm.h"
 #include "lib/hyperloglog.h"
 #include "libpq/pqformat.h"
diff --git a/src/common/Makefile b/src/common/Makefile
index f624977939..93eb27a2aa 100644
--- a/src/common/Makefile
+++ b/src/common/Makefile
@@ -58,7 +58,7 @@ OBJS_COMMON = \
 	file_perm.o \
 	file_utils.o \
 	hashfn.o \
-	hex_decode.o \
+	hex.o \
 	ip.o \
 	jsonapi.o \
 	keywords.o \
diff --git a/src/common/hex_decode.c b/src/common/hex.c
similarity index 79%
rename from src/common/hex_decode.c
rename to src/common/hex.c
index 3ecdc73b5c..97f57bcc32 100644
--- a/src/common/hex_decode.c
+++ b/src/common/hex.c
@@ -1,7 +1,7 @@
 /*-------------------------------------------------------------------------
  *
- * hex_decode.c
- *		hex decoding
+ * hex.c
+ *		hex processing
  *
  *
  * Portions Copyright (c) 1996-2020, PostgreSQL Global Development Group
@@ -9,7 +9,7 @@
  *
  *
  * IDENTIFICATION
- *	  src/common/hex_decode.c
+ *	  src/common/hex.c
  *
  *-------------------------------------------------------------------------
  */
@@ -26,7 +26,7 @@
 #else
 #include "mb/pg_wchar.h"
 #endif
-#include "common/hex_decode.h"
+#include "common/hex.h"
 
 
 static const int8 hexlookup[128] = {
@@ -40,6 +40,26 @@ static const int8 hexlookup[128] = {
 	-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
 };
 
+/*
+ * HEX
+ */
+
+static const char hextbl[] = "0123456789abcdef";
+
+uint64
+hex_encode(const char *src, size_t len, char *dst)
+{
+	const char *end = src + len;
+
+	while (src < end)
+	{
+		*dst++ = hextbl[(*src >> 4) & 0xF];
+		*dst++ = hextbl[*src & 0xF];
+		src++;
+	}
+	return (uint64) len * 2;
+}
+
 static inline char
 get_hex(const char *cp)
 {
@@ -104,3 +124,15 @@ hex_decode(const char *src, size_t len, char *dst)
 
 	return p - dst;
 }
+
+uint64
+hex_enc_len(const char *src, size_t srclen)
+{
+	return (uint64) srclen << 1;
+}
+
+uint64
+hex_dec_len(const char *src, size_t srclen)
+{
+	return (uint64) srclen >> 1;
+}
diff --git a/src/include/common/hex.h b/src/include/common/hex.h
new file mode 100644
index 0000000000..76154b65af
--- /dev/null
+++ b/src/include/common/hex.h
@@ -0,0 +1,18 @@
+/*
+ *	hex.h
+ *		hex processing
+ *
+ *	Portions Copyright (c) 1996-2020, PostgreSQL Global Development Group
+ *	Portions Copyright (c) 1994, Regents of the University of California
+ *
+ *	src/include/common/hex.h
+ */
+#ifndef COMMON_HEX_H
+#define COMMON_HEX_H
+
+extern uint64 hex_decode(const char *src, size_t len, char *dst);
+extern uint64 hex_encode(const char *src, size_t len, char *dst);
+extern uint64 hex_enc_len(const char *src, size_t srclen);
+extern uint64 hex_dec_len(const char *src, size_t srclen);
+
+#endif							/* COMMON_HEX_H */
diff --git a/src/include/common/hex_decode.h b/src/include/common/hex_decode.h
deleted file mode 100644
index 1f99f069b2..0000000000
--- a/src/include/common/hex_decode.h
+++ /dev/null
@@ -1,16 +0,0 @@
-/*
- *	hex_decode.h
- *		hex decoding
- *
- *	Portions Copyright (c) 1996-2020, PostgreSQL Global Development Group
- *	Portions Copyright (c) 1994, Regents of the University of California
- *
- *	src/include/common/hex_decode.h
- */
-#ifndef COMMON_HEX_DECODE_H
-#define COMMON_HEX_DECODE_H
-
-extern uint64 hex_decode(const char *src, size_t len, char *dst);
-
-
-#endif							/* COMMON_HEX_DECODE_H */
diff --git a/src/include/utils/builtins.h b/src/include/utils/builtins.h
index 19271e0696..11ba6ae565 100644
--- a/src/include/utils/builtins.h
+++ b/src/include/utils/builtins.h
@@ -31,9 +31,6 @@ extern void domain_check(Datum value, bool isnull, Oid domainType,
 extern int	errdatatype(Oid datatypeOid);
 extern int	errdomainconstraint(Oid datatypeOid, const char *conname);
 
-/* encode.c */
-extern uint64 hex_encode(const char *src, size_t len, char *dst);
-
 /* int.c */
 extern int2vector *buildint2vector(const int16 *int2s, int n);
 
diff --git a/src/tools/msvc/Mkvcbuild.pm b/src/tools/msvc/Mkvcbuild.pm
index 7f014a12c9..60b216cce0 100644
--- a/src/tools/msvc/Mkvcbuild.pm
+++ b/src/tools/msvc/Mkvcbuild.pm
@@ -121,7 +121,7 @@ sub mkvcbuild
 	our @pgcommonallfiles = qw(
 	  archive.c base64.c checksum_helper.c
 	  config_info.c controldata_utils.c d2s.c encnames.c exec.c
-	  f2s.c file_perm.c file_utils.c hashfn.c hex_decode.c ip.c jsonapi.c
+	  f2s.c file_perm.c file_utils.c hashfn.c hex.c ip.c jsonapi.c
 	  keywords.c kwlookup.c link-canary.c md5_common.c
 	  pg_get_line.c pg_lzcompress.c pgfnames.c psprintf.c relpath.c rmtree.c
 	  saslprep.c scram-common.c string.c stringinfo.c unicode_norm.c username.c
-- 
2.20.1


--IJpNTDwzlM2Ie8A6--





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

* [PATCH] hex squash commit
@ 2021-01-01 20:04 Bruce Momjian <[email protected]>
  0 siblings, 0 replies; 27+ messages in thread

From: Bruce Momjian @ 2021-01-01 20:04 UTC (permalink / raw)

---
 src/backend/replication/backup_manifest.c |  2 +-
 src/backend/utils/adt/encode.c            | 34 +------------------
 src/backend/utils/adt/varlena.c           |  2 +-
 src/common/Makefile                       |  2 +-
 src/common/{hex_decode.c => hex.c}        | 40 ++++++++++++++++++++---
 src/include/common/hex.h (new)            | 18 ++++++++++
 src/include/common/hex_decode.h (gone)    | 16 ---------
 src/include/utils/builtins.h              |  3 --
 src/tools/msvc/Mkvcbuild.pm               |  2 +-
 9 files changed, 59 insertions(+), 60 deletions(-)

diff --git a/src/backend/replication/backup_manifest.c b/src/backend/replication/backup_manifest.c
index c3f339c556..716f114d78 100644
--- a/src/backend/replication/backup_manifest.c
+++ b/src/backend/replication/backup_manifest.c
@@ -17,7 +17,7 @@
 #include "libpq/pqformat.h"
 #include "mb/pg_wchar.h"
 #include "replication/backup_manifest.h"
-#include "utils/builtins.h"
+#include "common/hex.h"
 #include "utils/json.h"
 
 static void AppendStringToManifest(backup_manifest_info *manifest, char *s);
diff --git a/src/backend/utils/adt/encode.c b/src/backend/utils/adt/encode.c
index a6c65b1657..bca941a496 100644
--- a/src/backend/utils/adt/encode.c
+++ b/src/backend/utils/adt/encode.c
@@ -15,7 +15,7 @@
 
 #include <ctype.h>
 
-#include "common/hex_decode.h"
+#include "common/hex.h"
 #include "mb/pg_wchar.h"
 #include "utils/builtins.h"
 #include "utils/memutils.h"
@@ -141,38 +141,6 @@ binary_decode(PG_FUNCTION_ARGS)
 }
 
 
-/*
- * HEX
- */
-
-static const char hextbl[] = "0123456789abcdef";
-
-uint64
-hex_encode(const char *src, size_t len, char *dst)
-{
-	const char *end = src + len;
-
-	while (src < end)
-	{
-		*dst++ = hextbl[(*src >> 4) & 0xF];
-		*dst++ = hextbl[*src & 0xF];
-		src++;
-	}
-	return (uint64) len * 2;
-}
-
-static uint64
-hex_enc_len(const char *src, size_t srclen)
-{
-	return (uint64) srclen << 1;
-}
-
-static uint64
-hex_dec_len(const char *src, size_t srclen)
-{
-	return (uint64) srclen >> 1;
-}
-
 /*
  * BASE64
  */
diff --git a/src/backend/utils/adt/varlena.c b/src/backend/utils/adt/varlena.c
index 9300d19e0c..79fcdcd178 100644
--- a/src/backend/utils/adt/varlena.c
+++ b/src/backend/utils/adt/varlena.c
@@ -22,7 +22,7 @@
 #include "catalog/pg_type.h"
 #include "common/hashfn.h"
 #include "common/int.h"
-#include "common/hex_decode.h"
+#include "common/hex.h"
 #include "common/unicode_norm.h"
 #include "lib/hyperloglog.h"
 #include "libpq/pqformat.h"
diff --git a/src/common/Makefile b/src/common/Makefile
index f624977939..93eb27a2aa 100644
--- a/src/common/Makefile
+++ b/src/common/Makefile
@@ -58,7 +58,7 @@ OBJS_COMMON = \
 	file_perm.o \
 	file_utils.o \
 	hashfn.o \
-	hex_decode.o \
+	hex.o \
 	ip.o \
 	jsonapi.o \
 	keywords.o \
diff --git a/src/common/hex_decode.c b/src/common/hex.c
similarity index 79%
rename from src/common/hex_decode.c
rename to src/common/hex.c
index 3ecdc73b5c..97f57bcc32 100644
--- a/src/common/hex_decode.c
+++ b/src/common/hex.c
@@ -1,7 +1,7 @@
 /*-------------------------------------------------------------------------
  *
- * hex_decode.c
- *		hex decoding
+ * hex.c
+ *		hex processing
  *
  *
  * Portions Copyright (c) 1996-2020, PostgreSQL Global Development Group
@@ -9,7 +9,7 @@
  *
  *
  * IDENTIFICATION
- *	  src/common/hex_decode.c
+ *	  src/common/hex.c
  *
  *-------------------------------------------------------------------------
  */
@@ -26,7 +26,7 @@
 #else
 #include "mb/pg_wchar.h"
 #endif
-#include "common/hex_decode.h"
+#include "common/hex.h"
 
 
 static const int8 hexlookup[128] = {
@@ -40,6 +40,26 @@ static const int8 hexlookup[128] = {
 	-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
 };
 
+/*
+ * HEX
+ */
+
+static const char hextbl[] = "0123456789abcdef";
+
+uint64
+hex_encode(const char *src, size_t len, char *dst)
+{
+	const char *end = src + len;
+
+	while (src < end)
+	{
+		*dst++ = hextbl[(*src >> 4) & 0xF];
+		*dst++ = hextbl[*src & 0xF];
+		src++;
+	}
+	return (uint64) len * 2;
+}
+
 static inline char
 get_hex(const char *cp)
 {
@@ -104,3 +124,15 @@ hex_decode(const char *src, size_t len, char *dst)
 
 	return p - dst;
 }
+
+uint64
+hex_enc_len(const char *src, size_t srclen)
+{
+	return (uint64) srclen << 1;
+}
+
+uint64
+hex_dec_len(const char *src, size_t srclen)
+{
+	return (uint64) srclen >> 1;
+}
diff --git a/src/include/common/hex.h b/src/include/common/hex.h
new file mode 100644
index 0000000000..76154b65af
--- /dev/null
+++ b/src/include/common/hex.h
@@ -0,0 +1,18 @@
+/*
+ *	hex.h
+ *		hex processing
+ *
+ *	Portions Copyright (c) 1996-2020, PostgreSQL Global Development Group
+ *	Portions Copyright (c) 1994, Regents of the University of California
+ *
+ *	src/include/common/hex.h
+ */
+#ifndef COMMON_HEX_H
+#define COMMON_HEX_H
+
+extern uint64 hex_decode(const char *src, size_t len, char *dst);
+extern uint64 hex_encode(const char *src, size_t len, char *dst);
+extern uint64 hex_enc_len(const char *src, size_t srclen);
+extern uint64 hex_dec_len(const char *src, size_t srclen);
+
+#endif							/* COMMON_HEX_H */
diff --git a/src/include/common/hex_decode.h b/src/include/common/hex_decode.h
deleted file mode 100644
index 1f99f069b2..0000000000
--- a/src/include/common/hex_decode.h
+++ /dev/null
@@ -1,16 +0,0 @@
-/*
- *	hex_decode.h
- *		hex decoding
- *
- *	Portions Copyright (c) 1996-2020, PostgreSQL Global Development Group
- *	Portions Copyright (c) 1994, Regents of the University of California
- *
- *	src/include/common/hex_decode.h
- */
-#ifndef COMMON_HEX_DECODE_H
-#define COMMON_HEX_DECODE_H
-
-extern uint64 hex_decode(const char *src, size_t len, char *dst);
-
-
-#endif							/* COMMON_HEX_DECODE_H */
diff --git a/src/include/utils/builtins.h b/src/include/utils/builtins.h
index 19271e0696..11ba6ae565 100644
--- a/src/include/utils/builtins.h
+++ b/src/include/utils/builtins.h
@@ -31,9 +31,6 @@ extern void domain_check(Datum value, bool isnull, Oid domainType,
 extern int	errdatatype(Oid datatypeOid);
 extern int	errdomainconstraint(Oid datatypeOid, const char *conname);
 
-/* encode.c */
-extern uint64 hex_encode(const char *src, size_t len, char *dst);
-
 /* int.c */
 extern int2vector *buildint2vector(const int16 *int2s, int n);
 
diff --git a/src/tools/msvc/Mkvcbuild.pm b/src/tools/msvc/Mkvcbuild.pm
index 7f014a12c9..60b216cce0 100644
--- a/src/tools/msvc/Mkvcbuild.pm
+++ b/src/tools/msvc/Mkvcbuild.pm
@@ -121,7 +121,7 @@ sub mkvcbuild
 	our @pgcommonallfiles = qw(
 	  archive.c base64.c checksum_helper.c
 	  config_info.c controldata_utils.c d2s.c encnames.c exec.c
-	  f2s.c file_perm.c file_utils.c hashfn.c hex_decode.c ip.c jsonapi.c
+	  f2s.c file_perm.c file_utils.c hashfn.c hex.c ip.c jsonapi.c
 	  keywords.c kwlookup.c link-canary.c md5_common.c
 	  pg_get_line.c pg_lzcompress.c pgfnames.c psprintf.c relpath.c rmtree.c
 	  saslprep.c scram-common.c string.c stringinfo.c unicode_norm.c username.c
-- 
2.20.1


--IJpNTDwzlM2Ie8A6--





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

* [PATCH] hex squash commit
@ 2021-01-01 20:04 Bruce Momjian <[email protected]>
  0 siblings, 0 replies; 27+ messages in thread

From: Bruce Momjian @ 2021-01-01 20:04 UTC (permalink / raw)

---
 src/backend/replication/backup_manifest.c |  2 +-
 src/backend/utils/adt/encode.c            | 34 +------------------
 src/backend/utils/adt/varlena.c           |  2 +-
 src/common/Makefile                       |  2 +-
 src/common/{hex_decode.c => hex.c}        | 40 ++++++++++++++++++++---
 src/include/common/hex.h (new)            | 18 ++++++++++
 src/include/common/hex_decode.h (gone)    | 16 ---------
 src/include/utils/builtins.h              |  3 --
 src/tools/msvc/Mkvcbuild.pm               |  2 +-
 9 files changed, 59 insertions(+), 60 deletions(-)

diff --git a/src/backend/replication/backup_manifest.c b/src/backend/replication/backup_manifest.c
index c3f339c556..716f114d78 100644
--- a/src/backend/replication/backup_manifest.c
+++ b/src/backend/replication/backup_manifest.c
@@ -17,7 +17,7 @@
 #include "libpq/pqformat.h"
 #include "mb/pg_wchar.h"
 #include "replication/backup_manifest.h"
-#include "utils/builtins.h"
+#include "common/hex.h"
 #include "utils/json.h"
 
 static void AppendStringToManifest(backup_manifest_info *manifest, char *s);
diff --git a/src/backend/utils/adt/encode.c b/src/backend/utils/adt/encode.c
index a6c65b1657..bca941a496 100644
--- a/src/backend/utils/adt/encode.c
+++ b/src/backend/utils/adt/encode.c
@@ -15,7 +15,7 @@
 
 #include <ctype.h>
 
-#include "common/hex_decode.h"
+#include "common/hex.h"
 #include "mb/pg_wchar.h"
 #include "utils/builtins.h"
 #include "utils/memutils.h"
@@ -141,38 +141,6 @@ binary_decode(PG_FUNCTION_ARGS)
 }
 
 
-/*
- * HEX
- */
-
-static const char hextbl[] = "0123456789abcdef";
-
-uint64
-hex_encode(const char *src, size_t len, char *dst)
-{
-	const char *end = src + len;
-
-	while (src < end)
-	{
-		*dst++ = hextbl[(*src >> 4) & 0xF];
-		*dst++ = hextbl[*src & 0xF];
-		src++;
-	}
-	return (uint64) len * 2;
-}
-
-static uint64
-hex_enc_len(const char *src, size_t srclen)
-{
-	return (uint64) srclen << 1;
-}
-
-static uint64
-hex_dec_len(const char *src, size_t srclen)
-{
-	return (uint64) srclen >> 1;
-}
-
 /*
  * BASE64
  */
diff --git a/src/backend/utils/adt/varlena.c b/src/backend/utils/adt/varlena.c
index 9300d19e0c..79fcdcd178 100644
--- a/src/backend/utils/adt/varlena.c
+++ b/src/backend/utils/adt/varlena.c
@@ -22,7 +22,7 @@
 #include "catalog/pg_type.h"
 #include "common/hashfn.h"
 #include "common/int.h"
-#include "common/hex_decode.h"
+#include "common/hex.h"
 #include "common/unicode_norm.h"
 #include "lib/hyperloglog.h"
 #include "libpq/pqformat.h"
diff --git a/src/common/Makefile b/src/common/Makefile
index f624977939..93eb27a2aa 100644
--- a/src/common/Makefile
+++ b/src/common/Makefile
@@ -58,7 +58,7 @@ OBJS_COMMON = \
 	file_perm.o \
 	file_utils.o \
 	hashfn.o \
-	hex_decode.o \
+	hex.o \
 	ip.o \
 	jsonapi.o \
 	keywords.o \
diff --git a/src/common/hex_decode.c b/src/common/hex.c
similarity index 79%
rename from src/common/hex_decode.c
rename to src/common/hex.c
index 3ecdc73b5c..97f57bcc32 100644
--- a/src/common/hex_decode.c
+++ b/src/common/hex.c
@@ -1,7 +1,7 @@
 /*-------------------------------------------------------------------------
  *
- * hex_decode.c
- *		hex decoding
+ * hex.c
+ *		hex processing
  *
  *
  * Portions Copyright (c) 1996-2020, PostgreSQL Global Development Group
@@ -9,7 +9,7 @@
  *
  *
  * IDENTIFICATION
- *	  src/common/hex_decode.c
+ *	  src/common/hex.c
  *
  *-------------------------------------------------------------------------
  */
@@ -26,7 +26,7 @@
 #else
 #include "mb/pg_wchar.h"
 #endif
-#include "common/hex_decode.h"
+#include "common/hex.h"
 
 
 static const int8 hexlookup[128] = {
@@ -40,6 +40,26 @@ static const int8 hexlookup[128] = {
 	-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
 };
 
+/*
+ * HEX
+ */
+
+static const char hextbl[] = "0123456789abcdef";
+
+uint64
+hex_encode(const char *src, size_t len, char *dst)
+{
+	const char *end = src + len;
+
+	while (src < end)
+	{
+		*dst++ = hextbl[(*src >> 4) & 0xF];
+		*dst++ = hextbl[*src & 0xF];
+		src++;
+	}
+	return (uint64) len * 2;
+}
+
 static inline char
 get_hex(const char *cp)
 {
@@ -104,3 +124,15 @@ hex_decode(const char *src, size_t len, char *dst)
 
 	return p - dst;
 }
+
+uint64
+hex_enc_len(const char *src, size_t srclen)
+{
+	return (uint64) srclen << 1;
+}
+
+uint64
+hex_dec_len(const char *src, size_t srclen)
+{
+	return (uint64) srclen >> 1;
+}
diff --git a/src/include/common/hex.h b/src/include/common/hex.h
new file mode 100644
index 0000000000..76154b65af
--- /dev/null
+++ b/src/include/common/hex.h
@@ -0,0 +1,18 @@
+/*
+ *	hex.h
+ *		hex processing
+ *
+ *	Portions Copyright (c) 1996-2020, PostgreSQL Global Development Group
+ *	Portions Copyright (c) 1994, Regents of the University of California
+ *
+ *	src/include/common/hex.h
+ */
+#ifndef COMMON_HEX_H
+#define COMMON_HEX_H
+
+extern uint64 hex_decode(const char *src, size_t len, char *dst);
+extern uint64 hex_encode(const char *src, size_t len, char *dst);
+extern uint64 hex_enc_len(const char *src, size_t srclen);
+extern uint64 hex_dec_len(const char *src, size_t srclen);
+
+#endif							/* COMMON_HEX_H */
diff --git a/src/include/common/hex_decode.h b/src/include/common/hex_decode.h
deleted file mode 100644
index 1f99f069b2..0000000000
--- a/src/include/common/hex_decode.h
+++ /dev/null
@@ -1,16 +0,0 @@
-/*
- *	hex_decode.h
- *		hex decoding
- *
- *	Portions Copyright (c) 1996-2020, PostgreSQL Global Development Group
- *	Portions Copyright (c) 1994, Regents of the University of California
- *
- *	src/include/common/hex_decode.h
- */
-#ifndef COMMON_HEX_DECODE_H
-#define COMMON_HEX_DECODE_H
-
-extern uint64 hex_decode(const char *src, size_t len, char *dst);
-
-
-#endif							/* COMMON_HEX_DECODE_H */
diff --git a/src/include/utils/builtins.h b/src/include/utils/builtins.h
index 19271e0696..11ba6ae565 100644
--- a/src/include/utils/builtins.h
+++ b/src/include/utils/builtins.h
@@ -31,9 +31,6 @@ extern void domain_check(Datum value, bool isnull, Oid domainType,
 extern int	errdatatype(Oid datatypeOid);
 extern int	errdomainconstraint(Oid datatypeOid, const char *conname);
 
-/* encode.c */
-extern uint64 hex_encode(const char *src, size_t len, char *dst);
-
 /* int.c */
 extern int2vector *buildint2vector(const int16 *int2s, int n);
 
diff --git a/src/tools/msvc/Mkvcbuild.pm b/src/tools/msvc/Mkvcbuild.pm
index 7f014a12c9..60b216cce0 100644
--- a/src/tools/msvc/Mkvcbuild.pm
+++ b/src/tools/msvc/Mkvcbuild.pm
@@ -121,7 +121,7 @@ sub mkvcbuild
 	our @pgcommonallfiles = qw(
 	  archive.c base64.c checksum_helper.c
 	  config_info.c controldata_utils.c d2s.c encnames.c exec.c
-	  f2s.c file_perm.c file_utils.c hashfn.c hex_decode.c ip.c jsonapi.c
+	  f2s.c file_perm.c file_utils.c hashfn.c hex.c ip.c jsonapi.c
 	  keywords.c kwlookup.c link-canary.c md5_common.c
 	  pg_get_line.c pg_lzcompress.c pgfnames.c psprintf.c relpath.c rmtree.c
 	  saslprep.c scram-common.c string.c stringinfo.c unicode_norm.c username.c
-- 
2.20.1


--IJpNTDwzlM2Ie8A6--





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

* [PATCH] hex squash commit
@ 2021-01-01 20:04 Bruce Momjian <[email protected]>
  0 siblings, 0 replies; 27+ messages in thread

From: Bruce Momjian @ 2021-01-01 20:04 UTC (permalink / raw)

---
 src/backend/replication/backup_manifest.c |  2 +-
 src/backend/utils/adt/encode.c            | 34 +------------------
 src/backend/utils/adt/varlena.c           |  2 +-
 src/common/Makefile                       |  2 +-
 src/common/{hex_decode.c => hex.c}        | 40 ++++++++++++++++++++---
 src/include/common/hex.h (new)            | 18 ++++++++++
 src/include/common/hex_decode.h (gone)    | 16 ---------
 src/include/utils/builtins.h              |  3 --
 src/tools/msvc/Mkvcbuild.pm               |  2 +-
 9 files changed, 59 insertions(+), 60 deletions(-)

diff --git a/src/backend/replication/backup_manifest.c b/src/backend/replication/backup_manifest.c
index c3f339c556..716f114d78 100644
--- a/src/backend/replication/backup_manifest.c
+++ b/src/backend/replication/backup_manifest.c
@@ -17,7 +17,7 @@
 #include "libpq/pqformat.h"
 #include "mb/pg_wchar.h"
 #include "replication/backup_manifest.h"
-#include "utils/builtins.h"
+#include "common/hex.h"
 #include "utils/json.h"
 
 static void AppendStringToManifest(backup_manifest_info *manifest, char *s);
diff --git a/src/backend/utils/adt/encode.c b/src/backend/utils/adt/encode.c
index a6c65b1657..bca941a496 100644
--- a/src/backend/utils/adt/encode.c
+++ b/src/backend/utils/adt/encode.c
@@ -15,7 +15,7 @@
 
 #include <ctype.h>
 
-#include "common/hex_decode.h"
+#include "common/hex.h"
 #include "mb/pg_wchar.h"
 #include "utils/builtins.h"
 #include "utils/memutils.h"
@@ -141,38 +141,6 @@ binary_decode(PG_FUNCTION_ARGS)
 }
 
 
-/*
- * HEX
- */
-
-static const char hextbl[] = "0123456789abcdef";
-
-uint64
-hex_encode(const char *src, size_t len, char *dst)
-{
-	const char *end = src + len;
-
-	while (src < end)
-	{
-		*dst++ = hextbl[(*src >> 4) & 0xF];
-		*dst++ = hextbl[*src & 0xF];
-		src++;
-	}
-	return (uint64) len * 2;
-}
-
-static uint64
-hex_enc_len(const char *src, size_t srclen)
-{
-	return (uint64) srclen << 1;
-}
-
-static uint64
-hex_dec_len(const char *src, size_t srclen)
-{
-	return (uint64) srclen >> 1;
-}
-
 /*
  * BASE64
  */
diff --git a/src/backend/utils/adt/varlena.c b/src/backend/utils/adt/varlena.c
index 9300d19e0c..79fcdcd178 100644
--- a/src/backend/utils/adt/varlena.c
+++ b/src/backend/utils/adt/varlena.c
@@ -22,7 +22,7 @@
 #include "catalog/pg_type.h"
 #include "common/hashfn.h"
 #include "common/int.h"
-#include "common/hex_decode.h"
+#include "common/hex.h"
 #include "common/unicode_norm.h"
 #include "lib/hyperloglog.h"
 #include "libpq/pqformat.h"
diff --git a/src/common/Makefile b/src/common/Makefile
index f624977939..93eb27a2aa 100644
--- a/src/common/Makefile
+++ b/src/common/Makefile
@@ -58,7 +58,7 @@ OBJS_COMMON = \
 	file_perm.o \
 	file_utils.o \
 	hashfn.o \
-	hex_decode.o \
+	hex.o \
 	ip.o \
 	jsonapi.o \
 	keywords.o \
diff --git a/src/common/hex_decode.c b/src/common/hex.c
similarity index 79%
rename from src/common/hex_decode.c
rename to src/common/hex.c
index 3ecdc73b5c..97f57bcc32 100644
--- a/src/common/hex_decode.c
+++ b/src/common/hex.c
@@ -1,7 +1,7 @@
 /*-------------------------------------------------------------------------
  *
- * hex_decode.c
- *		hex decoding
+ * hex.c
+ *		hex processing
  *
  *
  * Portions Copyright (c) 1996-2020, PostgreSQL Global Development Group
@@ -9,7 +9,7 @@
  *
  *
  * IDENTIFICATION
- *	  src/common/hex_decode.c
+ *	  src/common/hex.c
  *
  *-------------------------------------------------------------------------
  */
@@ -26,7 +26,7 @@
 #else
 #include "mb/pg_wchar.h"
 #endif
-#include "common/hex_decode.h"
+#include "common/hex.h"
 
 
 static const int8 hexlookup[128] = {
@@ -40,6 +40,26 @@ static const int8 hexlookup[128] = {
 	-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
 };
 
+/*
+ * HEX
+ */
+
+static const char hextbl[] = "0123456789abcdef";
+
+uint64
+hex_encode(const char *src, size_t len, char *dst)
+{
+	const char *end = src + len;
+
+	while (src < end)
+	{
+		*dst++ = hextbl[(*src >> 4) & 0xF];
+		*dst++ = hextbl[*src & 0xF];
+		src++;
+	}
+	return (uint64) len * 2;
+}
+
 static inline char
 get_hex(const char *cp)
 {
@@ -104,3 +124,15 @@ hex_decode(const char *src, size_t len, char *dst)
 
 	return p - dst;
 }
+
+uint64
+hex_enc_len(const char *src, size_t srclen)
+{
+	return (uint64) srclen << 1;
+}
+
+uint64
+hex_dec_len(const char *src, size_t srclen)
+{
+	return (uint64) srclen >> 1;
+}
diff --git a/src/include/common/hex.h b/src/include/common/hex.h
new file mode 100644
index 0000000000..76154b65af
--- /dev/null
+++ b/src/include/common/hex.h
@@ -0,0 +1,18 @@
+/*
+ *	hex.h
+ *		hex processing
+ *
+ *	Portions Copyright (c) 1996-2020, PostgreSQL Global Development Group
+ *	Portions Copyright (c) 1994, Regents of the University of California
+ *
+ *	src/include/common/hex.h
+ */
+#ifndef COMMON_HEX_H
+#define COMMON_HEX_H
+
+extern uint64 hex_decode(const char *src, size_t len, char *dst);
+extern uint64 hex_encode(const char *src, size_t len, char *dst);
+extern uint64 hex_enc_len(const char *src, size_t srclen);
+extern uint64 hex_dec_len(const char *src, size_t srclen);
+
+#endif							/* COMMON_HEX_H */
diff --git a/src/include/common/hex_decode.h b/src/include/common/hex_decode.h
deleted file mode 100644
index 1f99f069b2..0000000000
--- a/src/include/common/hex_decode.h
+++ /dev/null
@@ -1,16 +0,0 @@
-/*
- *	hex_decode.h
- *		hex decoding
- *
- *	Portions Copyright (c) 1996-2020, PostgreSQL Global Development Group
- *	Portions Copyright (c) 1994, Regents of the University of California
- *
- *	src/include/common/hex_decode.h
- */
-#ifndef COMMON_HEX_DECODE_H
-#define COMMON_HEX_DECODE_H
-
-extern uint64 hex_decode(const char *src, size_t len, char *dst);
-
-
-#endif							/* COMMON_HEX_DECODE_H */
diff --git a/src/include/utils/builtins.h b/src/include/utils/builtins.h
index 19271e0696..11ba6ae565 100644
--- a/src/include/utils/builtins.h
+++ b/src/include/utils/builtins.h
@@ -31,9 +31,6 @@ extern void domain_check(Datum value, bool isnull, Oid domainType,
 extern int	errdatatype(Oid datatypeOid);
 extern int	errdomainconstraint(Oid datatypeOid, const char *conname);
 
-/* encode.c */
-extern uint64 hex_encode(const char *src, size_t len, char *dst);
-
 /* int.c */
 extern int2vector *buildint2vector(const int16 *int2s, int n);
 
diff --git a/src/tools/msvc/Mkvcbuild.pm b/src/tools/msvc/Mkvcbuild.pm
index 7f014a12c9..60b216cce0 100644
--- a/src/tools/msvc/Mkvcbuild.pm
+++ b/src/tools/msvc/Mkvcbuild.pm
@@ -121,7 +121,7 @@ sub mkvcbuild
 	our @pgcommonallfiles = qw(
 	  archive.c base64.c checksum_helper.c
 	  config_info.c controldata_utils.c d2s.c encnames.c exec.c
-	  f2s.c file_perm.c file_utils.c hashfn.c hex_decode.c ip.c jsonapi.c
+	  f2s.c file_perm.c file_utils.c hashfn.c hex.c ip.c jsonapi.c
 	  keywords.c kwlookup.c link-canary.c md5_common.c
 	  pg_get_line.c pg_lzcompress.c pgfnames.c psprintf.c relpath.c rmtree.c
 	  saslprep.c scram-common.c string.c stringinfo.c unicode_norm.c username.c
-- 
2.20.1


--IJpNTDwzlM2Ie8A6--





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

* [PATCH] hex squash commit
@ 2021-01-01 20:04 Bruce Momjian <[email protected]>
  0 siblings, 0 replies; 27+ messages in thread

From: Bruce Momjian @ 2021-01-01 20:04 UTC (permalink / raw)

---
 src/backend/replication/backup_manifest.c |  2 +-
 src/backend/utils/adt/encode.c            | 34 +------------------
 src/backend/utils/adt/varlena.c           |  2 +-
 src/common/Makefile                       |  2 +-
 src/common/{hex_decode.c => hex.c}        | 40 ++++++++++++++++++++---
 src/include/common/hex.h (new)            | 18 ++++++++++
 src/include/common/hex_decode.h (gone)    | 16 ---------
 src/include/utils/builtins.h              |  3 --
 src/tools/msvc/Mkvcbuild.pm               |  2 +-
 9 files changed, 59 insertions(+), 60 deletions(-)

diff --git a/src/backend/replication/backup_manifest.c b/src/backend/replication/backup_manifest.c
index c3f339c556..716f114d78 100644
--- a/src/backend/replication/backup_manifest.c
+++ b/src/backend/replication/backup_manifest.c
@@ -17,7 +17,7 @@
 #include "libpq/pqformat.h"
 #include "mb/pg_wchar.h"
 #include "replication/backup_manifest.h"
-#include "utils/builtins.h"
+#include "common/hex.h"
 #include "utils/json.h"
 
 static void AppendStringToManifest(backup_manifest_info *manifest, char *s);
diff --git a/src/backend/utils/adt/encode.c b/src/backend/utils/adt/encode.c
index a6c65b1657..bca941a496 100644
--- a/src/backend/utils/adt/encode.c
+++ b/src/backend/utils/adt/encode.c
@@ -15,7 +15,7 @@
 
 #include <ctype.h>
 
-#include "common/hex_decode.h"
+#include "common/hex.h"
 #include "mb/pg_wchar.h"
 #include "utils/builtins.h"
 #include "utils/memutils.h"
@@ -141,38 +141,6 @@ binary_decode(PG_FUNCTION_ARGS)
 }
 
 
-/*
- * HEX
- */
-
-static const char hextbl[] = "0123456789abcdef";
-
-uint64
-hex_encode(const char *src, size_t len, char *dst)
-{
-	const char *end = src + len;
-
-	while (src < end)
-	{
-		*dst++ = hextbl[(*src >> 4) & 0xF];
-		*dst++ = hextbl[*src & 0xF];
-		src++;
-	}
-	return (uint64) len * 2;
-}
-
-static uint64
-hex_enc_len(const char *src, size_t srclen)
-{
-	return (uint64) srclen << 1;
-}
-
-static uint64
-hex_dec_len(const char *src, size_t srclen)
-{
-	return (uint64) srclen >> 1;
-}
-
 /*
  * BASE64
  */
diff --git a/src/backend/utils/adt/varlena.c b/src/backend/utils/adt/varlena.c
index 9300d19e0c..79fcdcd178 100644
--- a/src/backend/utils/adt/varlena.c
+++ b/src/backend/utils/adt/varlena.c
@@ -22,7 +22,7 @@
 #include "catalog/pg_type.h"
 #include "common/hashfn.h"
 #include "common/int.h"
-#include "common/hex_decode.h"
+#include "common/hex.h"
 #include "common/unicode_norm.h"
 #include "lib/hyperloglog.h"
 #include "libpq/pqformat.h"
diff --git a/src/common/Makefile b/src/common/Makefile
index f624977939..93eb27a2aa 100644
--- a/src/common/Makefile
+++ b/src/common/Makefile
@@ -58,7 +58,7 @@ OBJS_COMMON = \
 	file_perm.o \
 	file_utils.o \
 	hashfn.o \
-	hex_decode.o \
+	hex.o \
 	ip.o \
 	jsonapi.o \
 	keywords.o \
diff --git a/src/common/hex_decode.c b/src/common/hex.c
similarity index 79%
rename from src/common/hex_decode.c
rename to src/common/hex.c
index 3ecdc73b5c..97f57bcc32 100644
--- a/src/common/hex_decode.c
+++ b/src/common/hex.c
@@ -1,7 +1,7 @@
 /*-------------------------------------------------------------------------
  *
- * hex_decode.c
- *		hex decoding
+ * hex.c
+ *		hex processing
  *
  *
  * Portions Copyright (c) 1996-2020, PostgreSQL Global Development Group
@@ -9,7 +9,7 @@
  *
  *
  * IDENTIFICATION
- *	  src/common/hex_decode.c
+ *	  src/common/hex.c
  *
  *-------------------------------------------------------------------------
  */
@@ -26,7 +26,7 @@
 #else
 #include "mb/pg_wchar.h"
 #endif
-#include "common/hex_decode.h"
+#include "common/hex.h"
 
 
 static const int8 hexlookup[128] = {
@@ -40,6 +40,26 @@ static const int8 hexlookup[128] = {
 	-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
 };
 
+/*
+ * HEX
+ */
+
+static const char hextbl[] = "0123456789abcdef";
+
+uint64
+hex_encode(const char *src, size_t len, char *dst)
+{
+	const char *end = src + len;
+
+	while (src < end)
+	{
+		*dst++ = hextbl[(*src >> 4) & 0xF];
+		*dst++ = hextbl[*src & 0xF];
+		src++;
+	}
+	return (uint64) len * 2;
+}
+
 static inline char
 get_hex(const char *cp)
 {
@@ -104,3 +124,15 @@ hex_decode(const char *src, size_t len, char *dst)
 
 	return p - dst;
 }
+
+uint64
+hex_enc_len(const char *src, size_t srclen)
+{
+	return (uint64) srclen << 1;
+}
+
+uint64
+hex_dec_len(const char *src, size_t srclen)
+{
+	return (uint64) srclen >> 1;
+}
diff --git a/src/include/common/hex.h b/src/include/common/hex.h
new file mode 100644
index 0000000000..76154b65af
--- /dev/null
+++ b/src/include/common/hex.h
@@ -0,0 +1,18 @@
+/*
+ *	hex.h
+ *		hex processing
+ *
+ *	Portions Copyright (c) 1996-2020, PostgreSQL Global Development Group
+ *	Portions Copyright (c) 1994, Regents of the University of California
+ *
+ *	src/include/common/hex.h
+ */
+#ifndef COMMON_HEX_H
+#define COMMON_HEX_H
+
+extern uint64 hex_decode(const char *src, size_t len, char *dst);
+extern uint64 hex_encode(const char *src, size_t len, char *dst);
+extern uint64 hex_enc_len(const char *src, size_t srclen);
+extern uint64 hex_dec_len(const char *src, size_t srclen);
+
+#endif							/* COMMON_HEX_H */
diff --git a/src/include/common/hex_decode.h b/src/include/common/hex_decode.h
deleted file mode 100644
index 1f99f069b2..0000000000
--- a/src/include/common/hex_decode.h
+++ /dev/null
@@ -1,16 +0,0 @@
-/*
- *	hex_decode.h
- *		hex decoding
- *
- *	Portions Copyright (c) 1996-2020, PostgreSQL Global Development Group
- *	Portions Copyright (c) 1994, Regents of the University of California
- *
- *	src/include/common/hex_decode.h
- */
-#ifndef COMMON_HEX_DECODE_H
-#define COMMON_HEX_DECODE_H
-
-extern uint64 hex_decode(const char *src, size_t len, char *dst);
-
-
-#endif							/* COMMON_HEX_DECODE_H */
diff --git a/src/include/utils/builtins.h b/src/include/utils/builtins.h
index 19271e0696..11ba6ae565 100644
--- a/src/include/utils/builtins.h
+++ b/src/include/utils/builtins.h
@@ -31,9 +31,6 @@ extern void domain_check(Datum value, bool isnull, Oid domainType,
 extern int	errdatatype(Oid datatypeOid);
 extern int	errdomainconstraint(Oid datatypeOid, const char *conname);
 
-/* encode.c */
-extern uint64 hex_encode(const char *src, size_t len, char *dst);
-
 /* int.c */
 extern int2vector *buildint2vector(const int16 *int2s, int n);
 
diff --git a/src/tools/msvc/Mkvcbuild.pm b/src/tools/msvc/Mkvcbuild.pm
index 7f014a12c9..60b216cce0 100644
--- a/src/tools/msvc/Mkvcbuild.pm
+++ b/src/tools/msvc/Mkvcbuild.pm
@@ -121,7 +121,7 @@ sub mkvcbuild
 	our @pgcommonallfiles = qw(
 	  archive.c base64.c checksum_helper.c
 	  config_info.c controldata_utils.c d2s.c encnames.c exec.c
-	  f2s.c file_perm.c file_utils.c hashfn.c hex_decode.c ip.c jsonapi.c
+	  f2s.c file_perm.c file_utils.c hashfn.c hex.c ip.c jsonapi.c
 	  keywords.c kwlookup.c link-canary.c md5_common.c
 	  pg_get_line.c pg_lzcompress.c pgfnames.c psprintf.c relpath.c rmtree.c
 	  saslprep.c scram-common.c string.c stringinfo.c unicode_norm.c username.c
-- 
2.20.1


--IJpNTDwzlM2Ie8A6--





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

* [PATCH] hex squash commit
@ 2021-01-01 20:04 Bruce Momjian <[email protected]>
  0 siblings, 0 replies; 27+ messages in thread

From: Bruce Momjian @ 2021-01-01 20:04 UTC (permalink / raw)

---
 src/backend/replication/backup_manifest.c |  2 +-
 src/backend/utils/adt/encode.c            | 34 +------------------
 src/backend/utils/adt/varlena.c           |  2 +-
 src/common/Makefile                       |  2 +-
 src/common/{hex_decode.c => hex.c}        | 40 ++++++++++++++++++++---
 src/include/common/hex.h (new)            | 18 ++++++++++
 src/include/common/hex_decode.h (gone)    | 16 ---------
 src/include/utils/builtins.h              |  3 --
 src/tools/msvc/Mkvcbuild.pm               |  2 +-
 9 files changed, 59 insertions(+), 60 deletions(-)

diff --git a/src/backend/replication/backup_manifest.c b/src/backend/replication/backup_manifest.c
index c3f339c556..716f114d78 100644
--- a/src/backend/replication/backup_manifest.c
+++ b/src/backend/replication/backup_manifest.c
@@ -17,7 +17,7 @@
 #include "libpq/pqformat.h"
 #include "mb/pg_wchar.h"
 #include "replication/backup_manifest.h"
-#include "utils/builtins.h"
+#include "common/hex.h"
 #include "utils/json.h"
 
 static void AppendStringToManifest(backup_manifest_info *manifest, char *s);
diff --git a/src/backend/utils/adt/encode.c b/src/backend/utils/adt/encode.c
index a6c65b1657..bca941a496 100644
--- a/src/backend/utils/adt/encode.c
+++ b/src/backend/utils/adt/encode.c
@@ -15,7 +15,7 @@
 
 #include <ctype.h>
 
-#include "common/hex_decode.h"
+#include "common/hex.h"
 #include "mb/pg_wchar.h"
 #include "utils/builtins.h"
 #include "utils/memutils.h"
@@ -141,38 +141,6 @@ binary_decode(PG_FUNCTION_ARGS)
 }
 
 
-/*
- * HEX
- */
-
-static const char hextbl[] = "0123456789abcdef";
-
-uint64
-hex_encode(const char *src, size_t len, char *dst)
-{
-	const char *end = src + len;
-
-	while (src < end)
-	{
-		*dst++ = hextbl[(*src >> 4) & 0xF];
-		*dst++ = hextbl[*src & 0xF];
-		src++;
-	}
-	return (uint64) len * 2;
-}
-
-static uint64
-hex_enc_len(const char *src, size_t srclen)
-{
-	return (uint64) srclen << 1;
-}
-
-static uint64
-hex_dec_len(const char *src, size_t srclen)
-{
-	return (uint64) srclen >> 1;
-}
-
 /*
  * BASE64
  */
diff --git a/src/backend/utils/adt/varlena.c b/src/backend/utils/adt/varlena.c
index 9300d19e0c..79fcdcd178 100644
--- a/src/backend/utils/adt/varlena.c
+++ b/src/backend/utils/adt/varlena.c
@@ -22,7 +22,7 @@
 #include "catalog/pg_type.h"
 #include "common/hashfn.h"
 #include "common/int.h"
-#include "common/hex_decode.h"
+#include "common/hex.h"
 #include "common/unicode_norm.h"
 #include "lib/hyperloglog.h"
 #include "libpq/pqformat.h"
diff --git a/src/common/Makefile b/src/common/Makefile
index f624977939..93eb27a2aa 100644
--- a/src/common/Makefile
+++ b/src/common/Makefile
@@ -58,7 +58,7 @@ OBJS_COMMON = \
 	file_perm.o \
 	file_utils.o \
 	hashfn.o \
-	hex_decode.o \
+	hex.o \
 	ip.o \
 	jsonapi.o \
 	keywords.o \
diff --git a/src/common/hex_decode.c b/src/common/hex.c
similarity index 79%
rename from src/common/hex_decode.c
rename to src/common/hex.c
index 3ecdc73b5c..97f57bcc32 100644
--- a/src/common/hex_decode.c
+++ b/src/common/hex.c
@@ -1,7 +1,7 @@
 /*-------------------------------------------------------------------------
  *
- * hex_decode.c
- *		hex decoding
+ * hex.c
+ *		hex processing
  *
  *
  * Portions Copyright (c) 1996-2020, PostgreSQL Global Development Group
@@ -9,7 +9,7 @@
  *
  *
  * IDENTIFICATION
- *	  src/common/hex_decode.c
+ *	  src/common/hex.c
  *
  *-------------------------------------------------------------------------
  */
@@ -26,7 +26,7 @@
 #else
 #include "mb/pg_wchar.h"
 #endif
-#include "common/hex_decode.h"
+#include "common/hex.h"
 
 
 static const int8 hexlookup[128] = {
@@ -40,6 +40,26 @@ static const int8 hexlookup[128] = {
 	-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
 };
 
+/*
+ * HEX
+ */
+
+static const char hextbl[] = "0123456789abcdef";
+
+uint64
+hex_encode(const char *src, size_t len, char *dst)
+{
+	const char *end = src + len;
+
+	while (src < end)
+	{
+		*dst++ = hextbl[(*src >> 4) & 0xF];
+		*dst++ = hextbl[*src & 0xF];
+		src++;
+	}
+	return (uint64) len * 2;
+}
+
 static inline char
 get_hex(const char *cp)
 {
@@ -104,3 +124,15 @@ hex_decode(const char *src, size_t len, char *dst)
 
 	return p - dst;
 }
+
+uint64
+hex_enc_len(const char *src, size_t srclen)
+{
+	return (uint64) srclen << 1;
+}
+
+uint64
+hex_dec_len(const char *src, size_t srclen)
+{
+	return (uint64) srclen >> 1;
+}
diff --git a/src/include/common/hex.h b/src/include/common/hex.h
new file mode 100644
index 0000000000..76154b65af
--- /dev/null
+++ b/src/include/common/hex.h
@@ -0,0 +1,18 @@
+/*
+ *	hex.h
+ *		hex processing
+ *
+ *	Portions Copyright (c) 1996-2020, PostgreSQL Global Development Group
+ *	Portions Copyright (c) 1994, Regents of the University of California
+ *
+ *	src/include/common/hex.h
+ */
+#ifndef COMMON_HEX_H
+#define COMMON_HEX_H
+
+extern uint64 hex_decode(const char *src, size_t len, char *dst);
+extern uint64 hex_encode(const char *src, size_t len, char *dst);
+extern uint64 hex_enc_len(const char *src, size_t srclen);
+extern uint64 hex_dec_len(const char *src, size_t srclen);
+
+#endif							/* COMMON_HEX_H */
diff --git a/src/include/common/hex_decode.h b/src/include/common/hex_decode.h
deleted file mode 100644
index 1f99f069b2..0000000000
--- a/src/include/common/hex_decode.h
+++ /dev/null
@@ -1,16 +0,0 @@
-/*
- *	hex_decode.h
- *		hex decoding
- *
- *	Portions Copyright (c) 1996-2020, PostgreSQL Global Development Group
- *	Portions Copyright (c) 1994, Regents of the University of California
- *
- *	src/include/common/hex_decode.h
- */
-#ifndef COMMON_HEX_DECODE_H
-#define COMMON_HEX_DECODE_H
-
-extern uint64 hex_decode(const char *src, size_t len, char *dst);
-
-
-#endif							/* COMMON_HEX_DECODE_H */
diff --git a/src/include/utils/builtins.h b/src/include/utils/builtins.h
index 19271e0696..11ba6ae565 100644
--- a/src/include/utils/builtins.h
+++ b/src/include/utils/builtins.h
@@ -31,9 +31,6 @@ extern void domain_check(Datum value, bool isnull, Oid domainType,
 extern int	errdatatype(Oid datatypeOid);
 extern int	errdomainconstraint(Oid datatypeOid, const char *conname);
 
-/* encode.c */
-extern uint64 hex_encode(const char *src, size_t len, char *dst);
-
 /* int.c */
 extern int2vector *buildint2vector(const int16 *int2s, int n);
 
diff --git a/src/tools/msvc/Mkvcbuild.pm b/src/tools/msvc/Mkvcbuild.pm
index 7f014a12c9..60b216cce0 100644
--- a/src/tools/msvc/Mkvcbuild.pm
+++ b/src/tools/msvc/Mkvcbuild.pm
@@ -121,7 +121,7 @@ sub mkvcbuild
 	our @pgcommonallfiles = qw(
 	  archive.c base64.c checksum_helper.c
 	  config_info.c controldata_utils.c d2s.c encnames.c exec.c
-	  f2s.c file_perm.c file_utils.c hashfn.c hex_decode.c ip.c jsonapi.c
+	  f2s.c file_perm.c file_utils.c hashfn.c hex.c ip.c jsonapi.c
 	  keywords.c kwlookup.c link-canary.c md5_common.c
 	  pg_get_line.c pg_lzcompress.c pgfnames.c psprintf.c relpath.c rmtree.c
 	  saslprep.c scram-common.c string.c stringinfo.c unicode_norm.c username.c
-- 
2.20.1


--IJpNTDwzlM2Ie8A6--





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

* Relids instead of Bitmapset * in plannode.h
@ 2023-10-31 06:11 Ashutosh Bapat <[email protected]>
  2023-11-07 11:06 ` Re: Relids instead of Bitmapset * in plannode.h Alvaro Herrera <[email protected]>
  0 siblings, 1 reply; 27+ messages in thread

From: Ashutosh Bapat @ 2023-10-31 06:11 UTC (permalink / raw)
  To: PostgreSQL Hackers <[email protected]>

Hi,
For some reason plannode.h has declared variable to hold RTIs as
Bitmapset * instead of Relids like other places. Here's patch to fix
it. This is superficial change as Relids is typedefed to Bitmapset *.
Build succeeds for me and also make check passes.

-- 
Best Wishes,
Ashutosh Bapat


Attachments:

  [text/x-patch] 0001-Use-Relids-instead-of-Bitmapset-in-plannode-20231031.patch (2.5K, ../../CAExHW5tHCdRRAv6gu5qKb23Gniyg6twQAHm-mPkc+D+Aavmoug@mail.gmail.com/2-0001-Use-Relids-instead-of-Bitmapset-in-plannode-20231031.patch)
  download | inline diff:
From 1458cbd5dade42670b9a0499b65213758790b71f Mon Sep 17 00:00:00 2001
From: Ashutosh Bapat <[email protected]>
Date: Tue, 31 Oct 2023 11:29:29 +0530
Subject: [PATCH] Use Relids instead of Bitmapset * in plannode.h

Most of the planner code uses Relids instead of Bitmapset * to declare a
bitmapset of RTIs. Fix plannode.h to do the same.

Ashutosh Bapat
---
 src/include/nodes/plannodes.h | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/src/include/nodes/plannodes.h b/src/include/nodes/plannodes.h
index 1b787fe031..7b30a41a62 100644
--- a/src/include/nodes/plannodes.h
+++ b/src/include/nodes/plannodes.h
@@ -18,9 +18,9 @@
 #include "access/stratnum.h"
 #include "common/relpath.h"
 #include "lib/stringinfo.h"
-#include "nodes/bitmapset.h"
 #include "nodes/lockoptions.h"
 #include "nodes/parsenodes.h"
+#include "nodes/pathnodes.h"
 #include "nodes/primnodes.h"
 
 
@@ -263,7 +263,7 @@ struct PartitionPruneInfo;		/* forward reference to struct below */
 typedef struct Append
 {
 	Plan		plan;
-	Bitmapset  *apprelids;		/* RTIs of appendrel(s) formed by this node */
+	Relids		apprelids;		/* RTIs of appendrel(s) formed by this node */
 	List	   *appendplans;
 	int			nasyncplans;	/* # of asynchronous plans */
 
@@ -287,7 +287,7 @@ typedef struct MergeAppend
 	Plan		plan;
 
 	/* RTIs of appendrel(s) formed by this node */
-	Bitmapset  *apprelids;
+	Relids		apprelids;
 
 	List	   *mergeplans;
 
@@ -714,8 +714,8 @@ typedef struct ForeignScan
 	List	   *fdw_private;	/* private data for FDW */
 	List	   *fdw_scan_tlist; /* optional tlist describing scan tuple */
 	List	   *fdw_recheck_quals;	/* original quals not in scan.plan.qual */
-	Bitmapset  *fs_relids;		/* base+OJ RTIs generated by this scan */
-	Bitmapset  *fs_base_relids; /* base RTIs generated by this scan */
+	Relids		fs_relids;		/* base+OJ RTIs generated by this scan */
+	Relids		fs_base_relids; /* base RTIs generated by this scan */
 	bool		fsSystemCol;	/* true if any "system column" is needed */
 } ForeignScan;
 
@@ -743,7 +743,7 @@ typedef struct CustomScan
 	List	   *custom_exprs;	/* expressions that custom code may evaluate */
 	List	   *custom_private; /* private data for custom code */
 	List	   *custom_scan_tlist;	/* optional tlist describing scan tuple */
-	Bitmapset  *custom_relids;	/* RTIs generated by this scan */
+	Relids		custom_relids;	/* RTIs generated by this scan */
 
 	/*
 	 * NOTE: The method field of CustomScan is required to be a pointer to a
-- 
2.25.1



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

* Re: Relids instead of Bitmapset * in plannode.h
  2023-10-31 06:11 Relids instead of Bitmapset * in plannode.h Ashutosh Bapat <[email protected]>
@ 2023-11-07 11:06 ` Alvaro Herrera <[email protected]>
  2023-11-07 15:24   ` Re: Relids instead of Bitmapset * in plannode.h Tom Lane <[email protected]>
  0 siblings, 1 reply; 27+ messages in thread

From: Alvaro Herrera @ 2023-11-07 11:06 UTC (permalink / raw)
  To: Ashutosh Bapat <[email protected]>; +Cc: PostgreSQL Hackers <[email protected]>

Hello,

On 2023-Oct-31, Ashutosh Bapat wrote:

> For some reason plannode.h has declared variable to hold RTIs as
> Bitmapset * instead of Relids like other places. Here's patch to fix
> it. This is superficial change as Relids is typedefed to Bitmapset *.
> Build succeeds for me and also make check passes.

I think the reason for having done it this way, was mostly to avoid
including pathnodes.h in plannodes.h.  Did you explore what the
consequences are?  Starting here:
https://doxygen.postgresql.org/plannodes_8h.html

While looking at it, I noticed that tcopprot.h includes both plannodes.h
and parsenodes.h, but there's no reason to include the latter (or at
least headerscheck doesn't complain after removing it), so I propose to
remove it, per 0001 here.  There's a couple of files that need to be
repaired for this change.  windowfuncs.c is a no-brainer.  However,
having to edit bootstrap.h is a bit surprising -- I think before
dac048f71ebb ("Build all Flex files standalone") this inclusion wasn't
necessary, because the .y file already includes parsenodes.h; but after
that commit, bootparse.h needs parsenodes.h to declare YYSTYPE, per
comments in bootscanner.l.  Anyway, this seems a good change.

I also noticed while looking that I messed up in commit 7103ebb7aae8
("Add support for MERGE SQL command") on this point, because I added
#include parsenodes.h to plannodes.h.  This is because MergeAction,
which is in parsenodes.h, is also needed by some executor code.  But the
real way to fix that is to define that struct in primnodes.h.  0002 does
that.  (I'm forced to also move enum OverridingKind there, which is a
bit annoying.)

0003 here is your patch, which I include because of conflicts with my
0002.  After my 0002, plannodes.h is pretty slim, so I'd be hesitant to
include pathnodes.h just to be able to change the Bitmapset * to Relids.
But on the other hand, it doesn't seem to have too bad an effect overall
(if only because plannodes.h is included by rather few files), so +0.1
on doing this.  I would be more at ease if we didn't have to include
parsenodes.h in pathnodes.h, though, but that looks more difficult to
achieve.

-- 
Álvaro Herrera        Breisgau, Deutschland  —  https://www.EnterpriseDB.com/


Attachments:

  [text/x-diff] v2-0001-Don-t-include-parsenodes.h-in-tcopprot.h.patch (1.4K, ../../[email protected]/2-v2-0001-Don-t-include-parsenodes.h-in-tcopprot.h.patch)
  download | inline diff:
From dee38d19b281586a17788856cf169b8344c30da7 Mon Sep 17 00:00:00 2001
From: Alvaro Herrera <[email protected]>
Date: Mon, 6 Nov 2023 18:27:42 +0100
Subject: [PATCH v2 1/3] Don't include parsenodes.h in tcopprot.h

---
 src/backend/utils/adt/windowfuncs.c | 1 +
 src/include/bootstrap/bootstrap.h   | 1 +
 src/include/tcop/tcopprot.h         | 1 -
 3 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/backend/utils/adt/windowfuncs.c b/src/backend/utils/adt/windowfuncs.c
index b87a624fb2..cbdfba6994 100644
--- a/src/backend/utils/adt/windowfuncs.c
+++ b/src/backend/utils/adt/windowfuncs.c
@@ -14,6 +14,7 @@
 #include "postgres.h"
 
 #include "nodes/supportnodes.h"
+#include "nodes/parsenodes.h"
 #include "utils/builtins.h"
 #include "windowapi.h"
 
diff --git a/src/include/bootstrap/bootstrap.h b/src/include/bootstrap/bootstrap.h
index e1cb73c5f2..6a212122a3 100644
--- a/src/include/bootstrap/bootstrap.h
+++ b/src/include/bootstrap/bootstrap.h
@@ -15,6 +15,7 @@
 #define BOOTSTRAP_H
 
 #include "nodes/execnodes.h"
+#include "nodes/parsenodes.h"
 
 
 /*
diff --git a/src/include/tcop/tcopprot.h b/src/include/tcop/tcopprot.h
index 6c49db3bb7..b694d85974 100644
--- a/src/include/tcop/tcopprot.h
+++ b/src/include/tcop/tcopprot.h
@@ -15,7 +15,6 @@
 #define TCOPPROT_H
 
 #include "nodes/params.h"
-#include "nodes/parsenodes.h"
 #include "nodes/plannodes.h"
 #include "storage/procsignal.h"
 #include "utils/guc.h"
-- 
2.39.2



  [text/x-diff] v2-0002-Remove-parsenodes.h-from-plannodes.h.patch (3.4K, ../../[email protected]/3-v2-0002-Remove-parsenodes.h-from-plannodes.h.patch)
  download | inline diff:
From 870a853434b56d1fecd1a5fe85a56a2f60ff4ca9 Mon Sep 17 00:00:00 2001
From: Alvaro Herrera <[email protected]>
Date: Mon, 6 Nov 2023 18:28:08 +0100
Subject: [PATCH v2 2/3] Remove parsenodes.h from plannodes.h

This mistake was made because MergeAction was added to parsenodes.h
instead of primnodes.h, where it should have been.  Put it there.
---
 src/include/nodes/parsenodes.h | 24 ------------------------
 src/include/nodes/plannodes.h  |  1 -
 src/include/nodes/primnodes.h  | 27 +++++++++++++++++++++++++++
 3 files changed, 27 insertions(+), 25 deletions(-)

diff --git a/src/include/nodes/parsenodes.h b/src/include/nodes/parsenodes.h
index cf7e79062e..e494309da8 100644
--- a/src/include/nodes/parsenodes.h
+++ b/src/include/nodes/parsenodes.h
@@ -30,13 +30,6 @@
 #include "partitioning/partdefs.h"
 
 
-typedef enum OverridingKind
-{
-	OVERRIDING_NOT_SET = 0,
-	OVERRIDING_USER_VALUE,
-	OVERRIDING_SYSTEM_VALUE,
-} OverridingKind;
-
 /* Possible sources of a Query */
 typedef enum QuerySource
 {
@@ -1681,23 +1674,6 @@ typedef struct MergeWhenClause
 	List	   *values;			/* VALUES to INSERT, or NULL */
 } MergeWhenClause;
 
-/*
- * MergeAction -
- *		Transformed representation of a WHEN clause in a MERGE statement
- */
-typedef struct MergeAction
-{
-	NodeTag		type;
-	bool		matched;		/* true=MATCHED, false=NOT MATCHED */
-	CmdType		commandType;	/* INSERT/UPDATE/DELETE/DO NOTHING */
-	/* OVERRIDING clause */
-	OverridingKind override pg_node_attr(query_jumble_ignore);
-	Node	   *qual;			/* transformed WHEN conditions */
-	List	   *targetList;		/* the target list (of TargetEntry) */
-	/* target attribute numbers of an UPDATE */
-	List	   *updateColnos pg_node_attr(query_jumble_ignore);
-} MergeAction;
-
 /*
  * TriggerTransition -
  *	   representation of transition row or table naming clause
diff --git a/src/include/nodes/plannodes.h b/src/include/nodes/plannodes.h
index 24d46c76dc..d40af8e59f 100644
--- a/src/include/nodes/plannodes.h
+++ b/src/include/nodes/plannodes.h
@@ -20,7 +20,6 @@
 #include "lib/stringinfo.h"
 #include "nodes/bitmapset.h"
 #include "nodes/lockoptions.h"
-#include "nodes/parsenodes.h"
 #include "nodes/primnodes.h"
 
 
diff --git a/src/include/nodes/primnodes.h b/src/include/nodes/primnodes.h
index ab6d7fdc6d..bb930afb52 100644
--- a/src/include/nodes/primnodes.h
+++ b/src/include/nodes/primnodes.h
@@ -22,6 +22,14 @@
 #include "nodes/pg_list.h"
 
 
+typedef enum OverridingKind
+{
+	OVERRIDING_NOT_SET = 0,
+	OVERRIDING_USER_VALUE,
+	OVERRIDING_SYSTEM_VALUE,
+} OverridingKind;
+
+
 /* ----------------------------------------------------------------
  *						node definitions
  * ----------------------------------------------------------------
@@ -1718,6 +1726,25 @@ typedef struct BooleanTest
 	int			location;		/* token location, or -1 if unknown */
 } BooleanTest;
 
+
+/*
+ * MergeAction
+ *
+ * Transformed representation of a WHEN clause in a MERGE statement
+ */
+typedef struct MergeAction
+{
+	NodeTag		type;
+	bool		matched;		/* true=MATCHED, false=NOT MATCHED */
+	CmdType		commandType;	/* INSERT/UPDATE/DELETE/DO NOTHING */
+	/* OVERRIDING clause */
+	OverridingKind override pg_node_attr(query_jumble_ignore);
+	Node	   *qual;			/* transformed WHEN conditions */
+	List	   *targetList;		/* the target list (of TargetEntry) */
+	/* target attribute numbers of an UPDATE */
+	List	   *updateColnos pg_node_attr(query_jumble_ignore);
+} MergeAction;
+
 /*
  * CoerceToDomain
  *
-- 
2.39.2



  [text/x-diff] v2-0003-Use-Relids-instead-of-Bitmapset-in-plannode.h.patch (2.4K, ../../[email protected]/4-v2-0003-Use-Relids-instead-of-Bitmapset-in-plannode.h.patch)
  download | inline diff:
From 02987af92cea736dfe6819200304f7e122c842f5 Mon Sep 17 00:00:00 2001
From: Ashutosh Bapat <[email protected]>
Date: Tue, 31 Oct 2023 11:29:29 +0530
Subject: [PATCH v2 3/3] Use Relids instead of Bitmapset * in plannode.h

Most of the planner code uses Relids instead of Bitmapset * to declare a
bitmapset of RTIs. Fix plannode.h to do the same.

Ashutosh Bapat
---
 src/include/nodes/plannodes.h | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/src/include/nodes/plannodes.h b/src/include/nodes/plannodes.h
index d40af8e59f..c835a4ec16 100644
--- a/src/include/nodes/plannodes.h
+++ b/src/include/nodes/plannodes.h
@@ -18,8 +18,8 @@
 #include "access/stratnum.h"
 #include "common/relpath.h"
 #include "lib/stringinfo.h"
-#include "nodes/bitmapset.h"
 #include "nodes/lockoptions.h"
+#include "nodes/pathnodes.h"
 #include "nodes/primnodes.h"
 
 
@@ -263,7 +263,7 @@ struct PartitionPruneInfo;		/* forward reference to struct below */
 typedef struct Append
 {
 	Plan		plan;
-	Bitmapset  *apprelids;		/* RTIs of appendrel(s) formed by this node */
+	Relids		apprelids;		/* RTIs of appendrel(s) formed by this node */
 	List	   *appendplans;
 	int			nasyncplans;	/* # of asynchronous plans */
 
@@ -287,7 +287,7 @@ typedef struct MergeAppend
 	Plan		plan;
 
 	/* RTIs of appendrel(s) formed by this node */
-	Bitmapset  *apprelids;
+	Relids		apprelids;
 
 	List	   *mergeplans;
 
@@ -714,8 +714,8 @@ typedef struct ForeignScan
 	List	   *fdw_private;	/* private data for FDW */
 	List	   *fdw_scan_tlist; /* optional tlist describing scan tuple */
 	List	   *fdw_recheck_quals;	/* original quals not in scan.plan.qual */
-	Bitmapset  *fs_relids;		/* base+OJ RTIs generated by this scan */
-	Bitmapset  *fs_base_relids; /* base RTIs generated by this scan */
+	Relids		fs_relids;		/* base+OJ RTIs generated by this scan */
+	Relids		fs_base_relids; /* base RTIs generated by this scan */
 	bool		fsSystemCol;	/* true if any "system column" is needed */
 } ForeignScan;
 
@@ -743,7 +743,7 @@ typedef struct CustomScan
 	List	   *custom_exprs;	/* expressions that custom code may evaluate */
 	List	   *custom_private; /* private data for custom code */
 	List	   *custom_scan_tlist;	/* optional tlist describing scan tuple */
-	Bitmapset  *custom_relids;	/* RTIs generated by this scan */
+	Relids		custom_relids;	/* RTIs generated by this scan */
 
 	/*
 	 * NOTE: The method field of CustomScan is required to be a pointer to a
-- 
2.39.2



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

* Re: Relids instead of Bitmapset * in plannode.h
  2023-10-31 06:11 Relids instead of Bitmapset * in plannode.h Ashutosh Bapat <[email protected]>
  2023-11-07 11:06 ` Re: Relids instead of Bitmapset * in plannode.h Alvaro Herrera <[email protected]>
@ 2023-11-07 15:24   ` Tom Lane <[email protected]>
  2023-11-09 05:42     ` Re: Relids instead of Bitmapset * in plannode.h Ashutosh Bapat <[email protected]>
  0 siblings, 1 reply; 27+ messages in thread

From: Tom Lane @ 2023-11-07 15:24 UTC (permalink / raw)
  To: Alvaro Herrera <[email protected]>; +Cc: Ashutosh Bapat <[email protected]>; PostgreSQL Hackers <[email protected]>

Alvaro Herrera <[email protected]> writes:
> On 2023-Oct-31, Ashutosh Bapat wrote:
>> For some reason plannode.h has declared variable to hold RTIs as
>> Bitmapset * instead of Relids like other places. Here's patch to fix
>> it. This is superficial change as Relids is typedefed to Bitmapset *.
>> Build succeeds for me and also make check passes.

> I think the reason for having done it this way, was mostly to avoid
> including pathnodes.h in plannodes.h.

Yes, I'm pretty sure that's exactly the reason, and I'm strongly
against the initially-proposed patch.  The include footprint of
pathnodes.h would be greatly expanded, for no real benefit.
Among other things, that fuzzes the distinction between planner
modules and non-planner modules.

> While looking at it, I noticed that tcopprot.h includes both plannodes.h
> and parsenodes.h, but there's no reason to include the latter (or at
> least headerscheck doesn't complain after removing it), so I propose to
> remove it, per 0001 here.

0001 is ok, except check #include alphabetization.

> I also noticed while looking that I messed up in commit 7103ebb7aae8
> ("Add support for MERGE SQL command") on this point, because I added
> #include parsenodes.h to plannodes.h.  This is because MergeAction,
> which is in parsenodes.h, is also needed by some executor code.  But the
> real way to fix that is to define that struct in primnodes.h.  0002 does
> that.  (I'm forced to also move enum OverridingKind there, which is a
> bit annoying.)

This seems OK.  It seems to me that parsenodes.h has been required
by plannodes.h for a long time, but if we can decouple them, all
the better.

> 0003 here is your patch, which I include because of conflicts with my
> 0002.

Still don't like it.

> ... I would be more at ease if we didn't have to include
> parsenodes.h in pathnodes.h, though, but that looks more difficult to
> achieve.

Yeah, that dependency has been there a long time too.  I'm not too
fussed by dependencies on parsenodes.h, because anything involved
with either planning or execution will certainly be looking at
query trees too.  But I don't want to add dependencies that tie
planning and execution together.

			regards, tom lane






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

* Re: Relids instead of Bitmapset * in plannode.h
  2023-10-31 06:11 Relids instead of Bitmapset * in plannode.h Ashutosh Bapat <[email protected]>
  2023-11-07 11:06 ` Re: Relids instead of Bitmapset * in plannode.h Alvaro Herrera <[email protected]>
  2023-11-07 15:24   ` Re: Relids instead of Bitmapset * in plannode.h Tom Lane <[email protected]>
@ 2023-11-09 05:42     ` Ashutosh Bapat <[email protected]>
  2023-11-09 06:08       ` Re: Relids instead of Bitmapset * in plannode.h Tom Lane <[email protected]>
  0 siblings, 1 reply; 27+ messages in thread

From: Ashutosh Bapat @ 2023-11-09 05:42 UTC (permalink / raw)
  To: Tom Lane <[email protected]>; +Cc: Alvaro Herrera <[email protected]>; PostgreSQL Hackers <[email protected]>

On Tue, Nov 7, 2023 at 8:54 PM Tom Lane <[email protected]> wrote:
>
> Alvaro Herrera <[email protected]> writes:
> > On 2023-Oct-31, Ashutosh Bapat wrote:
> >> For some reason plannode.h has declared variable to hold RTIs as
> >> Bitmapset * instead of Relids like other places. Here's patch to fix
> >> it. This is superficial change as Relids is typedefed to Bitmapset *.
> >> Build succeeds for me and also make check passes.
>
> > I think the reason for having done it this way, was mostly to avoid
> > including pathnodes.h in plannodes.h.
>
> Yes, I'm pretty sure that's exactly the reason, and I'm strongly
> against the initially-proposed patch.  The include footprint of
> pathnodes.h would be greatly expanded, for no real benefit.
> Among other things, that fuzzes the distinction between planner
> modules and non-planner modules.

As I mentioned in [1] the Bitmapset implementation is not space
efficient to be used as Relids when there are thousands of partitions.
I was assessing all usages of Bitmapset to find if there are other
places where this is an issue. That's when I noticed this. At some
point in future (possibly quite near) when queries will involved
thousands of relations (partitions or otherwise) we will need to
implement Relids in more space efficient way. Having all Relids usages
of Bitmapset labelled as Relids will help us then. If we don't want to
add pathnodes.h to plannodes.h there will be more work to identify
Relids usage. That shouldn't be a couple of days work, so it's ok.

Other possibilities are
1. Define Relids in bitmapset.h itself and use Relids everywhere
Bitmapset * is really Relids. Wherever Relids is used bitmapset.h must
have been included one or other other way. That's a bigger churn.

2. Replace RTIs with Relids in the comments and add the following
comment somewhere near the #include section. "The Relids members in
various structures in this file have been declared as Bitmapset * to
avoid including pathnodes.h in this file. This include has greatly
expanded footprint for no real benefit.".

3. Do nothing right now. If and when we implement Relids as a separate
datastructure, it will get its own module. We will be able to place it
somewhere properly.

I have no additional comments on other patches.

[1] https://www.postgresql.org/message-id/CAExHW5s4EqY43oB%3Dne6B2%3D-xLgrs9ZGeTr1NXwkGFt2j-OmaQQ%40mail...

-- 
Best Wishes,
Ashutosh Bapat






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

* Re: Relids instead of Bitmapset * in plannode.h
  2023-10-31 06:11 Relids instead of Bitmapset * in plannode.h Ashutosh Bapat <[email protected]>
  2023-11-07 11:06 ` Re: Relids instead of Bitmapset * in plannode.h Alvaro Herrera <[email protected]>
  2023-11-07 15:24   ` Re: Relids instead of Bitmapset * in plannode.h Tom Lane <[email protected]>
  2023-11-09 05:42     ` Re: Relids instead of Bitmapset * in plannode.h Ashutosh Bapat <[email protected]>
@ 2023-11-09 06:08       ` Tom Lane <[email protected]>
  0 siblings, 0 replies; 27+ messages in thread

From: Tom Lane @ 2023-11-09 06:08 UTC (permalink / raw)
  To: Ashutosh Bapat <[email protected]>; +Cc: Alvaro Herrera <[email protected]>; PostgreSQL Hackers <[email protected]>

Ashutosh Bapat <[email protected]> writes:
> On Tue, Nov 7, 2023 at 8:54 PM Tom Lane <[email protected]> wrote:
>> Yes, I'm pretty sure that's exactly the reason, and I'm strongly
>> against the initially-proposed patch.  The include footprint of
>> pathnodes.h would be greatly expanded, for no real benefit.

> As I mentioned in [1] the Bitmapset implementation is not space
> efficient to be used as Relids when there are thousands of partitions.

TBH, I'd be very strongly against "optimizing" that case by adopting a
data structure that is less efficient for typical rangetable sizes.
I continue to think that anybody who is using that many partitions
is Doing It Wrong and has no excuse for thinking it'll be free.
Moreover, the size of their relid sets is pretty unlikely to be
their worst pain point.

In any case, that is a poor argument for weakening the separation
between planner and executor.  When and if somebody comes up with
a credible replacement for bitmapsets here, we can consider what
we want to do in terms of header-file organization --- but I do
not think including pathnodes.h into executor files will be it.

			regards, tom lane






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


end of thread, other threads:[~2023-11-09 06:08 UTC | newest]

Thread overview: 27+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2021-01-01 20:04 [PATCH] hex squash commit Bruce Momjian <[email protected]>
2021-01-01 20:04 [PATCH] hex squash commit Bruce Momjian <[email protected]>
2021-01-01 20:04 [PATCH] hex squash commit Bruce Momjian <[email protected]>
2021-01-01 20:04 [PATCH] hex squash commit Bruce Momjian <[email protected]>
2021-01-01 20:04 [PATCH] hex squash commit Bruce Momjian <[email protected]>
2021-01-01 20:04 [PATCH] hex squash commit Bruce Momjian <[email protected]>
2021-01-01 20:04 [PATCH] hex squash commit Bruce Momjian <[email protected]>
2021-01-01 20:04 [PATCH] hex squash commit Bruce Momjian <[email protected]>
2021-01-01 20:04 [PATCH] hex squash commit Bruce Momjian <[email protected]>
2021-01-01 20:04 [PATCH] hex squash commit Bruce Momjian <[email protected]>
2021-01-01 20:04 [PATCH] hex squash commit Bruce Momjian <[email protected]>
2021-01-01 20:04 [PATCH] hex squash commit Bruce Momjian <[email protected]>
2021-01-01 20:04 [PATCH] hex squash commit Bruce Momjian <[email protected]>
2021-01-01 20:04 [PATCH] hex squash commit Bruce Momjian <[email protected]>
2021-01-01 20:04 [PATCH] hex squash commit Bruce Momjian <[email protected]>
2021-01-01 20:04 [PATCH] hex squash commit Bruce Momjian <[email protected]>
2021-01-01 20:04 [PATCH] hex squash commit Bruce Momjian <[email protected]>
2021-01-01 20:04 [PATCH] hex squash commit Bruce Momjian <[email protected]>
2021-01-01 20:04 [PATCH] hex squash commit Bruce Momjian <[email protected]>
2021-01-01 20:04 [PATCH] hex squash commit Bruce Momjian <[email protected]>
2021-01-01 20:04 [PATCH] hex squash commit Bruce Momjian <[email protected]>
2021-01-01 20:04 [PATCH] hex squash commit Bruce Momjian <[email protected]>
2023-10-31 06:11 Relids instead of Bitmapset * in plannode.h Ashutosh Bapat <[email protected]>
2023-11-07 11:06 ` Re: Relids instead of Bitmapset * in plannode.h Alvaro Herrera <[email protected]>
2023-11-07 15:24   ` Re: Relids instead of Bitmapset * in plannode.h Tom Lane <[email protected]>
2023-11-09 05:42     ` Re: Relids instead of Bitmapset * in plannode.h Ashutosh Bapat <[email protected]>
2023-11-09 06:08       ` Re: Relids instead of Bitmapset * in plannode.h Tom Lane <[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