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