New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature issue#49 #76
Feature issue#49 #76
Conversation
@@ -2007,6 +2008,107 @@ PgShardProcessUtility(Node *parsetree, const char *queryString, | |||
} | |||
} | |||
} | |||
else if (statementType == T_DropStmt) | |||
{ | |||
DropStmt *dropStatement = (DropStmt *) parsetree; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The nesting gets pretty deep here. Can you move the drop logic into its own function?
Left some comments, mostly minor for now. Still want to think overnight about this approach, as it's quite a bit of code for something that's conceptually pretty simple. Will add more comments tomorrow morning. |
@jasonmp85 Well, in the beginning of our discussions, we thought that we should write C codes for this purpose. If we are going to implement it with C (either event trigger or utility hook), we need to write these codes (at least I couldn't find any other way). So, we may consider writing a SQL event trigger. Or, I am not sure, but if we use referential integrity constraints during metadata table creation, would the code become smaller? For instance, deleting a row from partition column propagates to shard and shard_placements. I haven't addressed your feedback, I think it is better to decide high level design first. |
@jasonmp85 we have chatted with @sumedhpathak and thought that we could divide the issue into two. One is for DROP EXTENSION and the other is DROP TABLE. In this way, we can merge DROP EXTENSION for v1.1, which is simpler and requires small code changes. |
OK, the more I think about it, the more I think @sumedhpathak and you are on to something with the "let's split this in two" idea…
@onderkalaci Can you rework this to just handle dropping the extension and we'll open an issue for later about dropping tables? |
OK, I left all my feedback. Can you remove the |
static void | ||
PgShardProcessUtilityDropCommands(Node *parsetree) | ||
{ | ||
DropStmt *dropStatement = (DropStmt *) parsetree; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the idiom within PostgreSQL is to cast this before calling the function so the function signature can be more specific.
This commit aims to test feasibility of using utility hook for controlling DROP EXTENSION statement.
This commits applies some style refactoring.
This commits add a dependency control for distributed tables. If a table is dropped with CASCADE, delete all the dependent metadata information. Else, do not allow to drop the table.
This commit aims to add some tests for pg_shard dependency for both distributed tables and the extension itself.
This commit applies some style changes.
This commit aims to remove process utility hook codes that controls the dependency on distributed tables. Also, this commit addresses some of the minor style changes.
This commit updates some of the comments in the code.
This commit updated some of the comments.
Final code review feedback.
195e85f
to
9c74f7a
Compare
@onderkalaci I hope this isn't too presumptuous of me, but I'm making some changes here before merging:
The only change in functionality I made is this: the original implementation would have printed a Reducing Indentation Levels If we have a construct like this: void
SomeFunction(Params *param)
{
Variable variable = param->field;
/* ... */
if (variable == VALUE)
{
Variable other = variable * 2;
/* ... */
}
/* no more code in this function after if statement */
} We can remove a level of nesting by doing this instead: void
SomeFunction(Params *param)
{
Variable variable = param->field;
Variable other = -1;
/* ... */
if (variable != VALUE)
{
return;
}
other = variable * 2;
/* code that used to be inside if block */
} I'd say use this judiciously, because it can become a tax on the reader, but if you find yourself with five levels of nesting and you're inside some |
Oh yeah, and I changed the A final note: You had |
Forbids dropping extension if dist. tables exist. cr: @jasonmp85
This pull request includes commits which add dependency control for pg_shard extension and distributed tables.
Fixes #49
Code Review Tasks
develop
(i.e.git fetch; git rebase -i origin/develop
) or merge develop into this branchDROP TABLE
logic and all functions/tests used by that logicDROP EXTENSION pg_shard
against a database wherepg_shard
isn't yet created (i.e. does your block run, or is it skipped?)if (booleanVar == true)
, just doif (booleanVar)
strncmp
, neverstrcmp
)DistributedTablesExist
so it's not called in a loop