Skip to content

Adds Retail Tablespace DDL function#1

Open
edbmanniwood wants to merge 17 commits intomasterfrom
dev/PG-153-retail-tablespace-ddl
Open

Adds Retail Tablespace DDL function#1
edbmanniwood wants to merge 17 commits intomasterfrom
dev/PG-153-retail-tablespace-ddl

Conversation

@edbmanniwood
Copy link
Owner

@edbmanniwood edbmanniwood commented Sep 25, 2025

This uses Nishant Sharma's code, which does a nicer job of only showing the tablespace options when the user explicitly set them. (My earlier code used the get_tablespace_page_costs() and related functions, which failed to make that distinction.)

Tests have now been added. We take advantage of the special allow_in_place_tablespaces developer GUC.

@edbmanniwood edbmanniwood self-assigned this Sep 25, 2025
* "allow_in_place_tablespaces = true" and "LOCATION ''",
* path will begin with "pg_tblspc/". In that case, show
* "LOCATION ''" as the user originally specified. */
if (strncmp("pg_tblspc/", path, 10) == 0)
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this the correct way to check for a prefix (a.k.a. startsWith) in C?

/* Look up the tablespace in pg_tablespace */
tuple = SearchSysCache1(TABLESPACEOID, ObjectIdGetDatum(tspaceoid));

Assert(HeapTupleIsValid(tuple));

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of using Assert, check HeapTupleIsValid(tuple), and if it’s invalid, return with ereport

Comment on lines +13798 to +13835
if (opts->random_page_cost > 0)
{
appendStringInfo(&buf, "random_page_cost = %g",
opts->random_page_cost);
needcomma = true;
}

if (opts->seq_page_cost > 0)
{
if (needcomma)
appendStringInfo(&buf, ", seq_page_cost = %g",
opts->seq_page_cost);
else
appendStringInfo(&buf, "seq_page_cost = %g",
opts->seq_page_cost);
needcomma = true;
}

if (opts->effective_io_concurrency > 0)
{
if (needcomma)
appendStringInfo(&buf, ", effective_io_concurrency = %d",
opts->effective_io_concurrency);
else
appendStringInfo(&buf, "effective_io_concurrency = %d",
opts->effective_io_concurrency);
needcomma = true;
}

if (opts->maintenance_io_concurrency > 0)
{
if (needcomma)
appendStringInfo(&buf, ", maintenance_io_concurrency = %d",
opts->maintenance_io_concurrency);
else
appendStringInfo(&buf, "maintenance_io_concurrency = %d",
opts->maintenance_io_concurrency);
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not a C expert; others can comment, but,

Can this logic be changed to below:

	if (opts->random_page_cost > 0)
		appendStringInfo(&buf, "random_page_cost = %g, ",
						 opts->random_page_cost);

	if (opts->seq_page_cost > 0)
		appendStringInfo(&buf, "seq_page_cost = %g, ",
							 opts->seq_page_cost);


	if (opts->effective_io_concurrency > 0)
		appendStringInfo(&buf, "effective_io_concurrency = %d, ",
							 opts->effective_io_concurrency);


	if (opts->maintenance_io_concurrency > 0)
		appendStringInfo(&buf, "maintenance_io_concurrency = %d",
							 opts->maintenance_io_concurrency);

	/* Removing trailing comma and space */
	if (buf.data[buf.len - 2] == ',' && buf.data[buf.len - 1] == ' ')
	{
    	buf.len -= 2;
    	buf.data[buf.len] = '\0';  // Null-terminate the modified string
	}

edbmanniwood pushed a commit that referenced this pull request Oct 28, 2025
truncate_useless_pathkeys() seems to have neglected to account for
PathKeys that might be useful for WindowClause evaluation.  Modify it so
that it properly accounts for that.

Making this work required adjusting two things:

1. Change from checking query_pathkeys to check sort_pathkeys instead.
2. Add explicit check for window_pathkeys

For #1, query_pathkeys gets set in standard_qp_callback() according to the
sort order requirements for the first operation to be applied after the
join planner is finished, so this changes depending on which upper
planner operations a particular query needs.  If the query has window
functions and no GROUP BY, then query_pathkeys gets set to
window_pathkeys.  Before this change, this meant PathKeys useful for the
ORDER BY were not accounted for in queries with window functions.

Because of #1, #2 is now required so that we explicitly check to ensure
we don't truncate away PathKeys useful for window functions.

Author: David Rowley <dgrowleyml@gmail.com>
Discussion: https://postgr.es/m/CAApHDvrj3HTKmXoLMbUjTO=_MNMxM=cnuCSyBKidAVibmYPnrg@mail.gmail.com
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants