Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Feature #1113 - SQL Schemas #8445

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

Open
wants to merge 24 commits into
base: master
Choose a base branch
from
Open

Feature #1113 - SQL Schemas #8445

wants to merge 24 commits into from

Conversation

asfernandes
Copy link
Member

No description provided.

@asfernandes asfernandes linked an issue Feb 21, 2025 that may be closed by this pull request
@dyemanov dyemanov self-requested a review February 25, 2025 11:58
@asfernandes
Copy link
Member Author

Can someone please review this?
It will certainly require more work, and also there is compatibility work necessary to be done at least in v5 branch.

Copy link
Member

@hvlad hvlad left a comment

Choose a reason for hiding this comment

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

It just for docs, I'll try to add more reviews of the code later


```sql
ALTER SCHEMA <schema name>
<alter schema option>...
Copy link
Member

Choose a reason for hiding this comment

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

It is not clear if more than one option is allowed.

Copy link
Member Author

Choose a reason for hiding this comment

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

I think ... makes it clear that it is.

Copy link
Member

Choose a reason for hiding this comment

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

Maybe <alter schema option> [<alter schema option> ...] would make it more explicit

Copy link
Member Author

Choose a reason for hiding this comment

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

Maybe <alter schema option> [<alter schema option> ...] would make it more explicit

I don't see it this way, it just make things complicate to read. Anyone who (mis)understand the first version will do the same for this version.

We have others docs with the same convention (see README.case).

Copy link
Contributor

Choose a reason for hiding this comment

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

Usually it is written like this:

ALTER SCHEMA <alter schema options>
<alter schema options> ::= <alter schema option> [<alter schema options>]
<alter schema option> ::= <option 1 | option 2 | etc>

The monitoring tables now include schema-related information:

`MON$ATTACHMENTS`
- `MON$SEARCH_PATH`: search path of the attachment
Copy link
Member

Choose a reason for hiding this comment

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

SEARCH_PATH looks too generic, may be SCHEMA_SEARCH_PATH should be used ?
Or SCHEMA_PATH for short ?

Of course, if changed, it should be the same everywhere: context variable, DPB tag names, utilities command-line switches, etc

Copy link
Member Author

Choose a reason for hiding this comment

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

The SQL standard has SET SEARCH_PATH command.
In docs, I tried to always call it schema search path.
In this case, I used same wording as the command.

@AlexPeshkoff
Copy link
Member

AlexPeshkoff commented Apr 3, 2025 via email

Copy link
Member

@dyemanov dyemanov left a comment

Choose a reason for hiding this comment

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

The first part of the review, more to follow the next week.

For `CREATE`, `CREATE OR ALTER`, and `RECREATE` statements, the system searches only the **current schema** (the first
valid schema in the search path) for an existing object, and the new object is created in this same schema.
This rule also applies to `GRANT` and `REVOKE` statements for DDL operations without the `ON SCHEMA` subclause. If no
**current schema** is available (i.e., no valid schema exists in the search path), an error is raised.
Copy link
Member

Choose a reason for hiding this comment

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

What if SYSTEM is the first schema in the search path? AFAIU, it should be read-only for users. Will an error be raised or will be this schema ignored while resolving the name in DDL statements?

Copy link
Member Author

Choose a reason for hiding this comment

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

An error is raised.

This ensures backward compatibility with previous Firebird versions.

While the `SYSTEM` schema allows operations like index creation and manipulation of those indexes, it is otherwise
locked for DDL changes. Modifying objects within the `SYSTEM` schema through DDL operations is strongly discouraged.
Copy link
Member

Choose a reason for hiding this comment

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

It's related to my question above. I may understand a need to create/drop indices on system tables and it implies they're created in the system schema. But what other DDL are allowed (although discouraged) for the system schema?

Copy link
Member Author

Choose a reason for hiding this comment

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

It's discouraged to even create indexes in system tables, I'd say.
I don't think there are others accepted DDL changes.
Is Modifying problematic here?


```sql
ALTER SCHEMA <schema name>
<alter schema option>...
Copy link
Member

Choose a reason for hiding this comment

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

Maybe <alter schema option> [<alter schema option> ...] would make it more explicit


Firebird::string nameToString(const MetaName& name)
{
return name.toQuotedString();
Copy link
Member

Choose a reason for hiding this comment

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

Are these methods really needed, provided that they're one-liners that could be used directly instead?

Copy link
Member Author

Choose a reason for hiding this comment

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

No. It was necessary in a previous version where the toQuotedString methods had different names in the two classes.

@@ -1 +1 @@
117 shift/reduce conflicts, 22 reduce/reduce conflicts.
130 shift/reduce conflicts, 13 reduce/reduce conflicts.
Copy link
Member

Choose a reason for hiding this comment

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

Quite a lot of new shift/reduce conflicts, did you analyse whether the new syntax ambiguities safe?

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.

Add support for SQL Schemas [CORE738]
5 participants