public inbox for [email protected]  
help / color / mirror / Atom feed
[PATCH v3 3/5] Optimize JsonbContainer type recognition in get_jsonb_path_all()
4+ messages / 3 participants
[nested] [flat]

* [PATCH v3 3/5] Optimize JsonbContainer type recognition in get_jsonb_path_all()
@ 2019-02-21 00:08  Nikita Glukhov <[email protected]>
  0 siblings, 0 replies; 4+ messages in thread

From: Nikita Glukhov @ 2019-02-21 00:08 UTC (permalink / raw)

---
 src/backend/utils/adt/jsonfuncs.c | 16 +++++++---------
 1 file changed, 7 insertions(+), 9 deletions(-)

diff --git a/src/backend/utils/adt/jsonfuncs.c b/src/backend/utils/adt/jsonfuncs.c
index c7f71408d5..753d691d75 100644
--- a/src/backend/utils/adt/jsonfuncs.c
+++ b/src/backend/utils/adt/jsonfuncs.c
@@ -1487,18 +1487,16 @@ get_jsonb_path_all(FunctionCallInfo fcinfo, bool as_text)
 
 		if (jbvp->type == jbvBinary)
 		{
-			JsonbIterator *it = JsonbIteratorInit((JsonbContainer *) jbvp->val.binary.data);
-			JsonbIteratorToken r;
-
-			r = JsonbIteratorNext(&it, &tv, true);
-			container = (JsonbContainer *) jbvp->val.binary.data;
-			have_object = r == WJB_BEGIN_OBJECT;
-			have_array = r == WJB_BEGIN_ARRAY;
+			container = jbvp->val.binary.data;
+			have_object = JsonContainerIsObject(container);
+			have_array = JsonContainerIsArray(container);
+			Assert(!JsonbContainerIsScalar(container));
 		}
 		else
 		{
-			have_object = jbvp->type == jbvObject;
-			have_array = jbvp->type == jbvArray;
+			Assert(IsAJsonbScalar(jbvp));
+			have_object = false;
+			have_array = false;
 		}
 	}
 
-- 
2.17.1


--IJpNTDwzlM2Ie8A6
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
 filename="v3-0004-Extract-findJsonbKeyInObject.patch"



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

* [PATCH 3/5] Optimize JsonbContainer type recognition in get_jsonb_path_all()
@ 2019-02-21 00:08  Nikita Glukhov <[email protected]>
  0 siblings, 0 replies; 4+ messages in thread

From: Nikita Glukhov @ 2019-02-21 00:08 UTC (permalink / raw)

---
 src/backend/utils/adt/jsonfuncs.c | 16 +++++++---------
 1 file changed, 7 insertions(+), 9 deletions(-)

diff --git a/src/backend/utils/adt/jsonfuncs.c b/src/backend/utils/adt/jsonfuncs.c
index 162dffa..cfbd89b 100644
--- a/src/backend/utils/adt/jsonfuncs.c
+++ b/src/backend/utils/adt/jsonfuncs.c
@@ -1488,18 +1488,16 @@ get_jsonb_path_all(FunctionCallInfo fcinfo, bool as_text)
 
 		if (jbvp->type == jbvBinary)
 		{
-			JsonbIterator *it = JsonbIteratorInit((JsonbContainer *) jbvp->val.binary.data);
-			JsonbIteratorToken r;
-
-			r = JsonbIteratorNext(&it, &tv, true);
-			container = (JsonbContainer *) jbvp->val.binary.data;
-			have_object = r == WJB_BEGIN_OBJECT;
-			have_array = r == WJB_BEGIN_ARRAY;
+			container = jbvp->val.binary.data;
+			have_object = JsonContainerIsObject(container);
+			have_array = JsonContainerIsArray(container);
+			Assert(!JsonbContainerIsScalar(container));
 		}
 		else
 		{
-			have_object = jbvp->type == jbvObject;
-			have_array = jbvp->type == jbvArray;
+			Assert(IsAJsonbScalar(jbvp));
+			have_object = false;
+			have_array = false;
 		}
 	}
 
-- 
2.7.4


--------------55D1241744B27FF04177252F
Content-Type: text/x-patch;
 name="0004-Extract-findJsonbKeyInObject-v01.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
 filename="0004-Extract-findJsonbKeyInObject-v01.patch"



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

* Re: Fixes required for cross version update testing
@ 2023-01-14 00:57  Andrew Dunstan <[email protected]>
  0 siblings, 0 replies; 4+ messages in thread

From: Andrew Dunstan @ 2023-01-14 00:57 UTC (permalink / raw)
  To: Tom Lane <[email protected]>; +Cc: PostgreSQL Hackers <[email protected]>


On 2023-01-13 Fr 19:49, Tom Lane wrote:
> Andrew Dunstan <[email protected]> writes:
>> Here's a piece of WIP for that, in the form of a perl module that
>> provides a function that takes an old version number / tag and provides
>> the set of sql statements that need to be run to make the old repo
>> upgradeable. It still needs a good deal of polish, but it's a start.
> Oh!  I've been hacking on exactly the same idea all day ...
>
> https://www.postgresql.org/message-id/891521.1673657296%40sss.pgh.pa.us
>
> 			



Oh, sorry if I have wasted some of your time. I posted my outline idea
and then it itched so I scratched.


cheers


andrew


--
Andrew Dunstan
EDB: https://www.enterprisedb.com







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

* [PATCH v8 2/4] make common enum for sync methods
@ 2023-08-31 14:38  Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 4+ messages in thread

From: Nathan Bossart @ 2023-08-31 14:38 UTC (permalink / raw)

