Skip to content

Commit 6ea5df1

Browse files
committed
Fix detect tablespace oid.
1 parent af0e674 commit 6ea5df1

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

backup.c

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1371,7 +1371,6 @@ void make_pagemap_from_ptrack(parray *files)
13711371
size_t start_addr;
13721372
Oid db_oid, rel_oid, tablespace_oid = 0;
13731373
int sep_iter, sep_count = 0;
1374-
tablespace = palloc0(64);
13751374

13761375
/* Find target path*/
13771376
for(sep_iter = (int)path_length; sep_iter >= 0; sep_iter--)
@@ -1380,16 +1379,17 @@ void make_pagemap_from_ptrack(parray *files)
13801379
{
13811380
sep_count++;
13821381
}
1383-
if (sep_count == 3)
1382+
if (sep_count == 2)
13841383
{
13851384
tmp_path += sep_iter + 1;
13861385
break;
13871386
}
13881387
}
13891388
/* For unix only now */
1390-
sscanf(tmp_path, "%[^/]/%u/%u_ptrack", tablespace, &db_oid, &rel_oid);
1391-
if (strcmp(tablespace, "base") != 0 && strcmp(tablespace, "global") != 0)
1392-
sscanf(tablespace, "%i", &tablespace_oid);
1389+
sscanf(tmp_path, "%u/%u_ptrack", &db_oid, &rel_oid);
1390+
tablespace = strstr(p->ptrack_path, "pg_tblspc");
1391+
if (tablespace != NULL)
1392+
sscanf(tablespace+10, "%i/", &tablespace_oid);
13931393

13941394
flat_memory = pg_ptrack_get_and_clear(tablespace_oid,
13951395
db_oid,
@@ -1401,7 +1401,6 @@ void make_pagemap_from_ptrack(parray *files)
14011401
p->pagemap.bitmap = pg_malloc(p->pagemap.bitmapsize);
14021402
memcpy(p->pagemap.bitmap, flat_memory+start_addr, p->pagemap.bitmapsize);
14031403
pg_free(flat_memory);
1404-
pg_free(tablespace);
14051404
}
14061405
}
14071406
}

0 commit comments

Comments
 (0)