Skip to content

Commit 53245cc

Browse files
committed
Feature #1113 - Add support for SQL Schemas. (WIP)
1 parent b3e416d commit 53245cc

File tree

179 files changed

+12228
-6365
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

179 files changed

+12228
-6365
lines changed

builds/win32/msvc15/common.vcxproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@
144144
<ClInclude Include="..\..\..\src\common\classes\NoThrowTimeStamp.h" />
145145
<ClInclude Include="..\..\..\src\common\classes\objects_array.h" />
146146
<ClInclude Include="..\..\..\src\common\classes\ParsedList.h" />
147-
<ClInclude Include="..\..\..\src\common\classes\QualifiedName.h" />
147+
<ClInclude Include="..\..\..\src\common\classes\QualifiedMetaString.h" />
148148
<ClInclude Include="..\..\..\src\common\classes\RefCounted.h" />
149149
<ClInclude Include="..\..\..\src\common\classes\RefMutex.h" />
150150
<ClInclude Include="..\..\..\src\common\classes\rwlock.h" />

builds/win32/msvc15/common.vcxproj.filters

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -449,7 +449,7 @@
449449
<ClInclude Include="..\..\..\src\common\classes\objects_array.h">
450450
<Filter>headers</Filter>
451451
</ClInclude>
452-
<ClInclude Include="..\..\..\src\common\classes\QualifiedName.h">
452+
<ClInclude Include="..\..\..\src\common\classes\MetaString.h">
453453
<Filter>headers</Filter>
454454
</ClInclude>
455455
<ClInclude Include="..\..\..\src\common\classes\RefCounted.h">

builds/win32/msvc15/common_test.vcxproj

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,10 @@
179179
<ClCompile Include="..\..\..\src\common\tests\CommonTest.cpp" />
180180
<ClCompile Include="..\..\..\src\common\classes\tests\AlignerTest.cpp" />
181181
<ClCompile Include="..\..\..\src\common\classes\tests\ArrayTest.cpp" />
182+
<ClCompile Include="..\..\..\src\common\classes\tests\ClumpletTest.cpp" />
182183
<ClCompile Include="..\..\..\src\common\classes\tests\DoublyLinkedListTest.cpp" />
184+
<ClCompile Include="..\..\..\src\common\classes\tests\QualifiedMetaStringTest.cpp" />
185+
<ClCompile Include="..\..\..\src\common\classes\tests\VectorTest.cpp" />
183186
<ClCompile Include="..\..\..\src\yvalve\gds.cpp" />
184187
</ItemGroup>
185188
<ItemGroup>
@@ -195,4 +198,4 @@
195198
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
196199
<ImportGroup Label="ExtensionTargets">
197200
</ImportGroup>
198-
</Project>
201+
</Project>

builds/win32/msvc15/common_test.vcxproj.filters

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,20 @@
2424
<ClCompile Include="..\..\..\src\common\classes\tests\ArrayTest.cpp">
2525
<Filter>source</Filter>
2626
</ClCompile>
27+
<ClCompile Include="..\..\..\src\common\classes\tests\ClumpletTest.cpp">
28+
<Filter>source</Filter>
29+
</ClCompile>
2730
<ClCompile Include="..\..\..\src\common\classes\tests\DoublyLinkedListTest.cpp">
2831
<Filter>source</Filter>
2932
</ClCompile>
33+
<ClCompile Include="..\..\..\src\common\classes\tests\QualifiedMetaStringTest.cpp">
34+
<Filter>source</Filter>
35+
</ClCompile>
36+
<ClCompile Include="..\..\..\src\common\classes\tests\VectorTest.cpp">
37+
<Filter>source</Filter>
38+
</ClCompile>
3039
<ClCompile Include="..\..\..\src\yvalve\gds.cpp">
3140
<Filter>source</Filter>
3241
</ClCompile>
3342
</ItemGroup>
34-
</Project>
43+
</Project>

doc/sql.extensions/README.ddl_triggers.txt

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ DDL_TRIGGER context namespace:
119119
- EVENT_TYPE: event type (CREATE, ALTER, DROP)
120120
- OBJECT_TYPE: object type (TABLE, VIEW, etc)
121121
- DDL_EVENT: event name (<ddl event item>), where <ddl_event_item> is EVENT_TYPE || ' ' || OBJECT_TYPE
122+
- SCHEMA_NAME: object's schema name
122123
- OBJECT_NAME: metadata object name
123124
- OLD_OBJECT_NAME: metadata object name before a rename
124125
- NEW_OBJECT_NAME: metadata object name after a rename
@@ -294,51 +295,51 @@ commit;
294295

