Skip to content

Commit 9ae00a1

Browse files
authored
Merge pull request mysql#15 from planetscale/piki/cherry-picks
Cherry picks from 8.0.23 -> 8.0.28
2 parents 4e6d30c + c83f148 commit 9ae00a1

File tree

9 files changed

+92
-24
lines changed

9 files changed

+92
-24
lines changed

.buildkite/hooks/pre-command

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,20 @@
11
set -eu
22

3+
TODAY=$(date +"%Y%m%d")
4+
[ -n "$TODAY" ]
5+
echo "Today = \"${TODAY}\""
6+
37
git log -25000 --format='%H' | sort > tmp-log
48
git show-ref | grep tags/mysql-8 | sort > tmp-tags
5-
export CONTAINER_SEMVER=$(join tmp-log tmp-tags | sort -k2 | tail -1 | cut -d- -f2)
9+
export CONTAINER_SEMVER=$(join tmp-log tmp-tags | sort -t. -n -k3 | tail -1 | cut -d- -f2)
10+
[ -n "$CONTAINER_SEMVER" ]
11+
export CONTAINER_SEMVER="$CONTAINER_SEMVER.$TODAY"
612
echo "Semantic version = \"${CONTAINER_SEMVER}\""
713

814
export CONTAINER_SHORT_SHA=$(git log -1 --pretty='%h')
15+
[ -n "$CONTAINER_SHORT_SHA" ]
916
echo "Short SHA = \"${CONTAINER_SHORT_SHA}\""
1017

1118
export CONTAINER_BRANCH_NAME=$(echo "$BUILDKITE_BRANCH" | sed -e 's/[\/:]/_/g')
19+
[ -n "$CONTAINER_BRANCH_NAME" ]
1220
echo "Safe branch name = \"${CONTAINER_BRANCH_NAME}\""

.buildkite/pipeline.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@ env:
1212
steps:
1313
- name: "Build mysql-server"
1414
label: ":docker: Build and package"
15-
agents:
16-
queue: "whopper"
1715
command: bash build.sh
1816
artifact_paths:
1917
- "dist/*.tar.gz"

Dockerfile.release

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,24 @@ RUN apt-get install -y \
88
libaio1 \
99
libnuma1 \
1010
libtcmalloc-minimal4 \
11-
binutils
11+
binutils \
12+
bzip2 \
13+
ca-certificates \
14+
dirmngr \
15+
gnupg \
16+
libatomic1 \
17+
libcurl4 \
18+
libdbd-mysql-perl \
19+
libwww-perl \
20+
libev4 \
21+
libjemalloc2 \
22+
procps \
23+
rsync \
24+
strace \
25+
sysstat \
26+
wget \
27+
curl \
28+
percona-toolkit
1229

1330
ADD dist/ /dist
1431

build.sh

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
set -e
44

