25 Commits

Author SHA1 Message Date
Seth Hillbrand 8c34640520 Support SQLite generated columns in database libraries
SQLite ODBC drivers use PRAGMA table_info to implement SQLColumns,
which doesn't return generated columns. This caused KiCad to silently
ignore any generated column configured in a .kicad_dbl file.

Now CacheTableInfo trusts user-configured column names and adds them
to the cache even if the ODBC driver doesn't report them. If a column
truly doesn't exist, the subsequent query will fail with a clear error
rather than silently omitting the data.

Also adds a test case with a table containing a virtual generated column.

Fixes https://gitlab.com/kicad/code/kicad/-/issues/16952
2026-01-29 16:44:09 -08:00
Seth Hillbrand acbcb5e014 Fix issue 15880 by pre-describing ODBC parameters
Rather than modifying nanodbc to silently handle missing
SQLDescribeParam support, describe parameters in the application
before binding them. This approach keeps nanodbc pristine and
moves the workaround logic to KiCad where the issue occurs.

The fix pre-describes parameters as VARCHAR with size 255 in
DatabaseConnection::SelectOne before attempting to bind them.

Fixes https://gitlab.com/kicad/code/kicad/-/issues/15880
2026-01-29 16:31:44 -08:00
Jeff Young 260b0a9135 Catch exceptions thrown from nanodbc::statement's d'tor.
Fixes https://gitlab.com/kicad/code/kicad/-/issues/21707
2025-09-21 19:31:23 +01:00
Jeff Young 37df36be62 Catch all errors thrown by nanodbc.
Fixes https://gitlab.com/kicad/code/kicad/-/issues/21707
2025-09-17 13:00:01 +01:00
Jon Evans bdb2c3a025 DbLib: Use case-insensitive lookup for column caching 2025-01-02 12:59:15 -05:00
Seth Hillbrand 0b2d4d4879 Revise Copyright statement to align with TLF
Recommendation is to avoid using the year nomenclature as this
information is already encoded in the git repo.  Avoids needing to
repeatly update.

Also updates AUTHORS.txt from current repo with contributor names
2025-01-01 14:12:04 -08:00
Jon Evans 10922a194c Remove extraneous cache fill per row
Fixes https://gitlab.com/kicad/code/kicad/-/issues/18159


(cherry picked from commit 64da49f22e)

Co-authored-by: Jon Evans <jon@craftyjon.com>
2024-06-05 16:08:45 +00:00
Jon Evans 6c41354da5 DbLib: Prevent uncaught exception creating statement
Defer telling the statement about the connection until the
try block, because otherwise it can connect immediately and
potentially throw an exception if the connection fails.


(cherry picked from commit ddd7c35586)

Co-authored-by: Jon Evans <jon@craftyjon.com>
2024-05-06 21:00:13 +00:00
Jon Evans 3351da9906 DbLib: Fill entire table if cache is empty when loading one part
The "already placed parts" feature causes a situation where many
single-part queries are placed before the cache is even filled.

Fixes https://gitlab.com/kicad/code/kicad/-/issues/17940


(cherry picked from commit 3c99a3797e)

Co-authored-by: Jon Evans <jon@craftyjon.com>
2024-05-03 21:04:13 +00:00
Alex Shvartzkop cb25c8620e Performance optimizations for database libraries.
(cherry picked from commit e68df8e1d1)
2024-02-23 20:29:18 +03:00
Jon Evans 44374c661f Database: handle more possible datatype exceptions
Fixes https://gitlab.com/kicad/code/kicad/-/issues/16090
2023-11-15 12:27:34 -05:00
Jon Evans 6f9af10912 DbLib: support columns with numeric data
Fixes https://gitlab.com/kicad/code/kicad/-/issues/15662
2023-09-16 22:37:12 -04:00
Marek Roszko 7505fd0f37 Profile can live in core 2023-09-07 07:47:01 -04:00
Jon Evans e0d4cf2d5b DbLib: Provide more useful feedback when table is misconfigured
(cherry picked from commit 8f57fd82a0)
2023-08-15 20:45:52 +00:00
Jon Evans 39a5929f33 Database libraries performance improvements
Rework caching system and optimize queries
2023-06-22 18:49:37 -04:00
Wayne Stambaugh 789bf6455a Coverity fixes and code cleaning. 2023-03-02 09:04:47 -05:00
Jon Evans 66799b60f8 DbLib: Reconnect if connection is lost 2022-12-22 12:15:04 -05:00
Jon Evans 201b45b41a Remove call that crashes MySQL connector sometimes
It no longer is necessary anyway

Fixes https://gitlab.com/kicad/code/kicad/-/issues/12471
2022-09-23 19:28:04 -04:00
Marek Roszko 63295cfb9e Remove unused vars 2022-09-18 08:49:07 -04:00
Jon Evans b0aba0fdf3 Cache works better with unique keys 2022-09-01 23:11:35 -04:00
Jon Evans 60f6bb8c77 DbLib: Fixes for MySQL ODBC driver
SQLSetConnectAttr crashes for this driver, and SQLSetStmtAttr is the ODBC3 way anyway.
2022-09-01 00:24:56 -04:00
Jon Evans ae879c8f02 DbLib: Add single-row query cache
Since single-row queries are performed rapid-fire during certain actions like
stepping through the symbol browser, there is high value in caching them for
a small amount of time.  The default cache parameters will keep results for
10 seconds, which errs on the side of getting fresh data from the database
on most user interactions.
2022-08-30 22:18:36 -04:00
Jon Evans d22fc24d9e Attempt to fix MSVC build 2022-08-26 12:51:14 -04:00
jean-pierre charras 5c7f1083c7 database_connection.cpp: Fix compil issues on msys2. these issues are
due to "old" (or not existing) types used in sql.h
2022-08-26 18:15:57 +02:00
Jon Evans ae6a2a6443 ADDED: Database libraries MVP
Allows placing parts from an external database that reference symbols from another loaded library.

Includes:
- nanodbc wrapper
- database schematic library plugin
- basic tests

Fixes https://gitlab.com/kicad/code/kicad/-/issues/7436
2022-08-26 10:51:13 -04:00