Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for time zone data types. #114

Merged
merged 3 commits into from
Aug 21, 2024
Merged

Add support for time zone data types. #114

merged 3 commits into from
Aug 21, 2024

Conversation

fujita-kin
Copy link
Contributor

時間帯付データ型のTIMETZとTIMESTAMPTZを追加サポートする

レグレッションテスト結果

JSON版

kfujita@sumatra:~/project-tsurugi/metadata-manager/build.json$ cmake -G Ninja -DCMAKE_BUILD_TYPE=Debug -DDATA_STORAGE=json ..
-- The CXX compiler identification is GNU 11.4.0
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found Doxygen: /usr/bin/doxygen (found version "1.9.1") found components: doxygen dot
-- Found Boost: /usr/lib/x86_64-linux-gnu/cmake/Boost-1.74.0/BoostConfig.cmake (found version "1.74.0") found components: system filesystem
-- The target of the build is metadata-manager.
--   Default log output level for metadata-manager is ERROR.
--   Metadata is stored in JSON-file.
--   Exclude postgresql sources.
--   Exclude postgresql test sources.
-- The C compiler identification is GNU 11.4.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Found Python3: /usr/bin/python3.10 (found version "3.10.12") found components: Interpreter
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Success
-- Found Threads: TRUE
-- Configuring done
-- Generating done
-- Build files have been written to: /home/kfujita/project-tsurugi/metadata-manager/build.json
kfujita@sumatra:~/project-tsurugi/metadata-manager/build.json$ ninja && (sleep 0.2; ctest)
[66/66] Linking CXX executable test/src/metadata_test
Test project /home/kfujita/project-tsurugi/metadata-manager/build.json
    Start 1: test
1/1 Test #1: test .............................   Passed    3.88 sec

100% tests passed, 0 tests failed out of 1

Total Test time (real) =   3.88 sec
kfujita@sumatra:~/project-tsurugi/metadata-manager/build.json$
kfujita@sumatra:~/project-tsurugi/metadata-manager/build.json$ ../test/extended/json/expected/test_tables.sh tables_test
-----------------------------------------------------------------------
[OID file]
Succeed: There is no difference.
-----------------------------------------------------------------------
[Tables metadata]
Succeed: There is no difference.
-----------------------------------------------------------------------
[Test result]
Succeed: There is no difference.
kfujita@sumatra:~/project-tsurugi/metadata-manager/build.json$

PostgreSQL版

kfujita@sumatra:~/project-tsurugi/metadata-manager/build.pg$ cmake -G Ninja -DCMAKE_BUILD_TYPE=Debug -DDATA_STORAGE=postgresql ..
-- The CXX compiler identification is GNU 11.4.0
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found Doxygen: /usr/bin/doxygen (found version "1.9.1") found components: doxygen dot
-- Found Boost: /usr/lib/x86_64-linux-gnu/cmake/Boost-1.74.0/BoostConfig.cmake (found version "1.74.0") found components: system filesystem
-- Found pg_config for PostgreSQL: /home/kfujita/pgsql/bin/pg_config
--   Header file directory: /home/kfujita/pgsql/include
--   Library file directory: /home/kfujita/pgsql/lib
-- The target of the build is metadata-manager.
--   Default log output level for metadata-manager is ERROR.
--   Metadata is stored in PostgreSQL.
--   Exclude json sources.
--   Exclude json test sources.
-- The C compiler identification is GNU 11.4.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Found Python3: /usr/bin/python3.10 (found version "3.10.12") found components: Interpreter
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Success
-- Found Threads: TRUE
-- Configuring done
-- Generating done
-- Build files have been written to: /home/kfujita/project-tsurugi/metadata-manager/build.pg
kfujita@sumatra:~/project-tsurugi/metadata-manager/build.pg$ ninja && (sleep 0.2; ctest)
[77/77] Linking CXX executable test/src/metadata_test
Test project /home/kfujita/project-tsurugi/metadata-manager/build.pg
    Start 1: test
1/1 Test #1: test .............................   Passed    7.92 sec

100% tests passed, 0 tests failed out of 1

Total Test time (real) =   7.93 sec
kfujita@sumatra:~/project-tsurugi/metadata-manager/build.pg$

@fujita-kin fujita-kin requested a review from koh-okada as a code owner August 20, 2024 05:25
@koh-okada
Copy link
Contributor

@kcc-oniki
今回の修正に限った話ではありませんが、「ヘッダファイルに定義されたデータ型ID」と「SQLに記載されたデータ型ID」が一致しない場合はテストで検出できるようになっていますか。

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

  static constexpr char TIMETZ[]      = "1266";
  static constexpr char TIMESTAMP[]   = "1114";
  static constexpr char TIMESTAMPTZ[] = "1184";

sql/ddl.sql

-- TIMETZ
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');
-- TIMESTAMP
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');
-- TIMESTAMPTZ
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');

理想としてはデータ型IDなどを定義したファイルをcppとsqlそれぞれが参照する形が好ましいですが、ここは将来的にヘッダファイル一本にまとめる予定なのでとりあえずはこのままで良いと思います。

@kcc-oniki
Copy link
Contributor

これを主目的としたテストというわけではありませんが、データ型のテストで検出されます。
ただ、ヘッダファイルはJSON版、DDLはPostgreSQL版のテストで検出しますので、両方を行う必要はあります。

@koh-okada koh-okada merged commit 773fad5 into master Aug 21, 2024
3 checks passed
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.

3 participants