55
if [ $(id -u) -eq 0 ]; then
6-
su bob -c ./build.sh
7-
cp build/*.tar.gz /dist/
8-
exit
6+
su bob -c ./build.sh
7+
cp build/*.tar.gz /dist/
8+
exit
99
fi
1010

1111
if [ -d build ]; then
@@ -15,27 +15,33 @@ fi
1515
mkdir build
1616
cd build
1717

18+
# The first group of build flags are from the rules file in
19+
# https://repo.mysql.com/apt/debian/pool/mysql-8.0/m/mysql-community/mysql-community_8.0.23-1debian9.debian.tar.xz
20+
# The second group are intended to speed up the build by skipping binaries
21+
# and debug symbols we don't need.
1822
cmake \
23+
-DWITH_BOOST=boost-lib \
24+
-DDOWNLOAD_BOOST=1 \
1925
-DBUILD_CONFIG=mysql_release \
2026
-DCMAKE_INSTALL_PREFIX=/usr \
21-
-DDEFAULT_CHARSET=utf8mb4 \
22-
-DDEFAULT_COLLATION=utf8mb4_unicode_ci \
23-
-DDOWNLOAD_BOOST=1 \
27+
-DSYSCONFDIR=/etc/mysql \
28+
-DMYSQL_UNIX_ADDR=/var/run/mysqld/mysqld.sock \
29+
-DWITH_INNODB_MEMCACHED=1 \
30+
-DWITH_MECAB=system \
31+
-DWITH_NUMA=ON \
32+
-DCOMPILATION_COMMENT="PlanetScale MySQL" \
33+
-DCOMPILATION_COMMENT_SERVER="PlanetScale MySQL Server" \
34+
-DREPRODUCIBLE_BUILD=OFF \
35+
\
2436
-DENABLED_PROFILING=0 \
2537
-DENABLE_DEBUG_SYNC=0 \
2638
-DENABLE_DTRACE=0 \
2739
-DENABLE_GCOV=0 \
2840
-DENABLE_GPROF=0 \
29-
-DMYSQL_UNIX_ADDR=/var/run/mysqld/mysqld.sock \
3041
-DOPTIMIZER_TRACE=0 \
31-
-DSYSCONFDIR=/etc/mysql \
32-
-DWITH_BOOST=boost-lib \
3342
-DWITH_CLIENT_PROTOCOL_TRACING=0 \
3443
-DWITH_DEBUG=0 \
3544
-DWITH_INNODB_EXTRA_DEBUG=0 \
36-
-DWITH_INNODB_MEMCACHED=1 \
37-
-DWITH_MECAB=system \
38-
-DWITH_NUMA=ON \
3945
-DWITH_ROUTER=OFF \
4046
..
4147

sql/auth/sql_security_ctx.cc

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ void Security_context::init() {
9494
m_has_drop_policy = false;
9595
m_executed_drop_policy = false;
9696
m_registration_sandbox_mode = false;
97+
m_exclude_user_from_rows_read = false;
9798
}
9899

99100
void Security_context::logout() {
@@ -816,6 +817,8 @@ void Security_context::set_user_ptr(const char *user_arg,
816817

817818
// set new user value to m_user.
818819
m_user.set(user_arg, user_arg_length, system_charset_info);
820+
821+
recheck_exclude_rows_read();
819822
}
820823

821824
/**
@@ -838,6 +841,25 @@ void Security_context::assign_user(const char *user_arg,
838841
m_user.copy(user_arg, user_arg_length, system_charset_info);
839842
else
840843
m_user.set((const char *)nullptr, 0, system_charset_info);
844+
845+
recheck_exclude_rows_read();
846+
}
847+
848+
char *rows_read_exclude_users = nullptr;
849+
850+
void Security_context::recheck_exclude_rows_read() {
851+
m_exclude_user_from_rows_read = false;
852+
if (rows_read_exclude_users) {
853+
char *copy = strdup(rows_read_exclude_users);
854+
char *saveptr, *tok;
855+
for (tok=my_strtok_r(copy, ",", &saveptr); tok; tok=my_strtok_r(NULL, ",", &saveptr)) {
856+
if (!strcmp(tok, m_user.ptr())) {
857+
m_exclude_user_from_rows_read = true;
858+
break;
859+
}
860+
}
861+
free(copy);
862+
}
841863
}
842864

843865
/**
@@ -881,7 +903,7 @@ void Security_context::set_host_ptr(const char *host_arg,
881903
/**
882904
Setter method for member m_host.
883905
884-
Copies host_arg value to the m_host if it is not null else m_user is set
906+
Copies host_arg value to the m_host if it is not null else m_host is set
885907
to empty string.
886908
887909

sql/auth/sql_security_ctx.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ class Security_context {
6262
void skip_grants(const char *user = "skip-grants user",
6363
const char *host = "skip-grants host");
6464
bool is_skip_grants_user();
65+
bool exclude_user_from_rows_read() const { return m_exclude_user_from_rows_read; }
6566

6667
/**
6768
Getter method for member m_user.
@@ -381,6 +382,9 @@ class Security_context {
381382
*/
382383
bool m_is_skip_grants_user;
383384

