Skip to content

Commit 86621ff

Browse files
authored
Merge dd2fcfe into 4cfcfde
2 parents 4cfcfde + dd2fcfe commit 86621ff

12 files changed

Lines changed: 229 additions & 6 deletions

File tree

builds/win32/msvc12/engine.vcxproj

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@
9191
<ClCompile Include="..\..\..\src\jrd\intl_builtin.cpp" />
9292
<ClCompile Include="..\..\..\src\jrd\jrd.cpp" />
9393
<ClCompile Include="..\..\..\src\jrd\JrdStatement.cpp" />
94+
<ClCompile Include="..\..\..\src\jrd\KeywordsTable.cpp" />
9495
<ClCompile Include="..\..\..\src\jrd\lck.cpp" />
9596
<ClCompile Include="..\..\..\src\jrd\Mapping.cpp" />
9697
<ClCompile Include="..\..\..\src\jrd\Monitoring.cpp" />
@@ -276,6 +277,7 @@
276277
<ClInclude Include="..\..\..\src\jrd\jrd.h" />
277278
<ClInclude Include="..\..\..\src\jrd\JrdStatement.h" />
278279
<ClInclude Include="..\..\..\src\jrd\jrd_proto.h" />
280+
<ClInclude Include="..\..\..\src\jrd\KeywordsTable.h" />
279281
<ClInclude Include="..\..\..\src\jrd\lck.h" />
280282
<ClInclude Include="..\..\..\src\jrd\lck_proto.h" />
281283
<ClInclude Include="..\..\..\src\jrd\license.h" />
@@ -558,4 +560,4 @@
558560
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
559561
<ImportGroup Label="ExtensionTargets">
560562
</ImportGroup>
561-
</Project>
563+
</Project>

builds/win32/msvc12/engine.vcxproj.filters

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,9 @@
288288
<ClCompile Include="..\..\..\src\jrd\JrdStatement.cpp">
289289
<Filter>JRD files</Filter>
290290
</ClCompile>
291+
<ClCompile Include="..\..\..\src\jrd\KeywordsTable.cpp">
292+
<Filter>JRD files</Filter>
293+
</ClCompile>
291294
<ClCompile Include="..\..\..\src\jrd\lck.cpp">
292295
<Filter>JRD files</Filter>
293296
</ClCompile>
@@ -824,6 +827,9 @@
824827
<ClInclude Include="..\..\..\src\jrd\JrdStatement.h">
825828
<Filter>Header files</Filter>
826829
</ClInclude>
830+
<ClInclude Include="..\..\..\src\jrd\KeywordsTable.h">
831+
<Filter>Header files</Filter>
832+
</ClInclude>
827833
<ClInclude Include="..\..\..\src\jrd\lck.h">
828834
<Filter>Header files</Filter>
829835
</ClInclude>
@@ -1088,4 +1094,4 @@
10881094
<Filter>Resource files</Filter>
10891095
</ResourceCompile>
10901096
</ItemGroup>
1091-
</Project>
1097+
</Project>

builds/win32/msvc14/engine.vcxproj

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@
9191
<ClCompile Include="..\..\..\src\jrd\intl_builtin.cpp" />
9292
<ClCompile Include="..\..\..\src\jrd\jrd.cpp" />
9393
<ClCompile Include="..\..\..\src\jrd\JrdStatement.cpp" />
94+
<ClCompile Include="..\..\..\src\jrd\KeywordsTable.cpp" />
9495
<ClCompile Include="..\..\..\src\jrd\lck.cpp" />
9596
<ClCompile Include="..\..\..\src\jrd\Mapping.cpp" />
9697
<ClCompile Include="..\..\..\src\jrd\MetaName.cpp" />
@@ -277,6 +278,7 @@
277278
<ClInclude Include="..\..\..\src\jrd\jrd.h" />
278279
<ClInclude Include="..\..\..\src\jrd\JrdStatement.h" />
279280
<ClInclude Include="..\..\..\src\jrd\jrd_proto.h" />
281+
<ClInclude Include="..\..\..\src\jrd\KeywordsTable.h" />
280282
<ClInclude Include="..\..\..\src\jrd\lck.h" />
281283
<ClInclude Include="..\..\..\src\jrd\lck_proto.h" />
282284
<ClInclude Include="..\..\..\src\jrd\license.h" />
@@ -560,4 +562,4 @@
560562
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
561563
<ImportGroup Label="ExtensionTargets">
562564
</ImportGroup>
563-
</Project>
565+
</Project>

