agora inbox for [email protected]
help / color / mirror / Atom feedFrom: Sutou Kouhei <[email protected]>
Subject: [PATCH v30 8/9] Add support for implementing custom COPY FROM format as extension
Date: Mon, 25 Nov 2024 14:21:39 +0900
* Add CopyFromStateData::opaque that can be used to keep data for
custom COPY From format implementation
* Export CopyGetData() to get the next data as
CopyFromStateGetData()
---
src/backend/commands/copyfromparse.c | 11 +++++++++++
src/include/commands/copyapi.h | 2 ++
src/include/commands/copyfrom_internal.h | 3 +++
3 files changed, 16 insertions(+)
diff --git a/src/backend/commands/copyfromparse.c b/src/backend/commands/copyfromparse.c
index f7982bf692f..650b6b2382b 100644
--- a/src/backend/commands/copyfromparse.c
+++ b/src/backend/commands/copyfromparse.c
@@ -729,6 +729,17 @@ CopyReadBinaryData(CopyFromState cstate, char *dest, int nbytes)
return copied_bytes;
}
+/*
+ * Export CopyGetData() for extensions. We want to keep CopyGetData() as a
+ * static function for optimization. CopyGetData() calls in this file may be
+ * optimized by a compiler.
+ */
+int
+CopyFromStateGetData(CopyFromState cstate, void *dest, int minread, int maxread)
+{
+ return CopyGetData(cstate, dest, minread, maxread);
+}
+
/*
* Read raw fields in the next line for COPY FROM in text or csv mode.
* Return false if no more lines.
diff --git a/src/include/commands/copyapi.h b/src/include/commands/copyapi.h
index bf933069fea..d1a1dbeb178 100644
--- a/src/include/commands/copyapi.h
+++ b/src/include/commands/copyapi.h
@@ -105,4 +105,6 @@ typedef struct CopyFromRoutine
void (*CopyFromEnd) (CopyFromState cstate);
} CopyFromRoutine;
+extern int CopyFromStateGetData(CopyFromState cstate, void *dest, int minread, int maxread);
+
#endif /* COPYAPI_H */
diff --git a/src/include/commands/copyfrom_internal.h b/src/include/commands/copyfrom_internal.h
index 3743b11faa4..a65bbbc962e 100644
--- a/src/include/commands/copyfrom_internal.h
+++ b/src/include/commands/copyfrom_internal.h
@@ -181,6 +181,9 @@ typedef struct CopyFromStateData
#define RAW_BUF_BYTES(cstate) ((cstate)->raw_buf_len - (cstate)->raw_buf_index)
uint64 bytes_processed; /* number of bytes processed so far */
+
+ /* For custom format implementation */
+ void *opaque; /* private space */
} CopyFromStateData;
extern void ReceiveCopyBegin(CopyFromState cstate);
--
2.47.1
----Next_Part(Sat_Feb__1_08_10_23_2025_403)--
Content-Type: Text/X-Patch; charset=us-ascii
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="v30-0009-Add-CopyFromSkipErrorRow-for-custom-COPY-format-.patch"
view thread (35+ messages) latest in thread
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: [email protected]
Cc: [email protected]
Subject: Re: [PATCH v30 8/9] Add support for implementing custom COPY FROM format as extension
In-Reply-To: <no-message-id-44187@localhost>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox