Skip to content

Fix found flaws of package constants #9022

Open
Noremos wants to merge 6 commits into
FirebirdSQL:masterfrom
Noremos:package_constants_fixes
Open

Fix found flaws of package constants #9022
Noremos wants to merge 6 commits into
FirebirdSQL:masterfrom
Noremos:package_constants_fixes

Conversation

@Noremos
Copy link
Copy Markdown
Contributor

@Noremos Noremos commented May 12, 2026

Fix incorrect search in SCHEMAs list
Fix missing RDB$CONSTANT_SOURCE setup
Add USAGE privilage to SYSTEM packages

@Noremos Noremos mentioned this pull request May 12, 2026
Comment thread src/jrd/ini.epp Outdated
PRIV.RDB$PRIVILEGE[1] = 0;
PRIV.RDB$PRIVILEGE[0] = privileges[0];
PRIV.RDB$PRIVILEGE[1] = privileges[1];
PRIV.RDB$PRIVILEGE[2] = 0;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why not loop here?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I followed the original style. Is loop worth it?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Or do you mean storing each privilege in a separate record?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

No, I mean that the check and the way one string is assigned to another is strange, but if it was an original code... Probably, it still must be replaced with strncpy.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Hm, as I can see, storing each privilege in a separate record is indead a correct way to do it

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

In this case CHAR(6) field makes no sense.

@Noremos
Copy link
Copy Markdown
Contributor Author

Noremos commented May 12, 2026

I found an issue related to metadata. When selecting a constant from a procedure, an error may occur:
Statement format outdated, need to be reprepared. I hope I can fix this soon.

Code to reproduce:

set term ^;

   CREATE PACKAGE TEST1
   AS
   BEGIN
       PROCEDURE P1(I INT) RETURNS (PROCEDURE_OUTPUT INT); -- public procedure
       CONSTANT TEST1_PACKAGE_CONSTANT INTEGER = 10;
   END^

   CREATE PACKAGE BODY TEST1
   AS
   BEGIN
       CONSTANT CP2 INTEGER = 15;
       CONSTANT CP3 INTEGER = 30;
       PROCEDURE P1(I INT) RETURNS (PROCEDURE_OUTPUT INT)
       AS
       BEGIN
           PROCEDURE_OUTPUT = TEST1.TEST1_PACKAGE_CONSTANT + TEST1.CP2;
           SUSPEND;
       END
   END ^

   set term ;^
   commit;

   -- Test Public
   select test1.TEST1_PACKAGE_CONSTANT from rdb$database ;
   select * from test1.p1(0);
   commit;

Comment thread src/dsql/PackageNodes.epp Outdated
CONST.RDB$PRIVATE_FLAG = m_isPrivate;

CONST.RDB$CONSTANT_SOURCE.NULL = TRUE;
attachment->storeBinaryBlob(tdbb, transaction, &CONST.RDB$CONSTANT_SOURCE, source);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

storeMetaDataBlob() maybe ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the advice. Changed as suggested

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.

4 participants