[MDEV-4502] INTERNAL FUNCTIONS - Add parse_url returning Dynamic Column Object Created: 2013-05-09  Updated: 2013-06-18

Status: Open
Project: MariaDB Server
Component/s: None
Fix Version/s: None

Type: Task Priority: Trivial
Reporter: roberto spadim Assignee: Unassigned
Resolution: Unresolved Votes: 0
Labels: None


 Description   

Hi guys, could we develop a function to get information from a url, and 'convert' it to a dynamic column?

i have a big apache log, with some fields:
start time,total time,url,bytes in,bytes out

and i do some searchs in this database, for example, try to get how many users was quering some url with some variable=xxx

i do this search inside url value, it works, but it's not perfect

what i do?

SELECT * FROM log WHERE url LIKE '%USER=1234%'

in other words, it return all rows that have USER=1234, this include users 12345,123456, and others kinds of url values
ok, here i have some optimization from LIKE operator, but it's not perfect
after, i run in php side a parse in url and check if it's from user 1234

what i was thinking...
a function that convert a string url, to a dynamic column, like
http://www.php.net/manual/en/function.parse-url.php
and a function that convert a string of GET http values, to dynamic column, like
http://www.php.net/manual/en/function.parse-str.php

could it be done? this realy made my log very easier to analyze

the 'like' part is good to query just some rows, but this two functions could be done to optimize the php part

i could done some search like:

SELECT * FROM log WHERE 
URL_PARSE_VAR(url,'USER')='1234' 
AND
URL_PARSE(url,'path')='some_file.php'

and do some analytic tools, COUNT(*), SUM(total time)... etc



 Comments   
Comment by Sergei Golubchik [ 2013-05-09 ]

Sure, it's possible. Just write an UDF as described here: http://dev.mysql.com/doc/refman/5.6/en/adding-udf.html and parse the url any way you want.

Generated at Thu Feb 08 06:56:55 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.