snowflakedb / pdo_snowflake Goto Github PK
View Code? Open in Web Editor NEWPHP PDO driver for snowflake
License: Apache License 2.0
PHP PDO driver for snowflake
License: Apache License 2.0
We want to be consistent and so we're using the SF_ designation.
When connecting to Snowflake, session parameters, e.g., autocommit, timezone, etc, can be specified.
Apparently sticking to C89 is pain as we implicitly use convenient C99 features.
__VA_ARGS__
macro in logger//
If I add -std=c89
, bunch of errors show up, and some are very difficult to update.
The main concern was C99 code would not be compiled by Visual Studio, but it appeared VS 2015 already has most of C99 features and even C++11.
https://msdn.microsoft.com/en-us/library/hh409293.aspx
Maybe we should change the policy.
Honestly I underestimated C89 limitation. It just reminds me painful old days.
Agreed to use four space tabs and braces at the end style.
In order for the tests to run concurrently, each job should use different schema.
DML should return the number of affected rows.
Goal
We need to be able to renew a client session in the background without any input from the client.
Need to integrate Snowflake Connector for C logger with PDO.
And PHP ini can specify the log file name and severity.
Goal
TBD:
Someone (Saber or Markus) mentioned to me that this would be a nice feature in the C API. I think this would be a relatively trivial addition and quite convenient for developers who use the C API. I see two options for this:
(My first choice) We add a number of parameters field to the binding functions that will tell us if someone passes in a single binding structs or an array of structs.
(An alternative) Create new functions called "snowflake_bind_(input|output)_array" that deal with binding arrays of binding structs.
As we have more test cases as examples, we need better test framework and runners to run tests automatically, detect and aggregate errors.
I'm thinking of adding either one of them:
https://libcheck.github.io/check/doc/check_html/
https://cmocka.org/
Not v1.0 but future version.
Due to the fix for #35, all parameters are cleared in query/prepare.
This prevents from setting the statement attribute before query.
So far SF_STATE_WARNING is not used, and if no use case is given, let's remove it for now.
Later if we need it, we can add it.
Goal
select seq8(), randstr(100, random()) from table(generator(rowcount=>1000000))
and fetch results.Goal
Snowflake Connector's error should be propagated to PDO better.
When binding columns/results, max length is provided by the application, but it doesn't necessarily the actual length of value and value may not be null terminated, so SF_BIND_OUTPUT needs len member so that Snowflake client can set it for the application.
Binding parameters is similar. The applications should be able to specify the length.
Goals
Goal
Bind parameters is not working. Fixing.
We should run Snowflake Connector for C tests on TravisCI.
better to make SNOWFLAKE_STMT structure reusable such that the applications won't need to recreate it on every needs.
Mostly the code assumes the string data are null terminated. What if NULL is included in the data?
This issue is to add a test case including NULL with appropriate fixes if need.
Looks like we may be able to support named binding.
Ideally only one header should be exposed without namespace conflict. The following changes are required:
The value 0 is reserved for no error. All other value indicates error.
By default, PHP CLI allows the uses to interrupt a script by Ctrl+C. A problem is it leaks lot of memory. Is there any way to gracefully free all memory?
Note this could be PHP fundamental issue. Need further investigation.
snowflake_close is to close a session.
snowflake_term is to wipe out the SNOWFLAKE context.
I don't think we need to separate those two function calls but one should be good enough.
Following the steps in the readme i'm encountering the following error. This is a terrible bug report (Sorry) because I don't know what further details to provide.
I successfully built PHP and cloned pdo_snowflake
I did also try omitting -r
which (unsurpisingly, I guess) failed on clang: error: no such file or directory: 'libsnowflakeclient/cmake-build/libsnowflakeclient.a'
-- The C compiler identification is AppleClang 7.3.0.7030031
-- The CXX compiler identification is AppleClang 7.3.0.7030031
-- Check for working C compiler: /Library/Developer/CommandLineTools/usr/bin/cc
-- Check for working C compiler: /Library/Developer/CommandLineTools/usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /Library/Developer/CommandLineTools/usr/bin/c++
-- Check for working CXX compiler: /Library/Developer/CommandLineTools/usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
libcurl is located at /usr/local/lib/libcurl.a
libssl is located at /Users/ntaylor/src/pdo_snowflake/libsnowflakeclient/deps-build/linux/openssl/lib/libssl.a
libcrypto is located at /Users/ntaylor/src/pdo_snowflake/libsnowflakeclient/deps-build/linux/openssl/lib/libcrypto.a
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/ntaylor/src/pdo_snowflake/libsnowflakeclient/cmake-build
/usr/local/Cellar/cmake/3.7.1/bin/cmake -H/Users/ntaylor/src/pdo_snowflake/libsnowflakeclient -B/Users/ntaylor/src/pdo_snowflake/libsnowflakeclient/cmake-build --check-build-system CMakeFiles/Makefile.cmake 0
/usr/local/Cellar/cmake/3.7.1/bin/cmake -E cmake_progress_start /Users/ntaylor/src/pdo_snowflake/libsnowflakeclient/cmake-build/CMakeFiles /Users/ntaylor/src/pdo_snowflake/libsnowflakeclient/cmake-build/CMakeFiles/progress.marks
/Library/Developer/CommandLineTools/usr/bin/make -f CMakeFiles/Makefile2 all
/Library/Developer/CommandLineTools/usr/bin/make -f CMakeFiles/snowflakeclient.dir/build.make CMakeFiles/snowflakeclient.dir/depend
cd /Users/ntaylor/src/pdo_snowflake/libsnowflakeclient/cmake-build && /usr/local/Cellar/cmake/3.7.1/bin/cmake -E cmake_depends "Unix Makefiles" /Users/ntaylor/src/pdo_snowflake/libsnowflakeclient /Users/ntaylor/src/pdo_snowflake/libsnowflakeclient /Users/ntaylor/src/pdo_snowflake/libsnowflakeclient/cmake-build /Users/ntaylor/src/pdo_snowflake/libsnowflakeclient/cmake-build /Users/ntaylor/src/pdo_snowflake/libsnowflakeclient/cmake-build/CMakeFiles/snowflakeclient.dir/DependInfo.cmake --color=
Scanning dependencies of target snowflakeclient
/Library/Developer/CommandLineTools/usr/bin/make -f CMakeFiles/snowflakeclient.dir/build.make CMakeFiles/snowflakeclient.dir/build
[ 1%] Building C object CMakeFiles/snowflakeclient.dir/lib/client.c.o
/Library/Developer/CommandLineTools/usr/bin/cc -DLOG_USE_COLOR -I/Users/ntaylor/src/pdo_snowflake/libsnowflakeclient/deps-build/linux/curl/include -I/Users/ntaylor/src/pdo_snowflake/libsnowflakeclient/deps-build/linux/openssl/include -I/Users/ntaylor/src/pdo_snowflake/libsnowflakeclient/include -g -pthread -fPIC -Werror -std=gnu90 -o CMakeFiles/snowflakeclient.dir/lib/client.c.o -c /Users/ntaylor/src/pdo_snowflake/libsnowflakeclient/lib/client.c
In file included from /Users/ntaylor/src/pdo_snowflake/libsnowflakeclient/lib/client.c:17:
/Users/ntaylor/src/pdo_snowflake/libsnowflakeclient/lib/connection.h:338:46: error: duplicate 'const' declaration specifier [-Werror,-Wduplicate-decl-specifier]
ARRAY_LIST *json_get_object_keys(const cJSON const *item);
^~~~~~
1 error generated.
make[2]: *** [CMakeFiles/snowflakeclient.dir/lib/client.c.o] Error 1
make[1]: *** [CMakeFiles/snowflakeclient.dir/all] Error 2
make: *** [all] Error 2```
Goal
It is better the application can provide memory alloc hooks.
Goal:
select count(*) from table(generator(timelimit=>60))
successfullyThis requires to ping result every N seconds.
PHP has its own memory management APIs, i.e., ecalloc, efree, etc, so that allocated memories will be freed up in the end of request if it wants.
However, when a connection is not closed, while all memories allocated by PDO layers will be freed automatically, the memories in Snowflake Client layer won't be, because those memories are allocated SF_CALLOC and SF_FREE that currently simple mapping to the system functions calloc and free. This will yield memory leak.
Snowflake Client/Connector should have a mode that does similar to PHP memory manager such that the memories are automatically freed in each of snowflake_*term function calls.
added
diff --git a/libsnowflakeclient/CMakeLists.txt b/libsnowflakeclient/CMakeLists.txt
index 678c194..8b24362 100644
--- a/libsnowflakeclient/CMakeLists.txt
+++ b/libsnowflakeclient/CMakeLists.txt
@@ -8,7 +8,7 @@ project(snowflakeclient)
add_definitions(-DLOG_USE_COLOR)
set(CMAKE_VERBOSE_MAKEFILE ON)
-set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -pthread -fPIC -Wall")
+set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -pg -pthread -fPIC -Wall")
set(SOURCE_FILES
include
and ran ex_large_result_set
and found
Flat profile:
Each sample counts as 0.01 seconds.
% cumulative self self total
time seconds seconds calls ms/call ms/call name
99.93 178.88 178.88 199693 0.90 0.90 cJSON_GetArraySize
0.02 178.91 0.03 199738 0.00 0.00 cJSON_DetachItemViaPointer
0.02 178.94 0.03 199723 0.00 0.90 snowflake_fetch
0.01 178.96 0.02 199746 0.00 0.00 clear_snowflake_error
0.01 178.97 0.01 399516 0.00 0.00 array_list_get
0.01 178.98 0.01 399377 0.00 0.00 get_array_item
0.01 178.99 0.01 181966 0.00 0.00 parse_array
0.00 179.00 0.01 364887 0.00 0.00 cJSON_New_Item
0.00 179.00 0.01 cJSON_InitHooks
...
Since cJSON_GetArraySize
is used to check if the size of result is 0 or not, it can be simplified.
Markus found 2 bugs in the chunk downloader code:
The chunk_downloader_term function either returns false or unknown value. It should return true on success.
The signature of the json_get_object_keys function is 'const cJSON const *item' when it should be 'const cJSON * const item'.
We should also compile with '-Werror' (at least with libsnowflakeclient) to turn warnings into errors.
Aside from a pointer to the command/SQL text, a SQL length parameter is required.
stmt->desc should be returned by a function.
In order to get the metadata for fetched data, we need to have a function snowflake_stmt_desc to return SF_COLUMN_DESC.
Numeric values over precision 18 won't fit into int64. We may need to considering support __128int, decimal128, etc.
We use our own cacerts as often the system's ca certs are not reliable.
When bundling the cacert.pem, there are couple of options:
In either case, the applications should be able to reconfigure the cacert.pem
Goal:
select 1
.A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.