Giter Site home page Giter Site logo

snowflakedb / pdo_snowflake Goto Github PK

View Code? Open in Web Editor NEW
58.0 58.0 30.0 946.41 MB

PHP PDO driver for snowflake

License: Apache License 2.0

M4 1.97% JavaScript 0.44% C 45.67% PHP 25.76% CMake 0.63% Shell 6.23% C++ 15.30% Python 0.60% Dockerfile 0.38% Batchfile 3.04%
database php snowflake

pdo_snowflake's People

Contributors

fonsecas72 avatar jianshenghuang avatar mkantautas avatar sfc-gh-abhatnagar avatar sfc-gh-anavalos avatar sfc-gh-dprzybysz avatar sfc-gh-dszmolka avatar sfc-gh-dyoshinaga avatar sfc-gh-enkwate avatar sfc-gh-ext-simba-hx avatar sfc-gh-ext-simba-jl avatar sfc-gh-hchaturvedi avatar sfc-gh-hpathak avatar sfc-gh-igarish avatar sfc-gh-kdama avatar sfc-gh-kwagner avatar sfc-gh-mheavin avatar sfc-gh-mhofman avatar sfc-gh-mkeller avatar sfc-gh-mmacintyre avatar sfc-gh-pbulawa avatar sfc-gh-pfus avatar sfc-gh-skumbham avatar sfc-gh-sleslie avatar sfc-gh-sshankar avatar sfc-gh-wshangguan avatar simbagithub avatar smtakeda avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pdo_snowflake's Issues

C99 instead of C89?

Apparently sticking to C89 is pain as we implicitly use convenient C99 features.

  • __VA_ARGS__ macro in logger
  • Double slash comments //
  • Declaring variables in the middle of code instead of the beginning.

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.

Support Renew Session

We need to be able to renew a client session in the background without any input from the client.

Add logging

Need to integrate Snowflake Connector for C logger with PDO.
And PHP ini can specify the log file name and severity.

Implement Ctrl+C to stop a query support

Goal

  • Provide a signal hander for the applications to stop a query.
  • Provide an example of Ctrl+C to stop a query.

TBD:

  • Do we want to support Ctrl+C behavior by default.

Add Support for Binding Arrays of Input/Output Params

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:

  1. (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.

  2. (An alternative) Create new functions called "snowflake_bind_(input|output)_array" that deal with binding arrays of binding structs.

can we remove SF_STATE_WARNING?

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.

Add large result set support

Goal

  • Execute a query select seq8(), randstr(100, random()) from table(generator(rowcount=>1000000)) and fetch results.

Build PDO for Mac

  • Build Curl and Openssl on Mac
  • Commit the library and headers
  • Build PDO for Mac
  • Pass all existing tests.

Add len to SF_BIND_OUTPUT and SF_BIND_INPUT

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.

Review logging

Goals

  • Ensure the log includes required info for debug.
  • Ensure the log can be enabled and disabled as the customer needs.
  • Ensure the log location can be specified.
  • Ensure the log doesn't include sensitive information, i.e., password, private key

Add test case including NULL character.

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.

Reorganize headers

Ideally only one header should be exposed without namespace conflict. The following changes are required:

  • Hide cJSON data structure from public
  • Hide array_list structure from public
  • Hide uuid data structure from public.
  • Change header file name starting with "snowflake_" to avoid header name conflict.
  • Change public macro, constant values and function names starting with "SF_", "sf_" or "snowflake_"
  • Move all other private use headers from the public include folder to internal folder.

Support Ctrl+C well

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.

error: duplicate 'const' declaration specifier [-Werror,-Wduplicate-decl-specifier]

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```

Implement PingPong

Goal:

  • Execute select count(*) from table(generator(timelimit=>60)) successfully

This requires to ping result every N seconds.

Snowflake Client needs auto free memory mode.

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.

Performance tuning on snowflake_fetch

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.

Chunk Downloader Bugs

Markus found 2 bugs in the chunk downloader code:

  1. The chunk_downloader_term function either returns false or unknown value. It should return true on success.

  2. The signature of the json_get_object_keys function is 'const cJSON const *item' when it should be 'const cJSON * const item'.

  3. We should also compile with '-Werror' (at least with libsnowflakeclient) to turn warnings into errors.

Build PDO for Windows

  • Build Curl and Openssl for Windows
  • Commit library and headers
  • Build PDO for Windows
  • Pass all existing tests

CA certs

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:

  • Bundle in the package so that the installer puts cacert.pem and add the config.
  • Transform cacert.pem into a large string so that the code can parse on memory.

In either case, the applications should be able to reconfigure the cacert.pem

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.