3

I read the documentation for oci_cancel but it seems to me a bit fuzzy.

Does oci_cancel kill the sql process in the server?

If not, how can I make a script that executes a sql query, waits a moment and if the query exceeds 10 seconds (for example), cancel the query in the server?

Excuse me if this question is similar to one that has been asked time ago, but I didn't find any satisfactory answer.

Galled
  • 4,146
  • 2
  • 28
  • 41
  • 2
    Is not a method of preventing SQL injection. I try to find a way to kill long running queries because I try to detect programatically wich query is more heavy than another one. – Galled Nov 07 '11 at 17:03
  • 2
    Your rewritten title makes it much clearer what you're trying to accomplish, thank you :) – Frank Farmer Nov 07 '11 at 23:14

2 Answers2

1

PDO allows you to specify the query timeout with the "ATTR_TIMEOUT" attribute, although it's entirely dependent whether the driver supports it or not.

Galled
  • 4,146
  • 2
  • 28
  • 41
John Cartwright
  • 5,109
  • 22
  • 25
  • 1
    With only oci functions I can't do that, no? – Galled Nov 07 '11 at 17:04
  • Reading the link I find this: "Specifies the timeout duration in seconds. **Not all drivers support this option**, ... but other drivers may interpret this as a **connect or a read timeout interval**." – Galled Nov 07 '11 at 17:12
  • PDO is not an option. That would be make another connection with PDO and I'm using OCI. – Galled Nov 12 '11 at 16:28
0

Eventually I had to use a solution that does not know if it's the best, but it was a mixture of things:

I was already using something like this to save the results of the querys in CSV files and then lift them into a session variable.

Well, I'm using this way to make a CSV file with the result of the query, sending the query by a PHP exec in background with a script in php with set_time_limit(10) and then waiting a time (10 seconds) until the result of the query has saved in a session variable. If the time(10 seconds) pass and I haven't got the query saved in the session variable I continue make the next actions.

Community
  • 1
  • 1
Galled
  • 4,146
  • 2
  • 28
  • 41