[PHP-DEV] [PATCH] Sybase error handling
Attached is a patch for error handling with Sybase/MSSQL databases. Basically it picks up the message and the error number from the dberrhandler() call. This means that MSSQL/Sybase RAISERROR calls can be caught properly in the PHP script. Any chance of someone committing it in? Dave. Index: ext/sybase/php_sybase_db.c === RCS file: /repository/php4/ext/sybase/php_sybase_db.c,v retrieving revision 1.37 diff -u -r1.37 php_sybase_db.c --- ext/sybase/php_sybase_db.c 12 Mar 2002 20:18:00 - 1.37 +++ ext/sybase/php_sybase_db.c 22 May 2002 13:37:43 - -88,6 +88,8 PHP_FE(sybase_query,NULL) PHP_FE(sybase_free_result, NULL) PHP_FE(sybase_get_last_message, NULL) + PHP_FE(sybase_get_last_error, NULL) + PHP_FE(sybase_get_last_error_no,NULL) PHP_FE(sybase_num_rows, NULL) PHP_FE(sybase_num_fields, NULL) PHP_FE(sybase_fetch_row,NULL) -107,6 +109,8 PHP_FALIAS(mssql_query, sybase_query, NULL) PHP_FALIAS(mssql_free_result, sybase_free_result, NULL) PHP_FALIAS(mssql_get_last_message, sybase_get_last_message,NULL) + PHP_FALIAS(mssql_get_last_error,sybase_get_last_error, NULL) + PHP_FALIAS(mssql_get_last_error_no, sybase_get_last_error_no, NULL) PHP_FALIAS(mssql_num_rows, sybase_num_rows,NULL) PHP_FALIAS(mssql_num_fields,sybase_num_fields, NULL) PHP_FALIAS(mssql_fetch_row, sybase_fetch_row, NULL) -146,6 +150,9 if (severity = php_sybase_module.min_error_severity) { php_error(E_WARNING,Sybase error: %s (severity %d),dberrstr,severity); } + STR_FREE(php_sybase_module.error_message); + php_sybase_module.error_message = estrdup(dberrstr); + php_sybase_module.error_no = dberr; return INT_CANCEL; } -279,8 +286,10 { php_sybase_module.default_link=-1; php_sybase_module.num_links = php_sybase_module.num_persistent; - php_sybase_module.appname = estrndup(PHP 4.0,7); + php_sybase_module.appname = estrndup(PHP 4.2,7); php_sybase_module.server_message = empty_string; + php_sybase_module.error_message = empty_string; + php_sybase_module.error_no = 0; php_sybase_module.min_error_severity = php_sybase_module.cfg_min_error_severity; php_sybase_module.min_message_severity = php_sybase_module.cfg_min_message_severity; return SUCCESS; -296,6 +305,7 { efree(php_sybase_module.appname); STR_FREE(php_sybase_module.server_message); + STR_FREE(php_sybase_module.error_message); return SUCCESS; } -940,6 +950,26 RETURN_STRING(php_sybase_module.server_message,1); } /* }}} */ + + +/* {{{ proto string sybase_get_last_error(void) + Returns the last error message from server */ +PHP_FUNCTION(sybase_get_last_error) +{ + RETURN_STRING(php_sybase_module.error_message,1); +} +/* }}} */ + + +/* {{{ proto string sybase_get_last_error_no(void) + Returns the last error number from server */ +PHP_FUNCTION(sybase_get_last_error_no) +{ + Z_LVAL_P(return_value) = php_sybase_module.error_no; + Z_TYPE_P(return_value) = IS_LONG; +} +/* }}} */ + /* {{{ proto int sybase_num_rows(int result) Get number of rows in result */ Index: ext/sybase/php_sybase_db.h === RCS file: /repository/php4/ext/sybase/php_sybase_db.h,v retrieving revision 1.8 diff -u -r1.8 php_sybase_db.h --- ext/sybase/php_sybase_db.h 28 Feb 2002 08:26:50 - 1.8 +++ ext/sybase/php_sybase_db.h 22 May 2002 13:37:45 - -38,6 +38,8 PHP_FUNCTION(sybase_query); PHP_FUNCTION(sybase_free_result); PHP_FUNCTION(sybase_get_last_message); +PHP_FUNCTION(sybase_get_last_error); +PHP_FUNCTION(sybase_get_last_error_no); PHP_FUNCTION(sybase_num_rows); PHP_FUNCTION(sybase_num_fields); PHP_FUNCTION(sybase_fetch_row); -70,6 +72,8 long allow_persistent; char *appname; char *server_message; + char *error_message; + int error_no; int le_link,le_plink,le_result; long min_error_severity,min_message_severity; long cfg_min_error_severity,cfg_min_message_severity; -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DEV] Crasher in 4.2.1 - debugging advice needed
Hi, I've got a particular script that seg-faults when certain parts of it run (tested with 4.1.0 and 4.2.1, both CGI and Apache module). I've done a back trace, included below. Linux 2.4.18 (Redhat 7.0). I'm not sure what to do next, as if it is something not free'ing properly, or free'ing twice (as hinted in the bt), then are there any ways I can tell where? Many thanks for any pointers, Dave. #0 0x40139566 in chunk_free (ar_ptr=0x401dbce0, p=0x81a5360) at malloc.c:3131 #1 0x40139334 in __libc_free (mem=0x81a5368) at malloc.c:3043 #2 0x80e7d67 in shutdown_memory_manager (silent=0, clean_cache=0) at zend_alloc.c:485 #3 0x8062049 in php_request_shutdown (dummy=0x0) at main.c:742 #4 0x80608ff in main (argc=1, argv=0xbb34) at cgi_main.c:776 #5 0x400d9b65 in __libc_start_main (main=0x8060610 main, argc=1, ubp_av=0xbb34, init=0x805f000 _init, fini=0x8117fbc _fini, rtld_fini=0x4000df24 _dl_fini, stack_end=0xbb2c) at ../sysdeps/generic/libc-start.c:111 Line 485 of zend_alloc.c is the zend_message_dispatcher line if (!silent) { zend_message_dispatcher(ZMSG_MEMORY_LEAK_DETECTED, t); } -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DEV] Part run script shutdown
Hi, I'm trying to find out whether PHP_RSHUTDOWN_FUNCTION is called when a browser session is killed mid-script. If not, is there any way an extension can detect the output socket is closed? I've found a potential gotcha in the Sybase module, to do with locking, and the locks never being released if the script doesn't finish. I'm still digging about with it, so I'm not 100% sure what's going on yet Thanks, Dave. -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DEV] need help!
You're asking on the wrong list. It's php-general you need to subscribe to. This list is for development *OF* PHP, not IN PHP. -Original Message- From: its me [mailto:[EMAIL PROTECTED]] Sent: 10 March 2002 06:01 To: [EMAIL PROTECTED] Subject: [PHP-DEV] need help! i have in java script an array: var computerArray = new Array(('Select sub-category','',true,true), ('Hardware'), ('Monitors'), ('Printers'), ('Other')); but i want to create the items: ('Hardware'), ('Monitors'), ('Printers'), ('Other') dynamicaly from database and this array must stay in javascript i can't create it with only php because its elements are a drop down menu which change with the change of another drop down menu..so it must remain in javascript... the whole script is: script language=JavaScript !-- var computerArray = new Array(('Select sub-category','',true,true), ('Hardware'), ('Monitors'), ('Printers'), ('Other')); var carsArray = new Array(('Select sub-category','',true,true), ('Vans'), ('Sedan'), ('Spor'), ('Other')); function populateCategory(inForm,selected) { var selectedArray = eval(selected + Array); while (selectedArray.length inForm.subcategory.options.length) { inForm.subcategory.options[(inForm.subcategory.options.length - 1)] = null; } for (var i=0; i selectedArray.length; i++) { eval(inForm.subcategory.options[i]= + new Option + selectedArray[i]); } if (inForm.category.options[0].value == '') { inForm.category.options[0]= null; if ( navigator.appName == 'Netscape') { if (parseInt(navigator.appVersion) 4) { window.history.go(0); } else { if (navigator.platform == 'Win32' || navigator.platform == 'Win16') { window.history.go(0); } } } } } // End -- /script html BODY bgcolor=#FF text=#00 center form name=globe select name=category onChange=populateCategory(document.globe,document.globe.category. options[document.globe.category.selectedIndex].value) option selected value=''Select Category/option option value='cars'Cars/option option value='computer'Computer/option /select select name=subcategory option value=''/option /select /form /center /SCRIPT Rehab M.Shouman - Express yourself with a super cool email address from BigMailBox.com. Hundreds of choices. It's free! http://www.bigmailbox.com - -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DEV] Re: Suggestion: Adding fmt like linebreak algorithm
Forgive me, but what does BC stand for? I'd be happy to have a go at creating the new function though... Dave -Original Message- From: Markus Fischer [mailto:[EMAIL PROTECTED]] Sent: 27 December 2001 05:15 To: Sean R. Bright Cc: 'Dominik Roettsches'; [EMAIL PROTECTED] Subject: Re: [PHP-DEV] Re: Suggestion: Adding fmt like linebreak algorithm On Wed, Dec 26, 2001 at 11:32:22PM -0500, Sean R. Bright wrote : I need to find a plaintext version of Knuth's paper, then maybe I could help. I don't want to look at fmt's code. You should. It's pretty straightforward to bind. -- Please always Cc to me when replying to me on the lists. -- PHP Development Mailing List http://www.php.net/ To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP Development Mailing List http://www.php.net/ To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP-DEV] Sybase / MSsql module additions
I've added two functions - sybase_get_last_error and sybase_get_last_error_no (alias functions for mssql_ are included), so that the user can do error handling with the errors raised from sybase or mssql. I've included a unified diff for these changes. Tested on Apache and MS SQL. They are only minor changes, so shouldn't affect anything else. Do I have to do anything else with the source to submit it? If anyone wants the changes applying to the mssql extension, then let me know - they'll be the same changes. Corrections / comments welcome. Thanks a lot, Dave. --- ext/sybase/php_sybase_db.c Thu Dec 13 08:50:45 2001 +++ ext/sybase/php_sybase_db.c Thu Dec 13 10:43:50 2001 @@ -88,6 +88,8 @@ PHP_FE(sybase_query,NULL) PHP_FE(sybase_free_result, NULL) PHP_FE(sybase_get_last_message, NULL) + PHP_FE(sybase_get_last_error, NULL) + PHP_FE(sybase_get_last_error_no,NULL) PHP_FE(sybase_num_rows, NULL) PHP_FE(sybase_num_fields, NULL) PHP_FE(sybase_fetch_row,NULL) @@ -107,6 +109,8 @@ PHP_FALIAS(mssql_query, sybase_query, NULL) PHP_FALIAS(mssql_free_result, sybase_free_result, NULL) PHP_FALIAS(mssql_get_last_message, sybase_get_last_message,NULL) + PHP_FALIAS(mssql_get_last_error,sybase_get_last_error, NULL) + PHP_FALIAS(mssql_get_last_error_no, sybase_get_last_error_no, NULL) PHP_FALIAS(mssql_num_rows, sybase_num_rows,NULL) PHP_FALIAS(mssql_num_fields,sybase_num_fields, NULL) PHP_FALIAS(mssql_fetch_row, sybase_fetch_row, NULL) @@ -146,6 +150,9 @@ if (severity = php_sybase_module.min_error_severity) { php_error(E_WARNING,Sybase error: %s (severity %d),dberrstr,severity); } + STR_FREE(php_sybase_module.error_message); + php_sybase_module.error_message = estrdup(dberrstr); + php_sybase_module.error_no = dberr; return INT_CANCEL; } @@ -281,6 +288,8 @@ php_sybase_module.num_links = php_sybase_module.num_persistent; php_sybase_module.appname = estrndup(PHP 4.0,7); php_sybase_module.server_message = empty_string; + php_sybase_module.error_message = empty_string; + php_sybase_module.error_no = 0; php_sybase_module.min_error_severity = php_sybase_module.cfg_min_error_severity; php_sybase_module.min_message_severity = php_sybase_module.cfg_min_message_severity; return SUCCESS; @@ -912,6 +921,24 @@ PHP_FUNCTION(sybase_get_last_message) { RETURN_STRING(php_sybase_module.server_message,1); +} +/* }}} */ + +/* {{{ proto string sybase_get_last_error(void) + Returns the last error from server (not affected by min_error_severity) */ +PHP_FUNCTION(sybase_get_last_error) +{ + RETURN_STRING(php_sybase_module.error_message,1); +} +/* }}} */ + +/* {{{ proto int sybase_get_last_error_no(void) + Returns the last error number from server + (not affected by min_error_severity) */ +PHP_FUNCTION(sybase_get_last_error_no) +{ + Z_LVAL_P(return_value) = php_sybase_module.error_no; + Z_TYPE_P(return_value) = IS_LONG; } /* }}} */ --- ext/sybase/php_sybase_db.h Thu Dec 13 08:50:13 2001 +++ ext/sybase/php_sybase_db.h Thu Dec 13 10:43:50 2001 @@ -38,6 +38,8 @@ PHP_FUNCTION(sybase_query); PHP_FUNCTION(sybase_free_result); PHP_FUNCTION(sybase_get_last_message); +PHP_FUNCTION(sybase_get_last_error); +PHP_FUNCTION(sybase_get_last_error_no); PHP_FUNCTION(sybase_num_rows); PHP_FUNCTION(sybase_num_fields); PHP_FUNCTION(sybase_fetch_row); @@ -70,6 +72,8 @@ long allow_persistent; char *appname; char *server_message; + char *error_message; + int error_no; int le_link,le_plink,le_result; long min_error_severity,min_message_severity; long cfg_min_error_severity,cfg_min_message_severity; -- PHP Development Mailing List http://www.php.net/ To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP-DEV] Submitting changes
Where (and who) do I submit a code patch to one of the modules? -- PHP Development Mailing List http://www.php.net/ To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP-DEV] mssql/sybase error extension
Hi, I written a small extension to the sybase (and mssql) modules to handle the errors raised with raiserror from the sql server. However, I have never done any PHP source development before, and I would like someone to check that I haven't broken any development rules! - and also, if possible, test it on a sybase box (I only have an MS box to test it on). Also, how do I go about posting the changes into the source (I've altered 4.1.0)? Thanks ever so much, Dave. -- PHP Development Mailing List http://www.php.net/ To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]