25
25
#include "utils/memutils.h"
26
26
27
27
static void ResetUnloggedRelationsInTablespaceDir (const char * tsdirname ,
28
- int op );
28
+ int op , bool compressed );
29
29
static void ResetUnloggedRelationsInDbspaceDir (const char * dbspacedirname ,
30
- int op );
30
+ int op , bool compressed );
31
31
static bool parse_filename_for_nontemp_relation (const char * name ,
32
32
int * oidchars , ForkNumber * fork );
33
33
@@ -71,7 +71,7 @@ ResetUnloggedRelations(int op)
71
71
/*
72
72
* First process unlogged files in pg_default ($PGDATA/base)
73
73
*/
74
- ResetUnloggedRelationsInTablespaceDir ("base" , op );
74
+ ResetUnloggedRelationsInTablespaceDir ("base" , op , false );
75
75
76
76
/*
77
77
* Cycle through directories for all non-default tablespaces.
@@ -80,13 +80,25 @@ ResetUnloggedRelations(int op)
80
80
81
81
while ((spc_de = ReadDir (spc_dir , "pg_tblspc" )) != NULL )
82
82
{
83
+ FILE * compressionFile ;
84
+
83
85
if (strcmp (spc_de -> d_name , "." ) == 0 ||
84
86
strcmp (spc_de -> d_name , ".." ) == 0 )
85
87
continue ;
86
88
89
+ snprintf (temp_path , sizeof (temp_path ), "pg_tblspc/%s/%s/pg_compression" ,
90
+ spc_de -> d_name , TABLESPACE_VERSION_DIRECTORY );
91
+
92
+ compressionFile = fopen (temp_path , "r" );
93
+ if (compressionFile )
94
+ {
95
+ fclose (compressionFile );
96
+ }
97
+
87
98
snprintf (temp_path , sizeof (temp_path ), "pg_tblspc/%s/%s" ,
88
99
spc_de -> d_name , TABLESPACE_VERSION_DIRECTORY );
89
- ResetUnloggedRelationsInTablespaceDir (temp_path , op );
100
+
101
+ ResetUnloggedRelationsInTablespaceDir (temp_path , op , compressionFile != NULL );
90
102
}
91
103
92
104
FreeDir (spc_dir );
@@ -100,7 +112,7 @@ ResetUnloggedRelations(int op)
100
112
101
113
/* Process one tablespace directory for ResetUnloggedRelations */
102
114
static void
103
- ResetUnloggedRelationsInTablespaceDir (const char * tsdirname , int op )
115
+ ResetUnloggedRelationsInTablespaceDir (const char * tsdirname , int op , bool compressed )
104
116
{
105
117
DIR * ts_dir ;
106
118
struct dirent * de ;
@@ -133,15 +145,15 @@ ResetUnloggedRelationsInTablespaceDir(const char *tsdirname, int op)
133
145
134
146
snprintf (dbspace_path , sizeof (dbspace_path ), "%s/%s" ,
135
147
tsdirname , de -> d_name );
136
- ResetUnloggedRelationsInDbspaceDir (dbspace_path , op );
148
+ ResetUnloggedRelationsInDbspaceDir (dbspace_path , op , compressed );
137
149
}
138
150
139
151
FreeDir (ts_dir );
140
152
}
141
153
142
154
/* Process one per-dbspace directory for ResetUnloggedRelations */
143
155
static void
144
- ResetUnloggedRelationsInDbspaceDir (const char * dbspacedirname , int op )
156
+ ResetUnloggedRelationsInDbspaceDir (const char * dbspacedirname , int op , bool compressed )
145
157
{
146
158
DIR * dbspace_dir ;
147
159
struct dirent * de ;
@@ -332,8 +344,13 @@ ResetUnloggedRelationsInDbspaceDir(const char *dbspacedirname, int op)
332
344
strlen (forkNames [INIT_FORKNUM ]));
333
345
334
346
/* OK, we're ready to perform the actual copy. */
335
- elog (DEBUG2 , "copying %s to %s" , srcpath , dstpath );
336
- copy_file (srcpath , dstpath );
347
+ if (compressed ) {
348
+ elog (DEBUG2 , "copying %s to %s with compression" , srcpath , dstpath );
349
+ copy_zip_file (srcpath , false, dstpath , true);
350
+ } else {
351
+ elog (DEBUG2 , "copying %s to %s" , srcpath , dstpath );
352
+ copy_file (srcpath , dstpath );
353
+ }
337
354
}
338
355
339
356
FreeDir (dbspace_dir );
0 commit comments