---
 src/backend/storage/file/fd.c       | 4 ++--
 src/backend/utils/misc/guc_tables.c | 7 ++++---
 src/include/common/file_utils.h     | 6 ++++++
 src/include/storage/fd.h            | 6 ------
 src/tools/pgindent/typedefs.list    | 1 +
 5 files changed, 13 insertions(+), 11 deletions(-)

diff --git a/src/backend/storage/file/fd.c b/src/backend/storage/file/fd.c
index b490a76ba7..3fed475c38 100644
--- a/src/backend/storage/file/fd.c
+++ b/src/backend/storage/file/fd.c
@@ -162,7 +162,7 @@ int			max_safe_fds = FD_MINFREE;	/* default if not changed */
 bool		data_sync_retry = false;
 
 /* How SyncDataDirectory() should do its job. */
-int			recovery_init_sync_method = RECOVERY_INIT_SYNC_METHOD_FSYNC;
+int			recovery_init_sync_method = DATA_DIR_SYNC_METHOD_FSYNC;
 
 /* Which kinds of files should be opened with PG_O_DIRECT. */
 int			io_direct_flags;
@@ -3513,7 +3513,7 @@ SyncDataDirectory(void)
 	}
 
 #ifdef HAVE_SYNCFS
-	if (recovery_init_sync_method == RECOVERY_INIT_SYNC_METHOD_SYNCFS)
+	if (recovery_init_sync_method == DATA_DIR_SYNC_METHOD_SYNCFS)
 	{
 		DIR		   *dir;
 		struct dirent *de;
diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c
index e565a3092f..5abebe9a9c 100644
--- a/src/backend/utils/misc/guc_tables.c
+++ b/src/backend/utils/misc/guc_tables.c
@@ -41,6 +41,7 @@
 #include "commands/trigger.h"
 #include "commands/user.h"
 #include "commands/vacuum.h"
+#include "common/file_utils.h"
 #include "common/scram-common.h"
 #include "jit/jit.h"
 #include "libpq/auth.h"
@@ -430,9 +431,9 @@ StaticAssertDecl(lengthof(ssl_protocol_versions_info) == (PG_TLS1_3_VERSION + 2)
 				 "array length mismatch");
 
 static const struct config_enum_entry recovery_init_sync_method_options[] = {
-	{"fsync", RECOVERY_INIT_SYNC_METHOD_FSYNC, false},
+	{"fsync", DATA_DIR_SYNC_METHOD_FSYNC, false},
 #ifdef HAVE_SYNCFS
-	{"syncfs", RECOVERY_INIT_SYNC_METHOD_SYNCFS, false},
+	{"syncfs", DATA_DIR_SYNC_METHOD_SYNCFS, false},
 #endif
 	{NULL, 0, false}
 };
@@ -4964,7 +4965,7 @@ struct config_enum ConfigureNamesEnum[] =
 			gettext_noop("Sets the method for synchronizing the data directory before crash recovery."),
 		},
 		&recovery_init_sync_method,
-		RECOVERY_INIT_SYNC_METHOD_FSYNC, recovery_init_sync_method_options,
+		DATA_DIR_SYNC_METHOD_FSYNC, recovery_init_sync_method_options,
 		NULL, NULL, NULL
 	},
 
diff --git a/src/include/common/file_utils.h b/src/include/common/file_utils.h
index dd1532bcb0..7da21f15e6 100644
--- a/src/include/common/file_utils.h
+++ b/src/include/common/file_utils.h
@@ -24,6 +24,12 @@ typedef enum PGFileType
 	PGFILETYPE_LNK
 } PGFileType;
 
+typedef enum DataDirSyncMethod
+{
+	DATA_DIR_SYNC_METHOD_FSYNC,
+	DATA_DIR_SYNC_METHOD_SYNCFS
+} DataDirSyncMethod;
+
 struct iovec;					/* avoid including port/pg_iovec.h here */
 
 #ifdef FRONTEND
diff --git a/src/include/storage/fd.h b/src/include/storage/fd.h
index aea30c0622..d9d5d9da5f 100644
--- a/src/include/storage/fd.h
+++ b/src/include/storage/fd.h
@@ -46,12 +46,6 @@
 #include <dirent.h>
 #include <fcntl.h>
 
-typedef enum RecoveryInitSyncMethod
-{
-	RECOVERY_INIT_SYNC_METHOD_FSYNC,
-	RECOVERY_INIT_SYNC_METHOD_SYNCFS
-}			RecoveryInitSyncMethod;
-
 typedef int File;
 
 
diff --git a/src/tools/pgindent/typedefs.list b/src/tools/pgindent/typedefs.list
index 49a33c0387..fe571c6265 100644
--- a/src/tools/pgindent/typedefs.list
+++ b/src/tools/pgindent/typedefs.list
@@ -545,6 +545,7 @@ DR_printtup
 DR_sqlfunction
 DR_transientrel
 DWORD
+DataDirSyncMethod
 DataDumperPtr
 DataPageDeleteStack
 DatabaseInfo
-- 
2.25.1


--oyUTqETQ0mS9luUI
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
	filename="v8-0003-add-support-for-syncfs-in-frontend-support-functi.patch"



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


end of thread, other threads:[~2023-08-31 14:38 UTC | newest]

Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2019-02-21 00:08 [PATCH v3 3/5] Optimize JsonbContainer type recognition in get_jsonb_path_all() Nikita Glukhov <[email protected]>
2019-02-21 00:08 [PATCH 3/5] Optimize JsonbContainer type recognition in get_jsonb_path_all() Nikita Glukhov <[email protected]>
2023-01-14 00:57 Re: Fixes required for cross version update testing Andrew Dunstan <[email protected]>
2023-08-31 14:38 [PATCH v8 2/4] make common enum for sync methods Nathan Bossart <[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