Skip to content

Commit 773fad5

Browse files
authored
Merge pull request #114 from project-tsurugi/dev/timezone
Add support for time zone data types.
2 parents 2cc7c74 + 2b094e9 commit 773fad5

File tree

7 files changed

+77
-120
lines changed

7 files changed

+77
-120
lines changed

include/manager/metadata/dao/common/pg_type.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2021-2022 Project Tsurugi.
2+
* Copyright 2021-2024 Project Tsurugi.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -39,7 +39,6 @@ class PgType {
3939
static constexpr std::uint32_t kTimetz = 1266;
4040
static constexpr std::uint32_t kTimestamp = 1114;
4141
static constexpr std::uint32_t kTimestamptz = 1184;
42-
static constexpr std::uint32_t kInterval = 1186;
4342
};
4443

4544
/**
@@ -59,7 +58,6 @@ class PgType {
5958
static constexpr const char* const kTimetz = "timetz";
6059
static constexpr const char* const kTimestamp = "timestamp";
6160
static constexpr const char* const kTimestamptz = "timestamptz";
62-
static constexpr const char* const kInterval = "interval";
6361
};
6462
};
6563

sql/ddl.sql

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,11 @@ INSERT INTO tg_catalog.types (format_version, generation, id, name, pg_data_type
125125
INSERT INTO tg_catalog.types (format_version, generation, id, name, pg_data_type, pg_data_type_name, pg_data_type_qualified_name) values (1, 1, 1082, 'DATE', 1082,'date','date');
126126
-- TIME
127127
INSERT INTO tg_catalog.types (format_version, generation, id, name, pg_data_type, pg_data_type_name, pg_data_type_qualified_name) values (1, 1, 1083, 'TIME', 1083,'time','time');
128+
-- TIMETZ
129+
INSERT INTO tg_catalog.types (format_version, generation, id, name, pg_data_type, pg_data_type_name, pg_data_type_qualified_name) values (1, 1, 1266, 'TIMETZ', 1266,'timetz','timetz');
128130
-- TIMESTAMP
129131
INSERT INTO tg_catalog.types (format_version, generation, id, name, pg_data_type, pg_data_type_name, pg_data_type_qualified_name) values (1, 1, 1114, 'TIMESTAMP', 1114,'timestamp','timestamp');
132+
-- TIMESTAMPTZ
133+
INSERT INTO tg_catalog.types (format_version, generation, id, name, pg_data_type, pg_data_type_name, pg_data_type_qualified_name) values (1, 1, 1184, 'TIMESTAMPTZ', 1184,'timestamptz','timestamptz');
130134

131135
GRANT ALL ON ALL TABLES IN SCHEMA tg_catalog To current_user;

src/dao/json/datatypes_dao_json.cpp

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2021-2023 Project Tsurugi.
2+
* Copyright 2021-2024 Project Tsurugi.
33
*
44
* Licensed under the Apache License, version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -175,18 +175,6 @@ ErrorCode DataTypesDaoJson::prepare() {
175175
datatype.put(DataTypes::PG_DATA_TYPE_QUALIFIED_NAME,
176176
PgType::TypeName::kTimestamptz);
177177
datatypes.push_back(std::make_pair("", datatype));
178-
179-
// INTERVAL :
180-
datatype.put(DataTypes::FORMAT_VERSION, DataTypes::format_version());
181-
datatype.put(DataTypes::GENERATION, DataTypes::generation());
182-
datatype.put(DataTypes::ID,
183-
static_cast<ObjectIdType>(DataTypes::DataTypesId::INTERVAL));
184-
datatype.put(DataTypes::NAME, "INTERVAL");
185-
datatype.put(DataTypes::PG_DATA_TYPE, PgType::TypeOid::kInterval);
186-
datatype.put(DataTypes::PG_DATA_TYPE_NAME, "interval");
187-
datatype.put(DataTypes::PG_DATA_TYPE_QUALIFIED_NAME,
188-
PgType::TypeName::kInterval);
189-
datatypes.push_back(std::make_pair("", datatype));
190178
}
191179

192180
datatype_contents_.clear();

test/extended/json/expected/oid

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
tables=10
2-
column=31
1+
global=100042

test/extended/json/expected/result.txt

Lines changed: 35 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33
=== Start test of add and get of Tables class. ===
44
--- get table metadata by table name. ---
55
--- table metadata ---
6-
id: [1]
7-
name: [table_1]
6+
id: [100002]
7+
name: [table_100002]
88
namespace: [public]
99
numberOfTu: [123]
1010
--- columns metadata ---
11-
id: [1]
12-
tableId: [1]
11+
id: [100003]
12+
tableId: [100002]
1313
name: [column_1]
1414
columnNumb: [1]
1515
dataTypeId: [700]
@@ -18,8 +18,8 @@
1818
isNotNull: [0]
1919
defaultExp: [--]
2020
------------------
21-
id: [2]
22-
tableId: [1]
21+
id: [100004]
22+
tableId: [100002]
2323
name: [column_2]
2424
columnNumb: [2]
2525
dataTypeId: [1043]
@@ -28,8 +28,8 @@
2828
isNotNull: [0]
2929
defaultExp: [--]
3030
------------------
31-
id: [3]
32-
tableId: [1]
31+
id: [100005]
32+
tableId: [100002]
3333
name: [column_3]
3434
columnNumb: [3]
3535
dataTypeId: [1042]
@@ -40,13 +40,13 @@
4040
------------------
4141
--- get table metadata by table id. ---
4242
--- table metadata ---
43-
id: [1]
44-
name: [table_1]
43+
id: [100002]
44+
name: [table_100002]
4545
namespace: [public]
4646
numberOfTu: [123]
4747
--- columns metadata ---
48-
id: [1]
49-
tableId: [1]
48+
id: [100003]
49+
tableId: [100002]
5050
name: [column_1]
5151
columnNumb: [1]
5252
dataTypeId: [700]
@@ -55,8 +55,8 @@
5555
isNotNull: [0]
5656
defaultExp: [--]
5757
------------------
58-
id: [2]
59-
tableId: [1]
58+
id: [100004]
59+
tableId: [100002]
6060
name: [column_2]
6161
columnNumb: [2]
6262
dataTypeId: [1043]
@@ -65,8 +65,8 @@
6565
isNotNull: [0]
6666
defaultExp: [--]
6767
------------------
68-
id: [3]
69-
tableId: [1]
68+
id: [100005]
69+
tableId: [100002]
7070
name: [column_3]
7171
columnNumb: [3]
7272
dataTypeId: [1042]
@@ -79,13 +79,13 @@
7979

8080
=== Start test of update of Tables class. ===
8181
--- table metadata ---
82-
id: [2] --> [2]
83-
name: [table_2] --> [table_2-update]
82+
id: [100006] --> [100006]
83+
name: [table_100006] --> [table_100006-update]
8484
namespace: [public] --> [public-update]
8585
numberOfTu: [123] --> [246]
8686
--- columns metadata ---
87-
id: [4] --> [--]
88-
tableId: [2] --> [--]
87+
id: [100007] --> [--]
88+
tableId: [100006] --> [--]
8989
name: [column_1] --> [--]
9090
columnNumb: [1] --> [--]
9191
dataTypeId: [700] --> [--]
@@ -94,8 +94,8 @@
9494
isNotNull: [0] --> [--]
9595
defaultExp: [--] --> [--]
9696
------------------
97-
id: [5] --> [5]
98-
tableId: [2] --> [2]
97+
id: [100008] --> [100008]
98+
tableId: [100006] --> [100006]
9999
name: [column_2] --> [column_2-update]
100100
columnNumb: [2] --> [1]
101101
dataTypeId: [1043] --> [20]
@@ -104,8 +104,8 @@
104104
isNotNull: [0] --> [1]
105105
defaultExp: [--] --> [-1]
106106
------------------
107-
id: [6] --> [6]
108-
tableId: [2] --> [2]
107+
id: [100009] --> [100009]
108+
tableId: [100006] --> [100006]
109109
name: [column_3] --> [column_3-update]
110110
columnNumb: [3] --> [2]
111111
dataTypeId: [1042] --> [1043]
@@ -114,8 +114,8 @@
114114
isNotNull: [1] --> [0]
115115
defaultExp: [--] --> [default-string]
116116
------------------
117-
id: [--] --> [7]
118-
tableId: [--] --> [2]
117+
id: [--] --> [100010]
118+
tableId: [--] --> [100006]
119119
name: [--] --> [new-col]
120120
columnNumb: [--] --> [3]
121121
dataTypeId: [--] --> [23]
@@ -127,18 +127,17 @@
127127
=== Done test of update of Tables class. ===
128128

129129
=== Start test of remove of Tables class. ===
130-
=== Done test of remove of Tables class. ===
131-
remove table name :table_3, id:3
132-
remove table name :table_5, id:5
133-
remove table name :table_6, id:6
134-
remove table name :table_4, id:4
130+
remove table name :table_100023, id:100023
131+
remove table name :table_100015, id:100015
132+
remove table name :table_100011, id:100011
133+
remove table name :table_100019, id:100019
135134
can't remove table name not exists :table_name_not_exists
136-
remove table id:7
137-
remove table id:9
138-
remove table id:10
139-
remove table id:8
135+
remove table id:100039
136+
remove table id:100031
137+
remove table id:100027
138+
remove table id:100035
140139
can't remove table id not exists :0
141-
=== remove table functions test done. ===
140+
=== Done test of remove of Tables class. ===
142141

143142
=== Start test of get of DataTypes class. ===
144143
DataTypes -> FORMAT_VERSION:[1] / GENERATION:[1] / ID:[23] / NAME:[INT32]
@@ -153,7 +152,6 @@ DataTypes -> FORMAT_VERSION:[1] / GENERATION:[1] / ID:[1083] / NAME:[TIME]
153152
DataTypes -> FORMAT_VERSION:[1] / GENERATION:[1] / ID:[1266] / NAME:[TIMETZ]
154153
DataTypes -> FORMAT_VERSION:[1] / GENERATION:[1] / ID:[1114] / NAME:[TIMESTAMP]
155154
DataTypes -> FORMAT_VERSION:[1] / GENERATION:[1] / ID:[1184] / NAME:[TIMESTAMPTZ]
156-
DataTypes -> FORMAT_VERSION:[1] / GENERATION:[1] / ID:[1186] / NAME:[INTERVAL]
157155
=== Done test of get of DataTypes class. ===
158156

159157
Tables add and get functions test: Success

0 commit comments

Comments
 (0)