Yes i am aware of that, but my question here is, how can i get to know when the connection is down and then when it is back up.
I need this so i could lock down the server when the connection is out so that people who should be blocked, not to join. |
public OnGameModeInit() { g_MySQL = mysql_connect(...); SetTimer("MySqlConnectionCheck", 5000, true); return 1; } forward MySqlConnectionCheck(); public MySqlConnectionCheck() { mysql_query(g_MySQL, "SELECT 1", false); if(mysql_errno() != 0) { //error, probably related to network connection } return 1; }
i dont really understand that ORM thing, I learnt SQL pretty well. Can anyone give me a_mysql where queries can be done?
|
I'm getting error related to KERNEL32.dll, which doesn't support Windows server 2003 and Windows XP. I've tried to use all the possible versions to download from the github, could you please upload R37 and older versions? Thanks.
|
SELECT * FROM (
SELECT achievements.userid as a_uid, users.userid as u_uid FROM achievements LEFT JOIN users ON achievements.userid = users.userid) as temp
WHERE u_uid IS NULL
SELECT COUNT(ip) FROM some_table WHERE ip BETWEEN INET_ATON('45.166.0.0') AND INET_ATON('45.166.255.255');
SELECT COUNT(ip) FROM some_table WHERE INET_NTOA(ip) LIKE '45.166.%';
I've been reading a lot of articles and documentation for optimization and I've discovered INET_ATON and INET_NTOA few days ago. Saving IPs as an integer (UNSIGNED) saves a lot of space but I was wondering which one is better
pawn Код:
pawn Код:
|
explain SELECT COUNT(ip) FROM some_table WHERE ip BETWEEN INET_ATON('45.166.0.0') AND INET_ATON('45.166.255.255');
//and
explain SELECT COUNT(ip) FROM some_table WHERE INET_NTOA(ip) LIKE '45.166.%';
I've been reading a lot of articles and documentation for optimization and I've discovered INET_ATON and INET_NTOA few days ago. Saving IPs as an integer (UNSIGNED) saves a lot of space but I was wondering which one is better
pawn Код:
pawn Код:
|
SELECT country FROM iptable WHERE INET_ATON('x.x.x.x') BETWEEN range_start and range_end
I would think that the first one would be faster since inet_aton returns a integer. But something i just found out is you can add "explain" to the beginning of your query and it returns some helpful info.
pawn Код:
|
Personally, I use the first one. But it must be noted that I select it from a humongous table which contains all CIDR ranges around the world, so the query usually looks something like:
PHP код:
|
[root@localhost build]# cmake .. -- The C compiler identification is GNU 4.4.7 -- The CXX compiler identification is GNU 4.4.7 -- Check for working C compiler: /usr/bin/cc -- Check for working C compiler: /usr/bin/cc -- works -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done -- Check for working CXX compiler: /usr/bin/c++ -- Check for working CXX compiler: /usr/bin/c++ -- works -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Performing Test COMPILER_SUPPORTS_CXX11 -- Performing Test COMPILER_SUPPORTS_CXX11 - Failed CMake Error at CMakeLists.txt:74 (message): The compiler /usr/bin/c++ does not fulfill all required standards. Please use a different C++ compiler. -- Configuring incomplete, errors occurred! See also "/home/kasutaja/Desktop/mysql/SA-MP-MySQL-master/build/CMakeFiles/CMakeOutput.log". See also "/home/kasutaja/Desktop/mysql/SA-MP-MySQL-master/build/CMakeFiles/CMakeError.log". [root@localhost build]# cmake --version cmake version 2.8.12.2 [root@localhost build]# /opt/rh/devtoolset-2/root/usr/bin/gcc --version gcc (GCC) 4.8.2 20140120 (Red Hat 4.8.2-15) Copyright © 2013 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Performing C++ SOURCE FILE Test COMPILER_SUPPORTS_CXX11 failed with the following output: Change Dir: /home/kasutaja/Desktop/mysql/SA-MP-MySQL-master/build/CMakeFiles/CMakeTmp Run Build Command:/usr/bin/gmake "cmTryCompileExec1377417873/fast" /usr/bin/gmake -f CMakeFiles/cmTryCompileExec1377417873.dir/build.make CMakeFiles/cmTryCompileExec1377417873.dir/build gmake[1]: Entering directory `/home/kasutaja/Desktop/mysql/SA-MP-MySQL-master/build/CMakeFiles/CMakeTmp' /usr/bin/cmake -E cmake_progress_report /home/kasutaja/Desktop/mysql/SA-MP-MySQL-master/build/CMakeFiles/CMakeTmp/CMakeFiles 1 Building CXX object CMakeFiles/cmTryCompileExec1377417873.dir/src.cxx.o /usr/bin/c++ -m32 -std=c++11 -DCOMPILER_SUPPORTS_CXX11 -o CMakeFiles/cmTryCompileExec1377417873.dir/src.cxx.o -c /home/kasutaja/Desktop/mysql/SA-MP-MySQL-master/build/CMakeFiles/CMakeTmp/src.cxx cc1plus: error: unrecognized command line option "-std=c++11" gmake[1]: Leaving directory `/home/kasutaja/Desktop/mysql/SA-MP-MySQL-master/build/CMakeFiles/CMakeTmp' gmake[1]: *** [CMakeFiles/cmTryCompileExec1377417873.dir/src.cxx.o] Error 1 gmake: *** [cmTryCompileExec1377417873/fast] Error 2 Source file was: #include <tuple> #include <functional> #include <unordered_map> #include <forward_list> #include <string> class CTest { public: CTest() = default; ~CTest() = default; CTest(const CTest &rhs) = delete; CTest(CTest &&mv) { m_Num = mv.m_Num; m_NumPtr = mv.m_NumPtr; } int m_Num = 42; int *m_NumPtr = nullptr; std::unordered_map<std::string, int> m_Map; std::forward_list<int> m_ForwardList; }; int main(void) { int RefVar = 123; std::tuple< int, std::function<bool(int, int&)>> MyTuple( 42, [&RefVar](int num1, int &sub_ref) { RefVar += num1; sub_ref += RefVar; return true; } ); enum class StronglyTypedEnum { ENUM_VAR1, ENUM_VAR2 }; CTest test_class; return 0; }
[root@localhost build]# cmake --DCMAKE_C_COMPILER=/opt/rh/devtoolset-2/root/usr/bin/gcc -DCMAKE_CXX_COMPILER=/opt/rh/devtoolset-2/root/usr/bin/g++ .. CMake Error at CMakeLists.txt:74 (message): The compiler /opt/rh/devtoolset-2/root/usr/bin/g++ does not fulfill all required standards. Please use a different C++ compiler. -- Configuring incomplete, errors occurred! See also "/home/kasutaja/Desktop/mysql/SA-MP-MySQL-master/build/CMakeFiles/CMakeOutput.log". See also "/home/kasutaja/Desktop/mysql/SA-MP-MySQL-master/build/CMakeFiles/CMakeError.log". You have changed variables that require your cache to be deleted. Configure will be re-run and you may have to reset some variables. The following variables have changed: CMAKE_CXX_COMPILER= /opt/rh/devtoolset-2/root/usr/bin/g++ -- Generating done -- Build files have been written to: /home/kasutaja/Desktop/mysql/SA-MP-MySQL-master/build
Compiling the CXX compiler identification source file "CMakeCXXCompilerId.cpp" failed. Compiler: /opt/rh/devtoolset-2/root/usr/bin/g++ Build flags: Id flags: The output was: No such file or directory Compiling the CXX compiler identification source file "CMakeCXXCompilerId.cpp" failed. Compiler: /opt/rh/devtoolset-2/root/usr/bin/g++ Build flags: Id flags: -c The output was: No such file or directory Checking whether the CXX compiler is IAR using "" did not match "IAR .+ Compiler": Determining if the CXX compiler works failed with the following output: Compiling the CXX compiler identification source file "CMakeCXXCompilerId.cpp" failed. Compiler: /opt/rh/devtoolset-2/root/usr/bin/g++ Build flags: Id flags: The output was: No such file or directory Compiling the CXX compiler identification source file "CMakeCXXCompilerId.cpp" failed. Compiler: /opt/rh/devtoolset-2/root/usr/bin/g++ Build flags: Id flags: -c The output was: No such file or directory Checking whether the CXX compiler is IAR using "" did not match "IAR .+ Compiler": Determining if the CXX compiler works failed with the following output: Performing C++ SOURCE FILE Test COMPILER_SUPPORTS_CXX11 failed with the following output: Change Dir: /home/kasutaja/Desktop/mysql/SA-MP-MySQL-master/build/CMakeFiles/CMakeTmp Run Build Command:/usr/bin/gmake "cmTryCompileExec222989886/fast" /usr/bin/gmake -f CMakeFiles/cmTryCompileExec222989886.dir/build.make CMakeFiles/cmTryCompileExec222989886.dir/build gmake[1]: Entering directory `/home/kasutaja/Desktop/mysql/SA-MP-MySQL-master/build/CMakeFiles/CMakeTmp' /usr/bin/cmake -E cmake_progress_report /home/kasutaja/Desktop/mysql/SA-MP-MySQL-master/build/CMakeFiles/CMakeTmp/CMakeFiles 1 Building CXX object CMakeFiles/cmTryCompileExec222989886.dir/src.cxx.o /opt/rh/devtoolset-2/root/usr/bin/g++ -m32 -std=c++11 -DCOMPILER_SUPPORTS_CXX11 -o CMakeFiles/cmTryCompileExec222989886.dir/src.cxx.o -c /home/kasutaja/Desktop/mysql/SA-MP-MySQL-master/build/CMakeFiles/CMakeTmp/src.cxx Linking CXX executable cmTryCompileExec222989886 /usr/bin/cmake -E cmake_link_script CMakeFiles/cmTryCompileExec222989886.dir/link.txt --verbose=1 /opt/rh/devtoolset-2/root/usr/bin/g++ -m32 -std=c++11 -DCOMPILER_SUPPORTS_CXX11 CMakeFiles/cmTryCompileExec222989886.dir/src.cxx.o -o cmTryCompileExec222989886 -rdynamic /opt/rh/devtoolset-2/root/usr/libexec/gcc/x86_64-redhat-linux/4.8.2/ld: cannot find /usr/lib/libstdc++.so.6 /opt/rh/devtoolset-2/root/usr/libexec/gcc/x86_64-redhat-linux/4.8.2/ld: skipping incompatible /opt/rh/devtoolset-2/root/usr/lib/gcc/x86_64-redhat-linux/4.8.2/libstdc++_nonshared.a when searching for -lstdc++_nonshared /opt/rh/devtoolset-2/root/usr/libexec/gcc/x86_64-redhat-linux/4.8.2/ld: cannot find -lstdc++_nonshared /opt/rh/devtoolset-2/root/usr/libexec/gcc/x86_64-redhat-linux/4.8.2/ld: cannot find /lib/libgcc_s.so.1 collect2: error: ld returned 1 exit status gmake[1]: Leaving directory `/home/kasutaja/Desktop/mysql/SA-MP-MySQL-master/build/CMakeFiles/CMakeTmp' gmake[1]: *** [cmTryCompileExec222989886] Error 1 gmake: *** [cmTryCompileExec222989886/fast] Error 2
@Typhome
Looks like you are compiling the wrong brach. R39-3 is located here: https://github.com/pBlueG/SA-MP-MySQL/tree/issue-54 and does't require cmake. |
Thank you. I've downloaded CentOS 6.6 32-bit (so I don't have to mess with 32 and 64 bit librarys).
I've downloaded all needed packages (like mysql, groupinstall "Development Tools", boost, etc). When I go to project directory and do command "make" then I'll get only errors. make output: http://pastebin.com/QAcCwHAK // Fixed by downloading sampgdk (it wasn't included when I was downloading the ZIP on mysql project github). After that I'm still experiencing errors: http://pastebin.com/SExhpsii // I did "yum install mysql-devel" and again "make", then got compiled. ![]() // Also libboost must be properly installed (/usr/lib). |
Can you post precisely what you did?
I am getting this error; CMake Error at /usr/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:108 (message): Could NOT find SAMPSDK (missing: SAMPSDK_DIR SAMPSDK_INCLUDE_DIR) Call Stack (most recent call first): /usr/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:315 (_FPHSA_FAILURE_MESSAGE) cmake/FindSAMPSDK.cmake:21 (find_package_handle_standard_args) CMakeLists.txt:30 (find_package) |
Could NOT find SAMPSDK (missing: SAMPSDK_DIR SAMPSDK_INCLUDE_DIR)
GPP=g++ -m32 GCC=gcc -m32 COMPILE_FLAGS = -c -O3 -w -fPIC -DLINUX -Wall -I libs/ -I libs/sdk/amx/ LIBRARIES = -pthread -lrt -Wl,-Bstatic -lboost_thread -lboost_chrono -lboost_date_time -lboost_system -lboost_atomic -Wl,-Bdynamic all: compile dynamic_link static_link clean dynamic: compile dynamic_link clean static: compile static_link clean compile: @mkdir -p bin @echo Compiling plugin.. @ $(GPP) $(COMPILE_FLAGS) -std=c++0x src/*.cpp @echo Compiling plugin SDK.. @ $(GPP) $(COMPILE_FLAGS) libs/sdk/*.cpp @ $(GCC) $(COMPILE_FLAGS) libs/sdk/amx/*.c dynamic_link: @echo Linking \(dynamic\).. @ $(GPP) -O2 -fshort-wchar -shared -o "bin/mysql.so" *.o -L/usr/lib/mysql/libmysqlclient_r.so $(LIBRARIES) static_link: @echo Linking \(static\).. @ $(GPP) -O2 -fshort-wchar -shared -o "bin/mysql_static.so" *.o -Wl,-Bstatic -L/usr/lib/mysql/libmysqlclient_r.so -Wl,-Bdynamic $(LIBRARIES) clean: @ rm -f *.o @echo Done.
[root@localhost SA-MP-MySQL-R39-3]# cd bin [root@localhost bin]# ls -al total 1080 drwxr-xr-x. 2 root root 4096 Jun 25 02:02 . drwxr-xr-x. 7 root root 4096 Jun 25 02:05 .. -rwxr-xr-x. 1 root root 547152 Jun 25 02:02 mysql.so -rwxr-xr-x. 1 root root 547152 Jun 25 02:02 mysql_static.so
Код:
Could NOT find SAMPSDK (missing: SAMPSDK_DIR SAMPSDK_INCLUDE_DIR) Actually I haven't got correct mysql_static plugin, because size is only circa 540kB. I don't know why compiler won't include libmysql. https://www.upload.ee/files/4799154/...static.so.html https://www.upload.ee/files/4799153/mysql.so.html makefile: Код:
GPP=g++ -m32 GCC=gcc -m32 COMPILE_FLAGS = -c -O3 -w -fPIC -DLINUX -Wall -I libs/ -I libs/sdk/amx/ LIBRARIES = -pthread -lrt -Wl,-Bstatic -lboost_thread -lboost_chrono -lboost_date_time -lboost_system -lboost_atomic -Wl,-Bdynamic all: compile dynamic_link static_link clean dynamic: compile dynamic_link clean static: compile static_link clean compile: @mkdir -p bin @echo Compiling plugin.. @ $(GPP) $(COMPILE_FLAGS) -std=c++0x src/*.cpp @echo Compiling plugin SDK.. @ $(GPP) $(COMPILE_FLAGS) libs/sdk/*.cpp @ $(GCC) $(COMPILE_FLAGS) libs/sdk/amx/*.c dynamic_link: @echo Linking \(dynamic\).. @ $(GPP) -O2 -fshort-wchar -shared -o "bin/mysql.so" *.o -L/usr/lib/mysql/libmysqlclient_r.so $(LIBRARIES) static_link: @echo Linking \(static\).. @ $(GPP) -O2 -fshort-wchar -shared -o "bin/mysql_static.so" *.o -Wl,-Bstatic -L/usr/lib/mysql/libmysqlclient_r.so -Wl,-Bdynamic $(LIBRARIES) clean: @ rm -f *.o @echo Done. Код:
[root@localhost SA-MP-MySQL-R39-3]# cd bin [root@localhost bin]# ls -al total 1080 drwxr-xr-x. 2 root root 4096 Jun 25 02:02 . drwxr-xr-x. 7 root root 4096 Jun 25 02:05 .. -rwxr-xr-x. 1 root root 547152 Jun 25 02:02 mysql.so -rwxr-xr-x. 1 root root 547152 Jun 25 02:02 mysql_static.so |