Skip to content

Commit 35ce24c

Browse files
committed
pg_dump: Remove "blob" terminology
For historical reasons, pg_dump refers to large objects as "BLOBs". This term is not used anywhere else in PostgreSQL, and it also means something different in the SQL standard and other SQL systems. This patch renames internal functions, code comments, documentation, etc. to use the "large object" or "LO" terminology instead. There is no functionality change, so the archive format still uses the name "BLOB" for the archive entry. Additional long command-line options are added with the new naming. Reviewed-by: Daniel Gustafsson <[email protected]> Discussion: https://www.postgresql.org/message-id/flat/868a381f-4650-9460-1726-1ffd39a270b4%40enterprisedb.com
1 parent 8a476fd commit 35ce24c

14 files changed

+367
-361
lines changed

doc/src/sgml/ref/pg_dump.sgml

+9-7
Original file line numberDiff line numberDiff line change
@@ -132,15 +132,16 @@ PostgreSQL documentation
132132

133133
<varlistentry>
134134
<term><option>-b</option></term>
135-
<term><option>--blobs</option></term>
135+
<term><option>--large-objects</option></term>
136+
<term><option>--blobs</option> (deprecated)</term>
136137
<listitem>
137138
<para>
138139
Include large objects in the dump. This is the default behavior
139140
except when <option>--schema</option>, <option>--table</option>, or
140141
<option>--schema-only</option> is specified. The <option>-b</option>
141142
switch is therefore only useful to add large objects to dumps
142143
where a specific schema or table has been requested. Note that
143-
blobs are considered data and therefore will be included when
144+
large objects are considered data and therefore will be included when
144145
<option>--data-only</option> is used, but not
145146
when <option>--schema-only</option> is.
146147
</para>
@@ -149,7 +150,8 @@ PostgreSQL documentation
149150

150151
<varlistentry>
151152
<term><option>-B</option></term>
152-
<term><option>--no-blobs</option></term>
153+
<term><option>--no-large-objects</option></term>
154+
<term><option>--no-blobs</option> (deprecated)</term>
153155
<listitem>
154156
<para>
155157
Exclude large objects in the dump.
@@ -323,7 +325,7 @@ PostgreSQL documentation
323325
<para>
324326
Output a directory-format archive suitable for input into
325327
<application>pg_restore</application>. This will create a directory
326-
with one file for each table and blob being dumped, plus a
328+
with one file for each table and large object being dumped, plus a
327329
so-called Table of Contents file describing the dumped objects in a
328330
machine-readable format that <application>pg_restore</application>
329331
can read. A directory format archive can be manipulated with
@@ -434,9 +436,9 @@ PostgreSQL documentation
434436

435437
<note>
436438
<para>
437-
Non-schema objects such as blobs are not dumped when <option>-n</option> is
438-
specified. You can add blobs back to the dump with the
439-
<option>--blobs</option> switch.
439+
Non-schema objects such as large objects are not dumped when <option>-n</option> is
440+
specified. You can add large objects back to the dump with the
441+
<option>--large-objects</option> switch.
440442
</para>
441443
</note>
442444

src/bin/pg_dump/pg_backup.h

+6-6
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,9 @@ typedef enum _archiveMode
5353

5454
typedef enum _teSection
5555
{
56-
SECTION_NONE = 1, /* COMMENTs, ACLs, etc; can be anywhere */
56+
SECTION_NONE = 1, /* comments, ACLs, etc; can be anywhere */
5757
SECTION_PRE_DATA, /* stuff to be processed before data */
58-
SECTION_DATA, /* TABLE DATA, BLOBS, BLOB COMMENTS */
58+
SECTION_DATA, /* table data, large objects, LO comments */
5959
SECTION_POST_DATA /* stuff to be processed after data */
6060
} teSection;
6161

@@ -193,8 +193,8 @@ typedef struct _dumpOptions
193193

194194
int outputClean;
195195
int outputCreateDB;
196-
bool outputBlobs;
197-
bool dontOutputBlobs;
196+
bool outputLOs;
197+
bool dontOutputLOs;
198198
int outputNoOwner;
199199
char *outputSuperuser;
200200

