Details

    • Task
    • Status: Open (View Workflow)
    • Minor
    • Resolution: Unresolved
    • None
    • Replication
    • None

    Description

      We use %u-%u-%llu to format GTID fields in my_/snprintf.
      But GTIDs use fixed integer sizes since merge, while %u and %llu technically varies by platform.

      We should define a platform-agnostic printf format and apply it throughout the codebase.
      It could be…

      … a macro that complements PARAM_GTID – naming candidates are:

      (I prefer the Standard style because we should phase out InnoBase’s extra typedefs in favor of standardized ones (MDEV-35460).)

      … a function – a method of rpl_gtid?

      … a custom my_snprintf format extension – %pG?

      This implementation is the only one of the three that sql/share/errmsg-utf8.txt gets to utilize.

      Attachments

        Issue Links

          Activity

            %u and %llu use sizes that we want them to use, that's why we have our own printf implementation — to have the same output independently from local libc. We can postulate that %u is 32-bit unsigned int and that %llu is 64-bit unsigned long long int. Cannot we?

            serg Sergei Golubchik added a comment - %u and %llu use sizes that we want them to use, that's why we have our own printf implementation — to have the same output independently from local libc. We can postulate that %u is 32-bit unsigned int and that %llu is 64-bit unsigned long long int. Cannot we?
            ParadoxV5 Jimmy Hú added a comment -

            %u and %llu are 32-bit and 64-bit in modern desktops and servers, yes, but not necessarily because the standards don’t enforce so. If say, someone wants to embed a client in an Arduino, their compiler would complain that our code should use %lu.

            And we can’t deviate our my_snprintf from the standards either, lest our implementation be inconsistent with GCC -Wformat (MDEV-21978), not to mention that C sprintf also uses %u-%u-%llu.

            ParadoxV5 Jimmy Hú added a comment - %u and %llu are 32-bit and 64-bit in modern desktops and servers, yes, but not necessarily because the standards don’t enforce so. If say, someone wants to embed a client in an Arduino , their compiler would complain that our code should use %lu . And we can’t deviate our my_snprintf from the standards either, lest our implementation be inconsistent with GCC -Wformat ( MDEV-21978 ), not to mention that C sprintf also uses %u-%u-%llu .

            you're right, and this is technically true. but practically I don't think MariaDB will compile anywhere where longlong isn't 64 bit and int isn't 32 bit.

            long is non-portable and can be either 32-bit or 64-bit, both will work.

            serg Sergei Golubchik added a comment - you're right, and this is technically true. but practically I don't think MariaDB will compile anywhere where longlong isn't 64 bit and int isn't 32 bit. long is non-portable and can be either 32-bit or 64-bit, both will work.
            ParadoxV5 Jimmy Hú added a comment -

            rpl_gtid::seq_no currently uses uint64 which is defined as ulonglong, so it doesn’t matter currently,
            However, if MDEV-35460 replaces uint64 with uint64_t, we’ll get -Wformat warnings on Linux because their uint64_t is unsigned long.

            ParadoxV5 Jimmy Hú added a comment - rpl_gtid::seq_no currently uses uint64 which is defined as ulonglong , so it doesn’t matter currently, However, if MDEV-35460 replaces uint64 with uint64_t , we’ll get -Wformat warnings on Linux because their uint64_t is unsigned long .

            People

              Unassigned Unassigned
              ParadoxV5 Jimmy Hú
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:

                Git Integration

                  Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.