pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Pierre Ducroquet <p.psql@pinaraf.info>
Subject: [PATCH 3/4] store oids as integer instead of string
Date: Thu, 27 Jul 2023 10:04:51 +0200

---
 src/bin/pg_dump/pg_backup_archiver.c | 63 ++++++++++++++++++----------
 1 file changed, 42 insertions(+), 21 deletions(-)

inline patch 1: src/bin/pg_dump/pg_backup_archiver.c (+42/-21 lines) download inline-1.patchdiff --git a/src/bin/pg_dump/pg_backup_archiver.c b/src/bin/pg_dump/pg_backup_archiver.c index f9efb2badf..feacc22701 100644 --- a/src/bin/pg_dump/pg_backup_archiver.c +++ b/src/bin/pg_dump/pg_backup_archiver.c @@ -2470,7 +2470,6 @@ void WriteToc(ArchiveHandle *AH) { TocEntry *te; - char workbuf[32]; int tocCount; int i; @@ -2494,11 +2493,8 @@ WriteToc(ArchiveHandle *AH) WriteInt(AH, te->dumpId); WriteInt(AH, te->dataDumper ? 1 : 0); - /* OID is recorded as a string for historical reasons */ - sprintf(workbuf, "%u", te->catalogId.tableoid); - WriteStr(AH, workbuf); - sprintf(workbuf, "%u", te->catalogId.oid); - WriteStr(AH, workbuf); + WriteInt(AH, te->catalogId.tableoid); + WriteInt(AH, te->catalogId.oid); WriteStr(AH, te->tag); WriteStr(AH, te->desc); @@ -2514,10 +2510,9 @@ WriteToc(ArchiveHandle *AH) /* Dump list of dependencies */ for (i = 0; i < te->nDeps; i++) { - sprintf(workbuf, "%d", te->dependencies[i]); - WriteStr(AH, workbuf); + WriteInt(AH, te->dependencies[i]); } - WriteStr(AH, NULL); /* Terminate List */ + WriteInt(AH, -1); /* Terminate List */ if (AH->WriteExtraTocPtr) AH->WriteExtraTocPtr(AH, te); @@ -2529,6 +2524,7 @@ ReadToc(ArchiveHandle *AH) { int i; char *tmp; + int depId; DumpId *deps; int depIdx; int depSize; @@ -2553,7 +2549,11 @@ ReadToc(ArchiveHandle *AH) te->hadDumper = ReadInt(AH); - if (AH->version >= K_VERS_1_8) + if (AH->version >= K_VERS_1_16) + { + te->catalogId.tableoid = ReadInt(AH); + } + else if (AH->version >= K_VERS_1_8) { tmp = ReadStr(AH); te->catalogId.tableoid = strtoul(tmp, NULL, 10); @@ -2561,9 +2561,15 @@ ReadToc(ArchiveHandle *AH) } else te->catalogId.tableoid = InvalidOid; - tmp = ReadStr(AH); - te->catalogId.oid = strtoul(tmp, NULL, 10); - free(tmp); + + if (AH->version >= K_VERS_1_16) + te->catalogId.oid = ReadInt(AH); + else + { + tmp = ReadStr(AH); + te->catalogId.oid = strtoul(tmp, NULL, 10); + free(tmp); + } te->tag = ReadStr(AH); te->desc = ReadStr(AH); @@ -2638,16 +2644,31 @@ ReadToc(ArchiveHandle *AH) depIdx = 0; for (;;) { - tmp = ReadStr(AH); - if (!tmp) - break; /* end of list */ - if (depIdx >= depSize) + if (AH->version >= K_VERS_1_16) { - depSize *= 2; - deps = (DumpId *) pg_realloc(deps, sizeof(DumpId) * depSize); + depId = ReadInt(AH); + if (depId == -1) + break; /* end of list */ + if (depIdx >= depSize) + { + depSize *= 2; + deps = (DumpId *) pg_realloc(deps, sizeof(DumpId) * depSize); + } + deps[depIdx] = depId; + } + else + { + tmp = ReadStr(AH); + if (!tmp) + break; /* end of list */ + if (depIdx >= depSize) + { + depSize *= 2; + deps = (DumpId *) pg_realloc(deps, sizeof(DumpId) * depSize); + } + deps[depIdx] = strtoul(tmp, NULL, 10); + free(tmp); } - deps[depIdx] = strtoul(tmp, NULL, 10); - free(tmp); depIdx++; } -- 2.42.0
--nextPart4294444.ejJDZkT8p0 Content-Disposition: attachment; filename="0004-move-static-strings-to-arrays-at-beginning.patch" Content-Transfer-Encoding: 7Bit Content-Type: text/x-patch; charset="x-UTF_8J"; name="0004-move-static-strings-to-arrays-at-beginning.patch"

Message-ID: <no-message-id-629865@localhost>
Permalink:  ../no-message-id-629865@localhost/
Also on:    postgresql.org/message-id/no-message-id-629865@localhost

 ·  · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-hackers@postgresql.org
  Cc: p.psql@pinaraf.info
  Subject: Re: [PATCH 3/4] store oids as integer instead of string
  In-Reply-To: <no-message-id-629865@localhost>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox