summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVladislav Vaintroub <wlad@montyprogram.com>2011-05-12 15:39:54 +0200
committerVladislav Vaintroub <wlad@montyprogram.com>2011-05-12 15:39:54 +0200
commit984fa23b457fe0956fd118ea543467b2d2c7475e (patch)
tree87ac0f3d03fbe233f3ba5fcab00472295e58f2b5
parent84505e6e3a107e062d1caa20cf7ed63443133ef6 (diff)
parent83ce12ba699468dbb9477803a741dfaba426e7f7 (diff)
downloadmariadb-git-984fa23b457fe0956fd118ea543467b2d2c7475e.tar.gz
merge
-rwxr-xr-xCMakeLists.txt93
-rw-r--r--sql/sql_table.cc14
2 files changed, 104 insertions, 3 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 1e727080df2..4954e4a9d07 100755
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -21,7 +21,98 @@ ENDIF(COMMAND cmake_policy)
PROJECT(MySql)
# This reads user configuration, generated by configure.js.
-INCLUDE(win/configure.data)
+INCLUDE(win/configure.data OPTIONAL)
+
+MACRO(MYSQL_GET_CONFIG_VALUE keyword var)
+ IF(NOT ${var})
+ IF (EXISTS ${CMAKE_SOURCE_DIR}/configure.in)
+ FILE (STRINGS ${CMAKE_SOURCE_DIR}/configure.in str REGEX "^[ ]*${keyword}=")
+ IF(str)
+ STRING(REPLACE "${keyword}=" "" str ${str})
+ STRING(REGEX REPLACE "[ ].*" "" str ${str})
+ SET(${var} ${str} CACHE INTERNAL "Config variable")
+ ENDIF()
+ ENDIF()
+ ENDIF()
+ENDMACRO()
+
+
+# Read mysql version for configure script
+
+MACRO(GET_MYSQL_VERSION)
+ IF(NOT VERSION_STRING)
+ IF(EXISTS ${CMAKE_SOURCE_DIR}/configure.in)
+ FILE(STRINGS ${CMAKE_SOURCE_DIR}/configure.in str REGEX "AM_INIT_AUTOMAKE")
+ STRING(REGEX MATCH "[0-9]+\\.[0-9]+\\.[0-9]+[-][^ \\)]+" VERSION_STRING "${str}")
+ IF(NOT VERSION_STRING)
+ STRING(REGEX MATCH "[0-9]+\\.[0-9]+\\.[0-9]+" VERSION_STRING "${str}")
+ IF(NOT VERSION_STRING)
+ FILE(STRINGS configure.in str REGEX "AC_INIT\\(")
+ STRING(REGEX MATCH "[0-9]+\\.[0-9]+\\.[0-9]+[-][a-zA-Z0-9]+" VERSION_STRING "${str}")
+ IF(NOT VERSION_STRING)
+ STRING(REGEX MATCH "[0-9]+\\.[0-9]+\\.[0-9]+" VERSION_STRING "${str}")
+ ENDIF()
+ ENDIF()
+ ENDIF()
+ ENDIF()
+ ENDIF()
+
+ IF(NOT VERSION_STRING)
+ MESSAGE(FATAL_ERROR
+ "VERSION_STRING cannot be parsed, please specify -DVERSION_STRING=major.minor.patch-extra"
+ "when calling cmake")
+ ENDIF()
+
+ SET(VERSION ${VERSION_STRING})
+ STRING(REPLACE "-" "_" MYSQL_U_SCORE_VERSION "${VERSION_STRING}")
+
+ # Remove trailing (non-numeric) part of the version string
+ STRING(REGEX REPLACE "[^\\.0-9].*" "" VERSION_STRING ${VERSION_STRING})
+
+ STRING(REGEX REPLACE "([0-9]+)\\.[0-9]+\\.[0-9]+" "\\1" MAJOR_VERSION "${VERSION_STRING}")
+ STRING(REGEX REPLACE "[0-9]+\\.([0-9]+)\\.[0-9]+" "\\1" MINOR_VERSION "${VERSION_STRING}")
+ STRING(REGEX REPLACE "[0-9]+\\.[0-9]+\\.([0-9]+)" "\\1" PATCH "${VERSION_STRING}")
+ SET(MYSQL_BASE_VERSION "${MAJOR_VERSION}.${MINOR_VERSION}" CACHE INTERNAL "MySQL Base version")
+ SET(MYSQL_NO_DASH_VERSION "${MAJOR_VERSION}.${MINOR_VERSION}.${PATCH}")
+ MATH(EXPR MYSQL_VERSION_ID "10000*${MAJOR_VERSION} + 100*${MINOR_VERSION} + ${PATCH}")
+ MARK_AS_ADVANCED(VERSION MYSQL_VERSION_ID MYSQL_BASE_VERSION)
+ SET(CPACK_PACKAGE_VERSION_MAJOR ${MAJOR_VERSION})
+ SET(CPACK_PACKAGE_VERSION_MINOR ${MINOR_VERSION})
+ SET(CPACK_PACKAGE_VERSION_PATCH ${PATCH})
+ENDMACRO()
+
+# Get mysql version and other interesting variables
+GET_MYSQL_VERSION()
+
+MYSQL_GET_CONFIG_VALUE("PROTOCOL_VERSION" PROTOCOL_VERSION)
+MYSQL_GET_CONFIG_VALUE("DOT_FRM_VERSION" DOT_FRM_VERSION)
+MYSQL_GET_CONFIG_VALUE("MYSQL_TCP_PORT_DEFAULT" MYSQL_TCP_PORT_DEFAULT)
+MYSQL_GET_CONFIG_VALUE("MYSQL_UNIX_ADDR_DEFAULT" MYSQL_UNIX_ADDR_DEFAULT)
+MYSQL_GET_CONFIG_VALUE("SHARED_LIB_MAJOR_VERSION" SHARED_LIB_MAJOR_VERSION)
+IF(NOT MYSQL_TCP_PORT_DEFAULT)
+ SET(MYSQL_TCP_PORT_DEFAULT "3306")
+ENDIF()
+IF(NOT MYSQL_TCP_PORT)
+ SET(MYSQL_TCP_PORT ${MYSQL_TCP_PORT_DEFAULT})
+ SET(MYSQL_TCP_PORT_DEFAULT "0")
+ELSEIF(MYSQL_TCP_PORT EQUAL MYSQL_TCP_PORT_DEFAULT)
+ SET(MYSQL_TCP_PORT_DEFAULT "0")
+ENDIF()
+
+
+IF(NOT MYSQL_UNIX_ADDR)
+ SET(MYSQL_UNIX_ADDR "/tmp/mysql.sock")
+ENDIF()
+IF(NOT COMPILATION_COMMENT)
+ SET(COMPILATION_COMMENT "Source distribution")
+ENDIF()
+
+SET(WITH_EXAMPLE_STORAGE_ENGINE TRUE)
+SET(WITH_FEDERATEDX_STORAGE_ENGINE TRUE)
+SET(WITH_PARTITION_STORAGE_ENGINE TRUE)
+SET(WITH_MARIA_STORAGE_ENGINE TRUE)
+SET(WITH_PBXT_STORAGE_ENGINE TRUE)
+SET(WITH_XTRADB_STORAGE_ENGINE TRUE)
# Hardcode support for CSV storage engine
SET(WITH_CSV_STORAGE_ENGINE TRUE)
diff --git a/sql/sql_table.cc b/sql/sql_table.cc
index d76f1a427be..feacecd40a5 100644
--- a/sql/sql_table.cc
+++ b/sql/sql_table.cc
@@ -3645,9 +3645,19 @@ bool check_table_file_presence(char *old_path,
Except case when it is the same table.
*/
char tbl50[FN_REFLEN];
+#ifdef _WIN32
+ if (check_if_legal_tablename(table_name) != 0)
+ {
+ /*
+ Check for reserved device names for which access() returns 0
+ (CON, AUX etc).
+ */
+ return FALSE;
+ }
+#endif
strxmov(tbl50, mysql_data_home, "/", db, "/", table_name, NullS);
- if (!access(fn_format(tbl50, tbl50, "", reg_ext,
- MY_UNPACK_FILENAME), F_OK) &&
+ fn_format(tbl50, tbl50, "", reg_ext, MY_UNPACK_FILENAME);
+ if (!access(tbl50, F_OK) &&
(old_path == NULL ||
strcmp(old_path, tbl50) != 0))
{