builds/win32/msvc14/engine.vcxproj.filters

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,9 @@
288288
<ClCompile Include="..\..\..\src\jrd\JrdStatement.cpp">
289289
<Filter>JRD files</Filter>
290290
</ClCompile>
291+
<ClCompile Include="..\..\..\src\jrd\KeywordsTable.cpp">
292+
<Filter>JRD files</Filter>
293+
</ClCompile>
291294
<ClCompile Include="..\..\..\src\jrd\lck.cpp">
292295
<Filter>JRD files</Filter>
293296
</ClCompile>
@@ -827,6 +830,9 @@
827830
<ClInclude Include="..\..\..\src\jrd\JrdStatement.h">
828831
<Filter>Header files</Filter>
829832
</ClInclude>
833+
<ClInclude Include="..\..\..\src\jrd\KeywordsTable.h">
834+
<Filter>Header files</Filter>
835+
</ClInclude>
830836
<ClInclude Include="..\..\..\src\jrd\lck.h">
831837
<Filter>Header files</Filter>
832838
</ClInclude>
@@ -1094,4 +1100,4 @@
10941100
<Filter>Resource files</Filter>
10951101
</ResourceCompile>
10961102
</ItemGroup>
1097-
</Project>
1103+
</Project>

builds/win32/msvc15/engine.vcxproj

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@
9191
<ClCompile Include="..\..\..\src\jrd\intl_builtin.cpp" />
9292
<ClCompile Include="..\..\..\src\jrd\jrd.cpp" />
9393
<ClCompile Include="..\..\..\src\jrd\JrdStatement.cpp" />
94+
<ClCompile Include="..\..\..\src\jrd\KeywordsTable.cpp" />
9495
<ClCompile Include="..\..\..\src\jrd\lck.cpp" />
9596
<ClCompile Include="..\..\..\src\jrd\Mapping.cpp" />
9697
<ClCompile Include="..\..\..\src\jrd\MetaName.cpp" />
@@ -277,6 +278,7 @@
277278
<ClInclude Include="..\..\..\src\jrd\jrd.h" />
278279
<ClInclude Include="..\..\..\src\jrd\JrdStatement.h" />
279280
<ClInclude Include="..\..\..\src\jrd\jrd_proto.h" />
281+
<ClInclude Include="..\..\..\src\jrd\KeywordsTable.h" />
280282
<ClInclude Include="..\..\..\src\jrd\lck.h" />
281283
<ClInclude Include="..\..\..\src\jrd\lck_proto.h" />
282284
<ClInclude Include="..\..\..\src\jrd\license.h" />
@@ -561,4 +563,4 @@
561563
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
562564
<ImportGroup Label="ExtensionTargets">
563565
</ImportGroup>
564-
</Project>
566+
</Project>

builds/win32/msvc15/engine.vcxproj.filters

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,9 @@
288288
<ClCompile Include="..\..\..\src\jrd\JrdStatement.cpp">
289289
<Filter>JRD files</Filter>
290290
</ClCompile>
291+
<ClCompile Include="..\..\..\src\jrd\KeywordsTable.cpp">
292+
<Filter>JRD files</Filter>
293+
</ClCompile>
291294
<ClCompile Include="..\..\..\src\jrd\lck.cpp">
292295
<Filter>JRD files</Filter>
293296
</ClCompile>
@@ -827,6 +830,9 @@
827830
<ClInclude Include="..\..\..\src\jrd\JrdStatement.h">
828831
<Filter>Header files</Filter>
829832
</ClInclude>
833+
<ClInclude Include="..\..\..\src\jrd\KeywordsTable.h">
834+
<Filter>Header files</Filter>
835+
</ClInclude>
830836
<ClInclude Include="..\..\..\src\jrd\lck.h">
831837
<Filter>Header files</Filter>
832838
</ClInclude>
@@ -1094,4 +1100,4 @@
10941100
<Filter>Resource files</Filter>
10951101
</ResourceCompile>
10961102
</ItemGroup>
1097-
</Project>
1103+
</Project>

src/jrd/KeywordsTable.cpp

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
/*
2+
* The contents of this file are subject to the Initial
3+
* Developer's Public License Version 1.0 (the "License");
4+
* you may not use this file except in compliance with the
5+
* License. You may obtain a copy of the License at
6+
* http://www.ibphoenix.com/main.nfs?a=ibphoenix&page=ibp_idpl.
7+
*
8+
* Software distributed under the License is distributed AS IS,
9+
* WITHOUT WARRANTY OF ANY KIND, either express or implied.
10+
* See the License for the specific language governing rights
11+
* and limitations under the License.
12+
*
13+
* The Original Code was created by Adriano dos Santos Fernandes
14+
* for the Firebird Open Source RDBMS project.
15+
*
16+
* Copyright (c) 2021 Adriano dos Santos Fernandes <[email protected]>
17+
* and all contributors signed below.
18+
*
19+
* All Rights Reserved.
20+
* Contributor(s): ______________________________________.
21+
*/
22+
23+
#include "../jrd/KeywordsTable.h"
24+
#include "../jrd/ini.h"
25+
#include "../jrd/ids.h"
26+
#include "../common/keywords.h"
27+
28+
using namespace Jrd;
29+
using namespace Firebird;
30+
31+
32+
RecordBuffer* KeywordsTable::getRecords(thread_db* tdbb, jrd_rel* relation)
33+
{
34+
fb_assert(relation);
35+
fb_assert(relation->rel_id == rel_keywords);
36+
37+
auto recordBuffer = getData(relation);
38+
if (recordBuffer)
39+
return recordBuffer;
40+
41+
recordBuffer = allocBuffer(tdbb, *tdbb->getDefaultPool(), relation->rel_id);
42+
43+
const auto record = recordBuffer->getTempRecord();
44+
45+
for (const auto* token = keywordGetTokens(); token->tok_string; ++token)
46+
{
47+
if (isalpha(token->tok_string[0]))
48+
{
49+
record->nullify();
50+
51+
putField(tdbb, record,
52+
DumpField(f_keyword_name, VALUE_STRING, strlen(token->tok_string), token->tok_string));
53+
54+
const bool reserved = !token->nonReserved;
55+
putField(tdbb, record, DumpField(f_keyword_reserved, VALUE_BOOLEAN, 1, &reserved));
56+
57+
recordBuffer->store(record);
58+
}
59+
}
60+
61+
return recordBuffer;
62+
}
63+
64+
65+
//--------------------------------------
66+
67+
68+
void KeywordsTableScan::close(thread_db* tdbb) const
69+
{
70+
const auto request = tdbb->getRequest();
71+
const auto impure = request->getImpure<Impure>(impureOffset);
72+
73+
delete impure->table;
74+
impure->table = nullptr;
75+
76+
VirtualTableScan::close(tdbb);
77+
}
78+
79+
const Format* KeywordsTableScan::getFormat(thread_db* tdbb, jrd_rel* relation) const
80+
{
81+
const auto records = getRecords(tdbb, relation);
82+
return records->getFormat();
83+
}
84+
85+
bool KeywordsTableScan::retrieveRecord(thread_db* tdbb, jrd_rel* relation,
86+
FB_UINT64 position, Record* record) const
87+
{
88+
const auto records = getRecords(tdbb, relation);
89+
return records->fetch(position, record);
90+
}
91+
92+
RecordBuffer* KeywordsTableScan::getRecords(thread_db* tdbb, jrd_rel* relation) const
93+
{
94+
const auto request = tdbb->getRequest();
95+
const auto impure = request->getImpure<Impure>(impureOffset);
96+
97+
if (!impure->table)
98+
impure->table = FB_NEW_POOL(*tdbb->getDefaultPool()) KeywordsTable(*tdbb->getDefaultPool());
99+
100+
return impure->table->getRecords(tdbb, relation);
101+
}

