| From: | Nathan Bossart <nathandbossart(at)gmail(dot)com> | 
|---|---|
| To: | Pierre Ducroquet <p(dot)psql(at)pinaraf(dot)info> | 
| Cc: | pgsql-hackers(at)lists(dot)postgresql(dot)org | 
| Subject: | Re: Improvements in pg_dump/pg_restore toc format and performances | 
| Date: | 2023-09-20 20:29:22 | 
| Message-ID: | 20230920202922.GA3054233@nathanxps13 | 
| Views: | Whole Thread | Raw Message | Download mbox | Resend email | 
| Thread: | |
| Lists: | pgsql-hackers | 
On Tue, Sep 19, 2023 at 12:15:55PM +0200, Pierre Ducroquet wrote:
> Attached updated patches fix this regression, I'm sorry I missed that.
Thanks for the new patches.  0001 and 0002 look reasonable to me.  This is
a nitpick, but we might want to use atooid() in 0002, which is just
shorthand for the strtoul() call you are using.
> -		WriteStr(AH, NULL);		/* Terminate List */
> +		WriteInt(AH, -1);		/* Terminate List */
I think we need to be cautious about using WriteInt and ReadInt here.  OIDs
are unsigned, so we probably want to use InvalidOid (0) instead.
> +				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);
>  				}
I would suggest making the resizing logic common.
	if (AH->version >= K_VERS_1_16)
	{
		depId = ReadInt(AH);
		if (depId == InvalidOid)
			break;		/* end of list */
	}
	else
	{
		tmp = ReadStr(AH);
		if (!tmp)
			break;		/* end of list */
		depId = strtoul(tmp, NULL, 10);
		free(tmp);
	}
	if (depIdx >= depSize)
	{
		depSize *= 2;
		deps = (DumpId *) pg_realloc(deps, sizeof(DumpId) * depSize);
	}
	deps[depIdx] = depId;
Also, can we make depId more locally scoped?
I have yet to look into 0004 still.
-- 
Nathan Bossart
Amazon Web Services: https://aws.amazon.com
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Thomas Munro | 2023-09-20 22:54:09 | Guiding principle for dropping LLVM versions? | 
| Previous Message | Thomas Munro | 2023-09-20 20:22:20 | Re: LLVM 16 (opaque pointers) |