295296
select id, ddl_event, object_name, old_object_name, new_object_name, sql_text, ok from ddl_log order by id;
296297

297-
ID DDL_EVENT OBJECT_NAME OLD_OBJECT_NAME NEW_OBJECT_NAME SQL_TEXT OK
298-
===================== ========================= =============================== =============================== =============================== ================= ======
299-
2 CREATE TABLE T1 <null> <null> 80:0 Y
298+
ID DDL_EVENT OBJECT_NAME OLD_OBJECT_NAME NEW_OBJECT_NAME SQL_TEXT OK
299+
===================== ========================= =============================== =============================== =============================== ================= ======
300+
2 CREATE TABLE T1 <null> <null> 80:0 Y
300301
==============================================================================
301-
SQL_TEXT:
302+
SQL_TEXT:
302303
recreate table t1 (
303304
n1 integer,
304305
n2 integer
305306
)
306307
==============================================================================
307-
3 CREATE TABLE T1 <null> <null> 80:1 N
308+
3 CREATE TABLE T1 <null> <null> 80:1 N
308309
==============================================================================
309-
SQL_TEXT:
310+
SQL_TEXT:
310311
create table t1 (
311312
n1 integer,
312313
n2 integer
313314
)
314315
==============================================================================
315-
4 DROP TABLE T1 <null> <null> 80:2 Y
316+
4 DROP TABLE T1 <null> <null> 80:2 Y
316317
==============================================================================
317-
SQL_TEXT:
318+
SQL_TEXT:
318319
recreate table t1 (
319320
n integer
320321
)
321322
==============================================================================
322-
5 CREATE TABLE T1 <null> <null> 80:3 Y
323+
5 CREATE TABLE T1 <null> <null> 80:3 Y
323324
==============================================================================
324-
SQL_TEXT:
325+
SQL_TEXT:
325326
recreate table t1 (
326327
n integer
327328
)
328329
==============================================================================
329-
6 CREATE DOMAIN DOM1 <null> <null> 80:4 Y
330+
6 CREATE DOMAIN DOM1 <null> <null> 80:4 Y
330331
==============================================================================
331-
SQL_TEXT:
332+
SQL_TEXT:
332333
create domain dom1 as integer
333334
==============================================================================
334-
7 ALTER DOMAIN DOM1 <null> <null> 80:5 Y
335+
7 ALTER DOMAIN DOM1 <null> <null> 80:5 Y
335336
==============================================================================
336-
SQL_TEXT:
337+
SQL_TEXT:
337338
alter domain dom1 type bigint
338339
==============================================================================
339-
8 ALTER DOMAIN DOM1 DOM1 DOM2 80:6 Y
340+
8 ALTER DOMAIN DOM1 DOM1 DOM2 80:6 Y
340341
==============================================================================
341-
SQL_TEXT:
342+
SQL_TEXT:
342343
alter domain dom1 to dom2
343344
==============================================================================
344345

doc/sql.extensions/README.profiler.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,8 @@ execute procedure rdb$profiler.finish_session(true);
109109
110110
-- Data analysis
111111
112+
set search_path to plg$profiler, public, system;
113+
112114
set transaction read committed;
113115
114116
select * from plg$prof_sessions;
@@ -243,7 +245,9 @@ Input parameters:
243245

244246
# Snapshot tables
245247

246-
Snapshot tables (as well views and sequence) are automatically created in the first usage of the profiler. They are owned by the database owner, with read/write permissions for `PUBLIC`.
248+
The profiler schema, snapshot tables, views and sequence are automatically created in the first usage of the profiler.
249+
250+
They are owned by the database owner, with usage/read/write permissions for the RDB$PROFILER role, granted by default to `PUBLIC`.
247251

248252
When a session is deleted, the related data in other profiler snapshot tables are automatically deleted too through foreign keys with `DELETE CASCADE` option.
249253

src/alice/exe.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,7 @@ static void buildDpb(Firebird::ClumpletWriter& dpb, const SINT64 switches)
202202
dpb.reset(isc_dpb_version1);
203203
dpb.insertTag(isc_dpb_gfix_attach);
204204
tdgbl->uSvc->fillDpb(dpb);
205+
dpb.insertString(isc_dpb_schema_path, SYSTEM_SCHEMA, fb_strlen(SYSTEM_SCHEMA));
205206

