Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add on-segment mode for pg_dump utility #1

Draft
wants to merge 3 commits into
base: adb-6.x-dev
Choose a base branch
from
Draft

Conversation

kooooootb
Copy link
Owner

@kooooootb kooooootb commented May 31, 2024

Add pg_dump on-segment mode, where data is stored locally on segments

This mode gets activated by using --on-segment flag, it generates dump on client side as usual and data dumps on each used segment, compression level and archive formats are forwarded to segments' archives
Generated dump can be used by pg_restore or psql (for plain texts) as usual

Also to manage data on segments 2 other system modes were added.
First one (--on-segment-internal-dump-mode) reads data from stdin to stores it locally with forwarded archive format and compression level.
Second (--on-segment-internal-restore-mode) reads stored data and passes it to stdout

In this mode utility uses COPY ... TO PROGRAM ... ON SEGMENT instead of normal COPY and passes output of it to pg_dump on each segment.
To restore data it saves COPY ... FROM PROGRAM ... ON SEGMENT operators to final dump, which read data from utility on each segment.

@kooooootb kooooootb force-pushed the gp_dump branch 2 times, most recently from fb0dd2c to 43fac53 Compare June 2, 2024 17:21
This mode is used to save data on each segment locally part by part
if (compressLevel != 0)
return runRestore_CompressedPlainText(inputFileSpec);
#endif
else

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

else is redundant here

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wanted to make it clear but ok, done

ropt = NewRestoreOptions();
ropt->filename = inputFileSpec;

if (compressLevel == -1)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's make the code simpler using ternary operator: ropt->compression = (compressLevel == -1) ? 0 : compressLevel;

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

static void
setupDumpWorkerDummy(Archive *AH, RestoreOptions *ropt)
{
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's add newline at the end of file here and below to make github happy

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done


((ArchiveHandle *)AH)->ropt = ropt;

if (plainText)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we use format == archNull in this condition and remove the plainText variable?

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

make sense, done

const int bufferSize = 1024;
const char *buffer[bufferSize];

size_t readLen = 0;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

0 is never used. The readLen value is changed in the next line

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

extern int onSegmentHelper_RunRestore(const char *inputFileSpec, int compressLevel, ArchiveFormat format);
extern int onSegmentHelper_RunDump(const char *inputFileSpec, int compressLevel, ArchiveFormat format);

#endif // PG_DUMP_SEGMENT_HELPER
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add newline

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants