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

Assorted improvements from NCBI as of May 2024 #559

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

ucko
Copy link
Contributor

@ucko ucko commented May 30, 2024

This PR contains seven (mostly formally) interdependent commits from #555; I've split off what I cleanly could, and in particular split the bulk.c changes from 1512645 into e6facc4 so that I can have a separate BCP-focused PR, leaving b6ab56f for here.

ucko added 7 commits May 29, 2024 13:07
This distinction will initially be useful only for ctlib and dblib,
but applying it across the board may avoid possible confusion if it
turns out to be useful elsewhere too.

Signed-off-by: Aaron M. Ucko <[email protected]>
* #include <config.h> from several more internal headers to facilitate
  injecting most renaming through there; some of these headers consult
  HAVE_* macros anyway.
* Account for possible renaming of cs_dt_crack (not just aliasing it
  to ..._v2), dbopen, tdsdump_dump_buf, and tdsdump_log; for the
  latter two, change the underlying functions' names to
  tdsdump_do_... modulo possible mass renaming.

Signed-off-by: Aaron M. Ucko <[email protected]>
* odbc_sql2tds: Treat SYB5INT8 like other numeric types.
* tds_generic_get: Handle non-blob types with four-byte sizes (e.g.,
  XSYBCHAR at least some of the time).
* tds_generic_put_info: Send size 255 (0xff) for NULL short character
  types in output columns.

Signed-off-by: Aaron M. Ucko <[email protected]>
* tds.h (is_blob_col): Consider column_type in addition to column_varint_size.
* Retire 5 as a nominal column_varint_size value in favor of unified logic.

Signed-off-by: Aaron M. Ucko <[email protected]>
* tds.h (TDSMESSAGE): Add an osstr field.
* ctutil.c (_ct_handle_client_message): Propagate it to osstring(len).
* tds/login.c (tds_save): Clear osstr to avoid invalid reads when
  trying to connect to a dead server.
* tds/ncbi_strerror.c: New.
* tds/util.c:
** #include ncbi_strerror.c, whose definitions are all static.
** tdserror: Populate the osstr field; clean it when done.

Signed-off-by: Aaron M. Ucko <[email protected]>
- Harmonize variable, parameter, etc. data types more fully.
- Adjust system API usage accordingly:
-- For some string constants, use sizeof() - 1 in lieu of strlen,
   taking care to ensure they come from array variables.
-- Keep format specifiers for printf et al. in sync with argument types.
-- dbprrow: Account for the fact that printf always uses int for
   dynamic widths by substituting memchr + fwrite.
-- odbc/prepare_query.c (prepared_rpc): Substitute atoi for strtol
   (already used with no endptr) when populating TDSINT4.
- Cast away some remaining discrepancies where safe, in some cases by
  taking advantage of TDS_PUT_* macros.
- ctlib.h: Explicitly define _CS_CURS_TYPE_* in terms of
  TDS_CURSOR_STATE_* rather than duplicating their values.
- tds_parse_conf_section: To legitimize a cast, tighten debug_flags'
  range check on systems where int is narrower than long.
- odbc_util.c: #include <stddef.h> for ptrdiff_t (now used in
  odbc_set_string_flag).

Signed-off-by: Aaron M. Ucko <[email protected]>
All could at least potentially receive updates, but they were never
consulted or even logged.  Leave some commented out rather than fully
retired for ease of reinstatement if they're helpful to examine in a
debugger.

Signed-off-by: Aaron M. Ucko <[email protected]>
Comment on lines -1542 to +1553
void tdsdump_log(const char* file, unsigned int level_line, const char *fmt, ...)
void tdsdump_do_log(const char* file, unsigned int level_line,
const char *fmt, ...)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, this is an ABI and must be exported with this name

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought tds* were generally internal; I do see that libsybdb exposes tdsdump_open, but that function's not in play here.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, usually yes. BTW, it's only tdsdump_open (and tdsdbopen) that are in ABI, so tdsdump_log can be changed.

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.

2 participants