385+
bool m_exclude_user_from_rows_read;
386+
void recheck_exclude_rows_read();
387+
384388
bool m_executed_drop_policy;
385389
bool m_has_drop_policy;
386390
std::unique_ptr<std::function<void(Security_context *)>> m_drop_policy;

sql/protocol_classic.cc

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1332,11 +1332,17 @@ bool Protocol_classic::send_eof(uint server_status, uint statement_warn_count) {
13321332
if (has_client_capability(CLIENT_DEPRECATE_EOF) &&
13331333
(m_thd->get_command() != COM_BINLOG_DUMP &&
13341334
m_thd->get_command() != COM_BINLOG_DUMP_GTID)) {
1335-
char message[64] = "";
1336-
snprintf(message+1, sizeof(message)-1, "{\"rows_read\":%llu}", m_thd->get_stmt_da()->rows_read());
1337-
1338-
retval = net_send_ok(m_thd, server_status, statement_warn_count, 0, 0,
1339-
message, 1+strlen(message+1), true);
1335+
ulonglong rows_read = m_thd->get_stmt_da()->rows_read();
1336+
if (rows_read) {
1337+
char message[64] = "";
1338+
snprintf(message+1, sizeof(message)-1, "{\"rows_read\":%llu}", rows_read);
1339+
retval = net_send_ok(m_thd, server_status, statement_warn_count, 0, 0,
1340+
message, 1+strlen(message+1), true);
1341+
}
1342+
else {
1343+
retval = net_send_ok(m_thd, server_status, statement_warn_count, 0, 0,
1344+
NULL, 0, true);
1345+
}
13401346
}
13411347
else
13421348
retval = net_send_eof(m_thd, server_status, statement_warn_count);

sql/sys_vars.cc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1003,6 +1003,13 @@ static Sys_var_charptr Sys_my_bind_addr(
10031003
READ_ONLY NON_PERSIST GLOBAL_VAR(my_bind_addr_str), CMD_LINE(REQUIRED_ARG),
10041004
IN_FS_CHARSET, DEFAULT(MY_BIND_ALL_ADDRESSES));
10051005

1006+
extern char *rows_read_exclude_users;
1007+
static Sys_var_charptr Sys_my_rows_read_exclude_users(
1008+
"rows_read_exclude_users",
1009+
"Comma-separated list of users whose queries do not increment rows_read",
1010+
READ_ONLY NON_PERSIST GLOBAL_VAR(rows_read_exclude_users), CMD_LINE(REQUIRED_ARG),
1011+
IN_FS_CHARSET, DEFAULT(nullptr));
1012+
10061013
static Sys_var_charptr Sys_admin_addr(
10071014
"admin_address",
10081015
"IP address to bind to for service connection. Address can be an IPv4"

storage/innobase/handler/ha_innodb.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10131,7 +10131,7 @@ int ha_innobase::index_read(
1013110131
if (m_prebuilt->table->is_system_table) {
1013210132
srv_stats.n_system_rows_read.add(
1013310133
thd_get_thread_id(m_prebuilt->trx->mysql_thd), 1);
10134-
} else {
10134+
} else if (!m_user_thd->security_context()->exclude_user_from_rows_read()) {
1013510135
srv_stats.n_rows_read.add(thd_get_thread_id(m_prebuilt->trx->mysql_thd),
1013610136
1);
1013710137
m_user_thd->get_stmt_da()->inc_rows_read();
@@ -10379,7 +10379,7 @@ int ha_innobase::general_fetch(
1037910379
if (m_prebuilt->table->is_system_table) {
1038010380
srv_stats.n_system_rows_read.add(
1038110381
thd_get_thread_id(m_prebuilt->trx->mysql_thd), 1);
10382-
} else {
10382+
} else if (!m_user_thd->security_context()->exclude_user_from_rows_read()) {
1038310383
srv_stats.n_rows_read.add(thd_get_thread_id(m_prebuilt->trx->mysql_thd),
1038410384
1);
1038510385
m_user_thd->get_stmt_da()->inc_rows_read();

0 commit comments

Comments
 (0)