@@ -289,8 +289,8 @@ extern PGconn *GetConnection(Archive *AHX);
289289
/* Called to write *data* to the archive */
290290
extern void WriteData(Archive *AHX, const void *data, size_t dLen);
291291

292-
extern int StartBlob(Archive *AHX, Oid oid);
293-
extern int EndBlob(Archive *AHX, Oid oid);
292+
extern int StartLO(Archive *AHX, Oid oid);
293+
extern int EndLO(Archive *AHX, Oid oid);
294294

295295
extern void CloseArchive(Archive *AHX);
296296

src/bin/pg_dump/pg_backup_archiver.c

+39-39
Original file line numberDiff line numberDiff line change
@@ -554,7 +554,7 @@ RestoreArchive(Archive *AHX)
554554
*/
555555
if (strncmp(te->desc, "BLOB", 4) == 0)
556556
{
557-
DropBlobIfExists(AH, te->catalogId.oid);
557+
DropLOIfExists(AH, te->catalogId.oid);
558558
}
559559
else
560560
{
@@ -1224,44 +1224,44 @@ PrintTOCSummary(Archive *AHX)
12241224
}
12251225

12261226
/***********
1227-
* BLOB Archival
1227+
* Large Object Archival
12281228
***********/
12291229

1230-
/* Called by a dumper to signal start of a BLOB */
1230+
/* Called by a dumper to signal start of a LO */
12311231
int
1232-
StartBlob(Archive *AHX, Oid oid)
1232+
StartLO(Archive *AHX, Oid oid)
12331233
{
12341234
ArchiveHandle *AH = (ArchiveHandle *) AHX;
12351235

1236-
if (!AH->StartBlobPtr)
1236+
if (!AH->StartLOPtr)
12371237
pg_fatal("large-object output not supported in chosen format");
12381238

1239-
AH->StartBlobPtr(AH, AH->currToc, oid);
1239+
AH->StartLOPtr(AH, AH->currToc, oid);
12401240

12411241
return 1;
12421242
}
12431243

1244-
/* Called by a dumper to signal end of a BLOB */
1244+
/* Called by a dumper to signal end of a LO */
12451245
int
1246-
EndBlob(Archive *AHX, Oid oid)
1246+
EndLO(Archive *AHX, Oid oid)
12471247
{
12481248
ArchiveHandle *AH = (ArchiveHandle *) AHX;
12491249

1250-
if (AH->EndBlobPtr)
1251-
AH->EndBlobPtr(AH, AH->currToc, oid);
1250+
if (AH->EndLOPtr)
1251+
AH->EndLOPtr(AH, AH->currToc, oid);
12521252

12531253
return 1;
12541254
}
12551255

12561256
/**********
1257-
* BLOB Restoration
1257+
* Large Object Restoration
12581258
**********/
12591259

12601260
/*
1261-
* Called by a format handler before any blobs are restored
1261+
* Called by a format handler before any LOs are restored
12621262
*/
12631263
void
1264-
StartRestoreBlobs(ArchiveHandle *AH)
1264+
StartRestoreLOs(ArchiveHandle *AH)
12651265
{
12661266
RestoreOptions *ropt = AH->public.ropt;
12671267

@@ -1273,14 +1273,14 @@ StartRestoreBlobs(ArchiveHandle *AH)
12731273
ahprintf(AH, "BEGIN;\n\n");
12741274
}
12751275

1276-
AH->blobCount = 0;
1276+
AH->loCount = 0;
12771277
}
12781278

12791279
/*
1280-
* Called by a format handler after all blobs are restored
1280+
* Called by a format handler after all LOs are restored
12811281
*/
12821282
void
1283-
EndRestoreBlobs(ArchiveHandle *AH)
1283+
EndRestoreLOs(ArchiveHandle *AH)
12841284
{
12851285
RestoreOptions *ropt = AH->public.ropt;
12861286

@@ -1294,34 +1294,34 @@ EndRestoreBlobs(ArchiveHandle *AH)
12941294

12951295
pg_log_info(ngettext("restored %d large object",
12961296
"restored %d large objects",
1297-
AH->blobCount),
1298-
AH->blobCount);
1297+
AH->loCount),
1298+
AH->loCount);
12991299
}
13001300