206207
if (switches & sw_sweep) {
207208
dpb.insertByte(isc_dpb_sweep, isc_dpb_records);

src/auth/SecureRemotePassword/manage/SrpManagement.cpp

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -68,28 +68,28 @@ class SrpManagement final : public Firebird::StdPlugin<Firebird::IManagementImpl
6868
void prepareDataStructures()
6969
{
7070
const char* script[] = {
71-
"CREATE TABLE PLG$SRP (PLG$USER_NAME SEC$USER_NAME NOT NULL PRIMARY KEY, "
71+
"CREATE TABLE PUBLIC.PLG$SRP (PLG$USER_NAME SYSTEM.SEC$USER_NAME NOT NULL PRIMARY KEY, "
7272
"PLG$VERIFIER VARCHAR(128) CHARACTER SET OCTETS NOT NULL, "
7373
"PLG$SALT VARCHAR(32) CHARACTER SET OCTETS NOT NULL, "
74-
"PLG$COMMENT RDB$DESCRIPTION, PLG$FIRST SEC$NAME_PART, "
75-
"PLG$MIDDLE SEC$NAME_PART, PLG$LAST SEC$NAME_PART, "
76-
"PLG$ATTRIBUTES RDB$DESCRIPTION, "
74+
"PLG$COMMENT SYSTEM.RDB$DESCRIPTION, PLG$FIRST SYSTEM.SEC$NAME_PART, "
75+
"PLG$MIDDLE SYSTEM.SEC$NAME_PART, PLG$LAST SYSTEM.SEC$NAME_PART, "
76+
"PLG$ATTRIBUTES SYSTEM.RDB$DESCRIPTION, "
7777
"PLG$ACTIVE BOOLEAN)"
7878
,
79-
"CREATE VIEW PLG$SRP_VIEW AS "
79+
"CREATE VIEW PUBLIC.PLG$SRP_VIEW AS "
8080
"SELECT PLG$USER_NAME, PLG$VERIFIER, PLG$SALT, PLG$COMMENT, "
8181
" PLG$FIRST, PLG$MIDDLE, PLG$LAST, PLG$ATTRIBUTES, PLG$ACTIVE "
82-
"FROM PLG$SRP WHERE RDB$SYSTEM_PRIVILEGE(USER_MANAGEMENT) "
82+
"FROM PUBLIC.PLG$SRP WHERE RDB$SYSTEM_PRIVILEGE(USER_MANAGEMENT) "
8383
" OR CURRENT_USER = PLG$SRP.PLG$USER_NAME"
8484
,
85-
"GRANT ALL ON PLG$SRP TO VIEW PLG$SRP_VIEW"
85+
"GRANT ALL ON PUBLIC.PLG$SRP TO VIEW PUBLIC.PLG$SRP_VIEW"
8686
,
87-
"GRANT SELECT ON PLG$SRP_VIEW TO PUBLIC"
87+
"GRANT SELECT ON PUBLIC.PLG$SRP_VIEW TO PUBLIC"
8888
,
8989
"GRANT UPDATE(PLG$VERIFIER, PLG$SALT, PLG$FIRST, PLG$MIDDLE, PLG$LAST, "
90-
" PLG$COMMENT, PLG$ATTRIBUTES) ON PLG$SRP_VIEW TO PUBLIC"
90+
" PLG$COMMENT, PLG$ATTRIBUTES) ON PUBLIC.PLG$SRP_VIEW TO PUBLIC"
9191
,
92-
"GRANT ALL ON PLG$SRP_VIEW TO SYSTEM PRIVILEGE USER_MANAGEMENT"
92+
"GRANT ALL ON PUBLIC.PLG$SRP_VIEW TO SYSTEM PRIVILEGE USER_MANAGEMENT"
9393
,
9494
NULL
9595
};
@@ -353,7 +353,7 @@ class SrpManagement final : public Firebird::StdPlugin<Firebird::IManagementImpl
353353
case Firebird::IUser::OP_USER_ADD:
354354
{
355355
const char* insert =
356-
"INSERT INTO plg$srp_view(PLG$USER_NAME, PLG$VERIFIER, PLG$SALT, PLG$FIRST, PLG$MIDDLE, PLG$LAST,"
356+
"INSERT INTO public.plg$srp_view(PLG$USER_NAME, PLG$VERIFIER, PLG$SALT, PLG$FIRST, PLG$MIDDLE, PLG$LAST,"
357357
"PLG$COMMENT, PLG$ATTRIBUTES, PLG$ACTIVE) VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?)";
358358

359359
Firebird::IStatement* stmt = NULL;
@@ -455,7 +455,7 @@ class SrpManagement final : public Firebird::StdPlugin<Firebird::IManagementImpl
455455

456456
case Firebird::IUser::OP_USER_MODIFY:
457457
{
458-
Firebird::string update = "UPDATE plg$srp_view SET ";
458+
Firebird::string update = "UPDATE public.plg$srp_view SET ";
459459

460460
Firebird::AutoPtr<Varfield> verifier, slt;
461461
if (user->password()->entered())
@@ -558,7 +558,7 @@ class SrpManagement final : public Firebird::StdPlugin<Firebird::IManagementImpl
558558

559559
case Firebird::IUser::OP_USER_DELETE:
560560
{
561-
const char* del = "DELETE FROM plg$srp_view WHERE PLG$USER_NAME=?";
561+
const char* del = "DELETE FROM public.plg$srp_view WHERE PLG$USER_NAME=?";
562562
Firebird::IStatement* stmt = NULL;
563563
try
564564
{
@@ -605,7 +605,7 @@ class SrpManagement final : public Firebird::StdPlugin<Firebird::IManagementImpl
605605
" WHERE RDB$RELATION_NAME = 'RDB$ADMIN' AND RDB$PRIVILEGE = 'M' GROUP BY RDB$USER) "
606606
"SELECT PLG$USER_NAME, PLG$FIRST, PLG$MIDDLE, PLG$LAST, PLG$COMMENT, PLG$ATTRIBUTES, "
607607
" CASE WHEN RDB$USER IS NULL THEN FALSE ELSE TRUE END, PLG$ACTIVE "
608-
"FROM PLG$SRP_VIEW LEFT JOIN ADMINS "
608+
"FROM system.PLG$SRP_VIEW LEFT JOIN ADMINS "
609609
" ON PLG$SRP_VIEW.PLG$USER_NAME = ADMINS.RDB$USER ";
610610
if (user->userName()->entered())
611611
{

src/auth/SecureRemotePassword/server/SrpServer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ class SecurityDatabase : public VSecDb
196196
HANDSHAKE_DEBUG(fprintf(stderr, "Srv: SRP1: started transaction\n"));
197197

198198
const char* sql =
199-
"SELECT PLG$VERIFIER, PLG$SALT FROM PLG$SRP WHERE PLG$USER_NAME = ? AND PLG$ACTIVE";
199+
"SELECT PLG$VERIFIER, PLG$SALT FROM PUBLIC.PLG$SRP WHERE PLG$USER_NAME = ? AND PLG$ACTIVE";
200200
stmt = att->prepare(&status, tra, 0, sql, 3, IStatement::PREPARE_PREFETCH_METADATA);
201201
if (status->getState() & IStatus::STATE_ERRORS)
202202
{

src/auth/SecurityDatabase/LegacyManagement.epp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ void SecurityDatabaseManagement::start(Firebird::CheckStatusWrapper* st, Firebir
129129
Firebird::ClumpletWriter dpb(Firebird::ClumpletReader::dpbList, MAX_DPB_SIZE);
130130
dpb.insertByte(isc_dpb_sec_attach, TRUE);
131131
dpb.insertString(isc_dpb_config, Firebird::ParsedList::getNonLoopbackProviders(secDbName));
132+
dpb.insertString(isc_dpb_schema_path, SYSTEM_SCHEMA, fb_strlen(SYSTEM_SCHEMA));
132133

133134
unsigned int authBlockSize;
134135
const unsigned char* authBlock = logonInfo->authBlock(&authBlockSize);
@@ -343,6 +344,7 @@ int SecurityDatabaseManagement::execute(Firebird::CheckStatusWrapper* st, Firebi
343344
// this checks the "entered" flags for each parameter (except the name)
344345
// and makes all non-entered parameters null valued
345346

347+
// FIXME: epp queries outside engine has not exclusive schema search path set to SYSTEM
346348
STORE (TRANSACTION_HANDLE transaction REQUEST_HANDLE request) U IN PLG$VIEW_USERS USING
347349
STR_STORE(U.PLG$USER_NAME, user->userName()->get());
348350

0 commit comments

Comments
 (0)