{"id":22865553,"url":"https://github.com/tecfu/udf_json_rate_converter","last_synced_at":"2025-03-31T09:47:20.846Z","repository":{"id":20284913,"uuid":"23558258","full_name":"tecfu/udf_json_rate_converter","owner":"tecfu","description":"Returns high or low number from a JSON array string.","archived":false,"fork":false,"pushed_at":"2014-09-01T23:31:46.000Z","size":204,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-06T14:32:05.647Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tecfu.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-09-01T23:11:27.000Z","updated_at":"2014-09-01T23:14:41.000Z","dependencies_parsed_at":"2022-08-21T20:20:39.125Z","dependency_job_id":null,"html_url":"https://github.com/tecfu/udf_json_rate_converter","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tecfu%2Fudf_json_rate_converter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tecfu%2Fudf_json_rate_converter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tecfu%2Fudf_json_rate_converter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tecfu%2Fudf_json_rate_converter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tecfu","download_url":"https://codeload.github.com/tecfu/udf_json_rate_converter/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246450403,"owners_count":20779406,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-12-13T11:37:36.730Z","updated_at":"2025-03-31T09:47:20.791Z","avatar_url":"https://github.com/tecfu.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"mysql_udf_json_rate_converter\n=============================\n\nMySQL user defined function that calculates hi and low value in a numeric JSON array\n\nRequires libjansson:\n\n```\napt-get install libjansson-dev\n```\n\n# Compiling:\n\n[1] COMPILE main.c to udf_json_rate_converter.so\n\n```\ngcc -fPIC -Wall -c -g -I/usr/local/lib -I/usr/include/mysql -I/usr/local/include -fPIC -Wall -MMD -MP -MF build/Debug/GNU-Linux-x86/main.o.d -o build/Debug/GNU-Linux-x86/main.o main.c\ngcc -fPIC -Wall -o dist/Debug/GNU-Linux-x86/udf_json_rate_converter.so build/Debug/GNU-Linux-x86/main.o  -shared -ljansson\n```\n\n### Compilation Notes:\n\n- Include Directories\n```\nmysql.h jansson.h\n```\n\n- Linker Options\n```\n -shared -ljansson\n```\n\n- What the flags do:\n\n```\n-fPIC\n```\nIf supported for the target machine, emit position-independent code, suitable for dynamic linking and avoiding any limit on the size of the global offset table. This option makes a difference on the m68k, PowerPC and SPARC.\nPosition-independent code requires special support, and therefore works only on certain machines.\n\nWhen this flag is set, the macros __pic__ and __PIC__ are defined to 2. \n\n```\n-Wall\n```\nThis enables all the warnings about constructions that some users consider questionable, and that are easy to avoid (or modify to prevent the warning), even in conjunction with macros. This also enables some language-specific warnings described in C++ Dialect Options and Objective-C and Objective-C++ Dialect Options.\n\n\n\n\n# Installation:\n\n## [1] MOVE .so file to mysql plugins directory:\n\n//TO GET PATH TO PLUGINS DIR\n```\nmysql\u003e SHOW VARIABLES LIKE 'plugin_dir';\n```\n\n//TO MOVE .so TO PLUGINS DIR\n```\nmv udf_json_rate_converter.so /usr/lib/mysql/plugin/\n```\n\n## [n] CHECK FUNCTIONS AND DROP EXISTING CONFLICTS\n```\nSELECT * FROM mysql.func;\nDROP function ...\n```\n\n## [n] CREATE THE FUNCTIONS\n```\ncreate function udf_json_low_rate returns real soname 'udf_json_rate_converter.so';\ncreate function udf_json_high_rate returns real soname 'udf_json_rate_converter.so';\ncreate function udf_is_json returns integer soname 'udf_json_rate_converter.so';\n```\n\n## [n] RESTART MYSQL\n```\nservice mysql restart\n```\n\n# Example Trigger:\n\n```\nDELIMITER //\nCREATE TRIGGER update_rates BEFORE UPDATE ON sometable      \nFOR EACH ROW      \nBEGIN      \nDECLARE j INT(2);\nSET j = udf_is_json(NEW.rates);\nIF j = 1 THEN SET NEW.high_rate = udf_json_high_rate(NEW.rates), NEW.low_rate = udf_json_low_rate(NEW.rates);    \t\nELSE SET NEW.rates = OLD.rates, NEW.high_rate = OLD.high_rate, NEW.low_rate = OLD.low_rate;       \nEND IF;      \nEND\n//\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftecfu%2Fudf_json_rate_converter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftecfu%2Fudf_json_rate_converter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftecfu%2Fudf_json_rate_converter/lists"}