13011301

13021302
/*
1303-
* Called by a format handler to initiate restoration of a blob
1303+
* Called by a format handler to initiate restoration of a LO
13041304
*/
13051305
void
1306-
StartRestoreBlob(ArchiveHandle *AH, Oid oid, bool drop)
1306+
StartRestoreLO(ArchiveHandle *AH, Oid oid, bool drop)
13071307
{
1308-
bool old_blob_style = (AH->version < K_VERS_1_12);
1308+
bool old_lo_style = (AH->version < K_VERS_1_12);
13091309
Oid loOid;
13101310

1311-
AH->blobCount++;
1311+
AH->loCount++;
13121312

13131313
/* Initialize the LO Buffer */
13141314
AH->lo_buf_used = 0;
13151315

13161316
pg_log_info("restoring large object with OID %u", oid);
13171317

13181318
/* With an old archive we must do drop and create logic here */
1319-
if (old_blob_style && drop)
1320-
DropBlobIfExists(AH, oid);
1319+
if (old_lo_style && drop)
1320+
DropLOIfExists(AH, oid);
13211321

13221322
if (AH->connection)
13231323
{
1324-
if (old_blob_style)
1324+
if (old_lo_style)
13251325
{
13261326
loOid = lo_create(AH->connection, oid);
13271327
if (loOid == 0 || loOid != oid)
@@ -1335,27 +1335,27 @@ StartRestoreBlob(ArchiveHandle *AH, Oid oid, bool drop)
13351335
}
13361336
else
13371337
{
1338-
if (old_blob_style)
1338+
if (old_lo_style)
13391339
ahprintf(AH, "SELECT pg_catalog.lo_open(pg_catalog.lo_create('%u'), %d);\n",
13401340
oid, INV_WRITE);
13411341
else
13421342
ahprintf(AH, "SELECT pg_catalog.lo_open('%u', %d);\n",
13431343
oid, INV_WRITE);
13441344
}
13451345

1346-
AH->writingBlob = 1;
1346+
AH->writingLO = true;
13471347
}
13481348

13491349
void
1350-
EndRestoreBlob(ArchiveHandle *AH, Oid oid)
1350+
EndRestoreLO(ArchiveHandle *AH, Oid oid)
13511351
{
13521352
if (AH->lo_buf_used > 0)
13531353
{
13541354
/* Write remaining bytes from the LO buffer */
13551355
dump_lo_buf(AH);
13561356
}
13571357

1358-
AH->writingBlob = 0;
1358+
AH->writingLO = false;
13591359

13601360
if (AH->connection)
13611361
{
@@ -1645,7 +1645,7 @@ RestoringToDB(ArchiveHandle *AH)
16451645
}
16461646

16471647
/*
1648-
* Dump the current contents of the LO data buffer while writing a BLOB
1648+
* Dump the current contents of the LO data buffer while writing a LO
16491649
*/
16501650
static void
16511651
dump_lo_buf(ArchiveHandle *AH)
@@ -1673,10 +1673,10 @@ dump_lo_buf(ArchiveHandle *AH)
16731673
AH->lo_buf_used,
16741674
AH);
16751675

1676-
/* Hack: turn off writingBlob so ahwrite doesn't recurse to here */
1677-
AH->writingBlob = 0;
1676+
/* Hack: turn off writingLO so ahwrite doesn't recurse to here */
1677+
AH->writingLO = false;
16781678
ahprintf(AH, "SELECT pg_catalog.lowrite(0, %s);\n", buf->data);
1679-
AH->writingBlob = 1;
1679+
AH->writingLO = true;
16801680

16811681
destroyPQExpBuffer(buf);
16821682
}
@@ -1695,7 +1695,7 @@ ahwrite(const void *ptr, size_t size, size_t nmemb, ArchiveHandle *AH)
16951695
{
16961696
int bytes_written = 0;
16971697

1698-
if (AH->writingBlob)
1698+
if (AH->writingLO)
16991699
{
17001700
size_t remaining = size * nmemb;
17011701

@@ -2324,7 +2324,7 @@ _allocAH(const char *FileSpec, const ArchiveFormat fmt,
23242324
}
23252325

23262326
/*
2327-
* Write out all data (tables & blobs)
2327+
* Write out all data (tables & LOs)
23282328
*/
23292329
void
23302330
WriteDataChunks(ArchiveHandle *AH, ParallelState *pstate)
@@ -2418,8 +2418,8 @@ WriteDataChunksForTocEntry(ArchiveHandle *AH, TocEntry *te)
24182418

24192419
if (strcmp(te->desc, "BLOBS") == 0)
24202420
{
2421-
startPtr = AH->StartBlobsPtr;
2422-
endPtr = AH->EndBlobsPtr;
2421+
startPtr = AH->StartLOsPtr;
2422+
endPtr = AH->EndLOsPtr;
24232423
}
24242424
else
24252425
{
@@ -2965,7 +2965,7 @@ _tocEntryRequired(TocEntry *te, teSection curSection, ArchiveHandle *AH)
29652965
if (!te->hadDumper)
29662966
{
29672967
/*
2968-
* Special Case: If 'SEQUENCE SET' or anything to do with BLOBs, then
2968+
* Special Case: If 'SEQUENCE SET' or anything to do with LOs, then
29692969
* it is considered a data entry. We don't need to check for the
29702970
* BLOBS entry or old-style BLOB COMMENTS, because they will have
29712971
* hadDumper = true ... but we do need to check new-style BLOB ACLs,
@@ -3451,7 +3451,7 @@ _getObjectDescription(PQExpBuffer buf, const TocEntry *te)
34513451
appendPQExpBuffer(buf, "%s.", fmtId(te->namespace));
34523452
appendPQExpBufferStr(buf, fmtId(te->tag));
34533453
}
3454-
/* BLOBs just have a name, but it's numeric so must not use fmtId */
3454+
/* LOs just have a name, but it's numeric so must not use fmtId */
34553455
else if (strcmp(type, "BLOB") == 0)
34563456
{
34573457
appendPQExpBuffer(buf, "LARGE OBJECT %s", te->tag);

src/bin/pg_dump/pg_backup_archiver.h

+17-17
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ typedef z_stream *z_streamp;
7070
/* Historical version numbers (checked in code) */
7171
#define K_VERS_1_0 MAKE_ARCHIVE_VERSION(1, 0, 0)
7272
#define K_VERS_1_2 MAKE_ARCHIVE_VERSION(1, 2, 0) /* Allow No ZLIB */
73-
#define K_VERS_1_3 MAKE_ARCHIVE_VERSION(1, 3, 0) /* BLOBs */
73+
#define K_VERS_1_3 MAKE_ARCHIVE_VERSION(1, 3, 0) /* BLOBS */
7474
#define K_VERS_1_4 MAKE_ARCHIVE_VERSION(1, 4, 0) /* Date & name in header */
7575
#define K_VERS_1_5 MAKE_ARCHIVE_VERSION(1, 5, 0) /* Handle dependencies */
7676
#define K_VERS_1_6 MAKE_ARCHIVE_VERSION(1, 6, 0) /* Schema field in TOCs */
@@ -145,10 +145,10 @@ typedef void (*StartDataPtrType) (ArchiveHandle *AH, TocEntry *te);
145145
typedef void (*WriteDataPtrType) (ArchiveHandle *AH, const void *data, size_t dLen);
146146
typedef void (*EndDataPtrType) (ArchiveHandle *AH, TocEntry *te);
147147

148-
typedef void (*StartBlobsPtrType) (ArchiveHandle *AH, TocEntry *te);
149-
typedef void (*StartBlobPtrType) (ArchiveHandle *AH, TocEntry *te, Oid oid);
150-
typedef void (*EndBlobPtrType) (ArchiveHandle *AH, TocEntry *te, Oid oid);
151-
typedef void (*EndBlobsPtrType) (ArchiveHandle *AH, TocEntry *te);
148+
typedef void (*StartLOsPtrType) (ArchiveHandle *AH, TocEntry *te);
149+
typedef void (*StartLOPtrType) (ArchiveHandle *AH, TocEntry *te, Oid oid);
150+
typedef void (*EndLOPtrType) (ArchiveHandle *AH, TocEntry *te, Oid oid);
151+
typedef void (*EndLOsPtrType) (ArchiveHandle *AH, TocEntry *te);
152152

153153
typedef int (*WriteBytePtrType) (ArchiveHandle *AH, const int i);
154154
typedef int (*ReadBytePtrType) (ArchiveHandle *AH);
@@ -285,10 +285,10 @@ struct _archiveHandle
285285
PrintExtraTocPtrType PrintExtraTocPtr; /* Extra TOC info for format */
286286
PrintTocDataPtrType PrintTocDataPtr;
287287

288-
StartBlobsPtrType StartBlobsPtr;
289-
EndBlobsPtrType EndBlobsPtr;
290-
StartBlobPtrType StartBlobPtr;
291-
EndBlobPtrType EndBlobPtr;
288+
StartLOsPtrType StartLOsPtr;
289+
EndLOsPtrType EndLOsPtr;
290+
StartLOPtrType StartLOPtr;
291+
EndLOPtrType EndLOPtr;
292292

293293
SetupWorkerPtrType SetupWorkerPtr;
294294
WorkerJobDumpPtrType WorkerJobDumpPtr;
@@ -313,9 +313,9 @@ struct _archiveHandle
313313
ArchiverOutput outputKind; /* Flag for what we're currently writing */
314314
bool pgCopyIn; /* Currently in libpq 'COPY IN' mode. */
315315

316-
int loFd; /* BLOB fd */
317-
int writingBlob; /* Flag */
318-
int blobCount; /* # of blobs restored */
316+
int loFd;
317+
bool writingLO;
318+
int loCount; /* # of LOs restored */
319319

320320
char *fSpec; /* Archive File Spec */
321321
FILE *FH; /* General purpose file handle */
@@ -456,10 +456,10 @@ extern size_t WriteStr(ArchiveHandle *AH, const char *c);
456456
int ReadOffset(ArchiveHandle *, pgoff_t *);
457457
size_t WriteOffset(ArchiveHandle *, pgoff_t, int);
458458

459-
extern void StartRestoreBlobs(ArchiveHandle *AH);
460-
extern void StartRestoreBlob(ArchiveHandle *AH, Oid oid, bool drop);
461-
extern void EndRestoreBlob(ArchiveHandle *AH, Oid oid);
462-
extern void EndRestoreBlobs(ArchiveHandle *AH);
459+
extern void StartRestoreLOs(ArchiveHandle *AH);
460+
extern void StartRestoreLO(ArchiveHandle *AH, Oid oid, bool drop);
461+
extern void EndRestoreLO(ArchiveHandle *AH, Oid oid);
462+
extern void EndRestoreLOs(ArchiveHandle *AH);
463463

464464
extern void InitArchiveFmt_Custom(ArchiveHandle *AH);
465465
extern void InitArchiveFmt_Null(ArchiveHandle *AH);
@@ -469,7 +469,7 @@ extern void InitArchiveFmt_Tar(ArchiveHandle *AH);
469469
extern bool isValidTarHeader(char *header);
470470

471471
extern void ReconnectToServer(ArchiveHandle *AH, const char *dbname);
472-
extern void DropBlobIfExists(ArchiveHandle *AH, Oid oid);
472+
extern void DropLOIfExists(ArchiveHandle *AH, Oid oid);
473473

474474
void ahwrite(const void *ptr, size_t size, size_t nmemb, ArchiveHandle *AH);
475475
int ahprintf(ArchiveHandle *AH, const char *fmt,...) pg_attribute_printf(2, 3);

0 commit comments

Comments
 (0)