src/jrd/KeywordsTable.h

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
/*
2+
* The contents of this file are subject to the Initial
3+
* Developer's Public License Version 1.0 (the "License");
4+
* you may not use this file except in compliance with the
5+
* License. You may obtain a copy of the License at
6+
* http://www.ibphoenix.com/main.nfs?a=ibphoenix&page=ibp_idpl.
7+
*
8+
* Software distributed under the License is distributed AS IS,
9+
* WITHOUT WARRANTY OF ANY KIND, either express or implied.
10+
* See the License for the specific language governing rights
11+
* and limitations under the License.
12+
*
13+
* The Original Code was created by Adriano dos Santos Fernandes
14+
* for the Firebird Open Source RDBMS project.
15+
*
16+
* Copyright (c) 2021 Adriano dos Santos Fernandes <[email protected]>
17+
* and all contributors signed below.
18+
*
19+
* All Rights Reserved.
20+
* Contributor(s): ______________________________________.
21+
*/
22+
23+
#ifndef JRD_KEYWORDS_TABLE_H
24+
#define JRD_KEYWORDS_TABLE_H
25+
26+
#include "firebird.h"
27+
#include "../common/classes/fb_string.h"
28+
#include "../jrd/Monitoring.h"
29+
#include "../jrd/recsrc/RecordSource.h"
30+
31+
32+
namespace Jrd
33+
{
34+
35+
class KeywordsTable : public SnapshotData
36+
{
37+
public:
38+
KeywordsTable(MemoryPool& pool)
39+
: SnapshotData(pool)
40+
{
41+
}
42+
43+
public:
44+
RecordBuffer* getRecords(thread_db* tdbb, jrd_rel* relation);
45+
};
46+
47+
48+
class KeywordsTableScan : public VirtualTableScan
49+
{
50+
public:
51+
KeywordsTableScan(CompilerScratch* csb, const Firebird::string& alias,
52+
StreamType stream, jrd_rel* relation)
53+
: VirtualTableScan(csb, alias, stream, relation)
54+
{
55+
impureOffset = csb->allocImpure<Impure>();
56+
}
57+
58+
void close(thread_db* tdbb) const override;
59+
60+
protected:
61+
const Format* getFormat(thread_db* tdbb, jrd_rel* relation) const override;
62+
63+
bool retrieveRecord(thread_db* tdbb, jrd_rel* relation, FB_UINT64 position,
64+
Record* record) const override;
65+
66+
private:
67+
struct Impure
68+
{
69+
KeywordsTable* table;
70+
};
71+
72+
RecordBuffer* getRecords(thread_db* tdbb, jrd_rel* relation) const;
73+
74+
ULONG impureOffset;
75+
};
76+
77+
} // namespace Jrd
78+
79+
#endif // JRD_KEYWORDS_TABLE_H

src/jrd/fields.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,3 +220,6 @@
220220
FIELD(fld_cfg_is_set , nam_cfg_is_set , dtype_boolean , 1 , 0 , NULL , false)
221221

222222
FIELD(fld_repl_mode , nam_repl_mode , dtype_short , sizeof(SSHORT) , 0 , NULL , true)
223+
224+
FIELD(fld_keyword_name , nam_keyword_name , dtype_varying , METADATA_IDENTIFIER_CHAR_LEN, dsc_text_type_ascii , NULL , false)
225+
FIELD(fld_keyword_reserved, nam_keyword_reserved, dtype_boolean, 1 , 0 , NULL , false)

src/jrd/names.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -451,3 +451,7 @@ NAME("RDB$CONFIG_VALUE", nam_cfg_value)
451451
NAME("RDB$CONFIG_DEFAULT", nam_cfg_default)
452452
NAME("RDB$CONFIG_IS_SET", nam_cfg_is_set)
453453
NAME("RDB$CONFIG_SOURCE", nam_cfg_source)
454+
455+
NAME("RDB$KEYWORDS", nam_keywords)
456+
NAME("RDB$KEYWORD_NAME", nam_keyword_name)
457+
NAME("RDB$KEYWORD_RESERVED", nam_keyword_reserved)

0 commit comments

Comments
 (0)