36
36
#include "catalog/pg_tablespace.h"
37
37
#include "miscadmin.h"
38
38
#include "port/pg_crc32c.h"
39
- #ifdef PGPRO_EE
40
- /* For file_is_in_cfs_tablespace() only. */
41
- #include "common/cfs_common.h"
42
- #endif
43
39
#include "storage/copydir.h"
44
40
#if PG_VERSION_NUM >= 120000
45
41
#include "storage/md.h"
@@ -95,53 +91,6 @@ ptrack_write_chunk(int fd, pg_crc32c *crc, char *chunk, size_t size)
95
91
}
96
92
}
97
93
98
- /*
99
- * Determines whether given file path is a path to a cfm file.
100
- */
101
- bool
102
- is_cfm_file_path (const char * filepath ) {
103
- ssize_t len = strlen (filepath );
104
-
105
- // For this length checks we assume that the filename is at least
106
- // 1 character longer than the corresponding extension ".cfm":
107
- // strlen(".cfm") == 4 therefore we assume that the filename can't be
108
- // shorter than 5 bytes, for example: "5.cfm".
109
- return strlen (filepath ) >= 5 && strcmp (& filepath [len - 4 ], ".cfm" ) == 0 ;
110
- }
111
-
112
- #if CFS_SUPPORT
113
- /*
114
- * Determines the relation file size specified by fullpath as if it
115
- * was not compressed.
116
- */
117
- off_t
118
- get_cfs_relation_file_decompressed_size (RelFileNodeBackend rnode , const char * fullpath , ForkNumber forknum ) {
119
- File fd ;
120
- off_t size ;
121
-
122
- #if PG_VERSION_NUM >= 120000
123
- int compressor ;
124
- compressor = md_get_compressor_internal (nodeOf (rnode ), rnode .backend , forknum );
125
- fd = PathNameOpenFile (fullpath , O_RDWR | PG_BINARY , compressor );
126
- #else
127
- fd = PathNameOpenFile (fullpath , O_RDWR | PG_BINARY | PG_COMPRESSION );
128
- #endif
129
-
130
- if (fd < 0 )
131
- return (off_t )- 1 ;
132
-
133
- #if PG_VERSION_NUM >= 120000
134
- size = FileSize (fd );
135
- #else
136
- size = FileSeek (fd , 0 , SEEK_END );
137
- #endif
138
-
139
- FileClose (fd );
140
-
141
- return size ;
142
- }
143
- #endif
144
-
145
94
/*
146
95
* Delete ptrack files when ptrack is disabled.
147
96
*
@@ -549,13 +498,8 @@ assign_ptrack_map_size(int newval, void *extra)
549
498
* For use in functions that copy directories bypassing buffer manager.
550
499
*/
551
500
static void
552
- #if CFS_SUPPORT
553
- ptrack_mark_file (Oid dbOid , Oid tablespaceOid ,
554
- const char * filepath , const char * filename , bool is_cfs )
555
- #else
556
501
ptrack_mark_file (Oid dbOid , Oid tablespaceOid ,
557
502
const char * filepath , const char * filename )
558
- #endif
559
503
{
560
504
RelFileNodeBackend rnode ;
561
505
ForkNumber forknum ;
@@ -564,9 +508,6 @@ ptrack_mark_file(Oid dbOid, Oid tablespaceOid,
564
508
struct stat stat_buf ;
565
509
int oidchars ;
566
510
char oidbuf [OIDCHARS + 1 ];
567
- #if CFS_SUPPORT
568
- off_t rel_size ;
569
- #endif
570
511
571
512
/* Do not track temporary relations */
572
513
if (looks_like_temp_rel_name (filename ))
@@ -585,21 +526,6 @@ ptrack_mark_file(Oid dbOid, Oid tablespaceOid,
585
526
oidbuf [oidchars ] = '\0' ;
586
527
nodeRel (nodeOf (rnode )) = atooid (oidbuf );
587
528
588
- #if CFS_SUPPORT
589
- // if current tablespace is cfs-compressed and md_get_compressor_internal
590
- // returns the type of the compressing algorithm for filepath, then it
591
- // needs to be de-compressed to obtain its size
592
- if (is_cfs && md_get_compressor_internal (nodeOf (rnode ), rnode .backend , forknum ) != 0 ) {
593
- rel_size = get_cfs_relation_file_decompressed_size (rnode , filepath , forknum );
594
-
595
- if (rel_size == (off_t )- 1 ) {
596
- elog (WARNING , "ptrack: could not open cfs-compressed relation file: %s" , filepath );
597
- return ;
598
- }
599
-
600
- nblocks = rel_size / BLCKSZ ;
601
- } else
602
- #endif
603
529
/* Compute number of blocks based on file size */
604
530
if (stat (filepath , & stat_buf ) == 0 )
605
531
nblocks = stat_buf .st_size / BLCKSZ ;
@@ -620,9 +546,6 @@ ptrack_walkdir(const char *path, Oid tablespaceOid, Oid dbOid)
620
546
{
621
547
DIR * dir ;
622
548
struct dirent * de ;
623
- #if CFS_SUPPORT
624
- bool is_cfs ;
625
- #endif
626
549
627
550
/* Do not walk during bootstrap and if ptrack is disabled */
628
551
if (ptrack_map_size == 0
@@ -631,10 +554,6 @@ ptrack_walkdir(const char *path, Oid tablespaceOid, Oid dbOid)
631
554
|| InitializingParallelWorker )
632
555
return ;
633
556
634
- #if CFS_SUPPORT
635
- is_cfs = file_is_in_cfs_tablespace (path );
636
- #endif
637
-
638
557
dir = AllocateDir (path );
639
558
640
559
while ((de = ReadDirExtended (dir , path , LOG )) != NULL )
@@ -662,11 +581,7 @@ ptrack_walkdir(const char *path, Oid tablespaceOid, Oid dbOid)
662
581
}
663
582
664
583
if (S_ISREG (fst .st_mode ))
665
- #if CFS_SUPPORT
666
- ptrack_mark_file (dbOid , tablespaceOid , subpath , de -> d_name , is_cfs );
667
- #else
668
- ptrack_mark_file (dbOid , tablespaceOid , subpath , de -> d_name );
669
- #endif
584
+ ptrack_mark_file (dbOid , tablespaceOid , subpath , de -> d_name );
670
585
}
671
586
672
587
FreeDir (dir ); /* we ignore any error here */
0 commit comments