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

Migrate database schema to modern types and improve string handling #37

Merged
merged 2 commits into from
Nov 19, 2024

Conversation

stevewgr
Copy link
Member

Description

This pull request migrates the database to address legacy data types and improve storage and processing efficiency. Specifically:

  1. Migration from ntext/text to varchar:

    • These legacy types are deprecated in newer MSSQL versions and will be fully removed in future versions.
    • Updated the layout of K_NPCPOS to align with the official configuration and the loading order used by N3ME and server files.
  2. Migration from CHAR to VARCHAR:

    • CHAR columns caused inconsistencies due to fixed length and padded whitespaces.
    • VARCHAR handles variable-length strings more efficiently, reducing IO overhead, optimizing storage, and improving performance.
    • This resolves misuse of CHAR and addresses inefficiencies in storage and operations.

Additional Notes

  • This is the initial step in cleaning up inconsistencies in the database schema and migrating towards the use of MSSQL 2019's new collation: Latin1_General_100_CS_AS_SC_UTF8.
  • The changes maintain compatibility with the current server files; no updates to the server are required.
  • Previously, the server files (C++ codebase) had to call a Trim function to handle trailing spaces in strings retrieved from CHAR columns. With this migration to VARCHAR, such trimming may no longer be necessary but can remain in place without causing any issues. Cleanup of this logic can be done incrementally.

Why These Changes?

  • Future-proofing: Preparing the database for MSSQL updates and removing reliance on deprecated types.
  • Efficiency: Optimizing database operations by using appropriate data types.
  • Consistency: Reducing discrepancies caused by padded strings and fixed-length columns.

Impact

  • No breaking changes.
  • Server files remain compatible without modification.
  • Performance and consistency improvements in database operations.

Next Steps

Further cleanup tasks, such as updating server-side string handling logic (e.g., trimming), can be addressed incrementally without immediate urgency.

Note that with newer MSSQL collation they're deprecated and in future
SQL versions will be fully removed.

Also I updated the layout of K_NPCPOS to match how it is officially and
with the N3ME and server files loading order.
CHAR columns caused inconsistencies due to fixed length and padded
whitespaces, leading to inefficient IO and server operations. VARCHAR
handles variable-length strings more compactly, saving space and improving
performance for our use case. This migration resolves misuse and optimizes
storage and processing efficiency.
@stevewgr stevewgr self-assigned this Nov 19, 2024
@stevewgr
Copy link
Member Author

stevewgr commented Nov 19, 2024

Note that if you can't load the big diff in your browser, you can add .patch at the end of the commit message and it will render it:
https://github.com/ko4life-net/ko-db/pull/37/commits/6e9f29ca06444159e58e63f35b59ac31f09f6b51.patch

You can also use a browser extension to colorized it.

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.

1 participant