diff options
| author | Leo Baschy <codelion@php.net> | 2000-03-09 22:19:57 +0000 | 
|---|---|---|
| committer | Leo Baschy <codelion@php.net> | 2000-03-09 22:19:57 +0000 | 
| commit | db33bb8ff6f99d67143804e52b2f5edcd6d806dc (patch) | |
| tree | 1b8881c7e9dc02d2fadff07a22641bc4e876e12d | |
| parent | f6460bfe6fc548b317926ceeb3c75de46d69049c (diff) | |
| download | php-git-db33bb8ff6f99d67143804e52b2f5edcd6d806dc.tar.gz | |
_close_odbc_conn calls _free_odbc_result if possible
| -rw-r--r-- | ext/odbc/php_odbc.c | 30 | ||||
| -rw-r--r-- | ext/odbc/php_odbc.h | 1 | 
2 files changed, 31 insertions, 0 deletions
| diff --git a/ext/odbc/php_odbc.c b/ext/odbc/php_odbc.c index 366b7309c2..c823d41882 100644 --- a/ext/odbc/php_odbc.c +++ b/ext/odbc/php_odbc.c @@ -160,10 +160,18 @@ static void _free_odbc_result(odbc_result *res)  			 * zend_list_delete(res->conn_ptr->id);  			 */  		} +		if (res->conn_ptr) { +			if (res->conn_ptr->one_result == res) { +				res->conn_ptr->one_result = NULL; +			}; +		};  		efree(res);  	}  } +#define ODBC_REGISTER_RESULT_WITH_CONNECTION(result) if (!((result)->conn_ptr->one_result)) { \ +	(result)->conn_ptr->one_result = (result); }; +  static void _close_odbc_conn(odbc_connection *conn)  {  	/* FIXME @@ -173,6 +181,10 @@ static void _close_odbc_conn(odbc_connection *conn)  	 */  	ODBCLS_FETCH(); +	if (conn->one_result) { +		zend_list_delete(conn->one_result->id); +		conn->one_result = NULL; +	};     	SQLDisconnect(conn->hdbc);  	SQLFreeConnect(conn->hdbc);  	SQLFreeEnv(conn->henv); @@ -184,6 +196,10 @@ static void _close_odbc_pconn(odbc_connection *conn)  {  	ODBCLS_FETCH(); +	if (conn->one_result) { +		zend_list_delete(conn->one_result->id); +		conn->one_result = NULL; +	};  	SQLDisconnect(conn->hdbc);  	SQLFreeConnect(conn->hdbc);  	SQLFreeEnv(conn->henv); @@ -688,6 +704,7 @@ PHP_FUNCTION(odbc_prepare)  	zend_list_addref(conn->id);  	result->conn_ptr = conn;  	result->fetched = 0; +	ODBC_REGISTER_RESULT_WITH_CONNECTION(result);  	RETURN_RESOURCE(result->id);  }  /* }}} */ @@ -1017,6 +1034,7 @@ PHP_FUNCTION(odbc_exec)  	zend_list_addref(conn->id);  	result->conn_ptr = conn;  	result->fetched = 0; +	ODBC_REGISTER_RESULT_WITH_CONNECTION(result);  	RETURN_RESOURCE(result->id);  } @@ -1583,6 +1601,7 @@ int odbc_sqlconnect(odbc_connection **conn, char *db, char *uid, char *pwd, int  	*conn = (odbc_connection *)pemalloc(sizeof(odbc_connection), persistent);  	(*conn)->persistent = persistent; +	(*conn)->one_result = NULL;  	SQLAllocEnv(&((*conn)->henv));  	SQLAllocConnect((*conn)->henv, &((*conn)->hdbc)); @@ -2251,6 +2270,7 @@ PHP_FUNCTION(odbc_tables)  	}  	result->conn_ptr = conn;  	result->fetched = 0; +	ODBC_REGISTER_RESULT_WITH_CONNECTION(result);  	ZEND_REGISTER_RESOURCE(return_value, result, le_result);  }  /* }}} */ @@ -2333,6 +2353,7 @@ PHP_FUNCTION(odbc_columns)  	}  	result->conn_ptr = conn;  	result->fetched = 0; +	ODBC_REGISTER_RESULT_WITH_CONNECTION(result);  	ZEND_REGISTER_RESOURCE(return_value, result, le_result);  }  /* }}} */ @@ -2412,6 +2433,7 @@ PHP_FUNCTION(odbc_columnprivileges)  	}  	result->conn_ptr = conn;  	result->fetched = 0; +	ODBC_REGISTER_RESULT_WITH_CONNECTION(result);  	ZEND_REGISTER_RESOURCE(return_value, result, le_result);  }  /* }}} */ @@ -2512,6 +2534,7 @@ PHP_FUNCTION(odbc_foreignkeys)  	}  	result->conn_ptr = conn;  	result->fetched = 0; +	ODBC_REGISTER_RESULT_WITH_CONNECTION(result);  	ZEND_REGISTER_RESOURCE(return_value, result, le_result);  }  /* }}} */ @@ -2585,6 +2608,7 @@ PHP_FUNCTION(odbc_gettypeinfo)  	}  	result->conn_ptr = conn;  	result->fetched = 0; +	ODBC_REGISTER_RESULT_WITH_CONNECTION(result);  	ZEND_REGISTER_RESOURCE(return_value, result, le_result);  }  /* }}} */ @@ -2660,6 +2684,7 @@ PHP_FUNCTION(odbc_primarykeys)  	}  	result->conn_ptr = conn;  	result->fetched = 0; +	ODBC_REGISTER_RESULT_WITH_CONNECTION(result);  	ZEND_REGISTER_RESOURCE(return_value, result, le_result);  }  /* }}} */ @@ -2743,6 +2768,7 @@ PHP_FUNCTION(odbc_procedurecolumns)  	}  	result->conn_ptr = conn;  	result->fetched = 0; +	ODBC_REGISTER_RESULT_WITH_CONNECTION(result);  	ZEND_REGISTER_RESOURCE(return_value, result, le_result);  }  /* }}} */ @@ -2824,6 +2850,7 @@ PHP_FUNCTION(odbc_procedures)  	}  	result->conn_ptr = conn;  	result->fetched = 0; +	ODBC_REGISTER_RESULT_WITH_CONNECTION(result);  	ZEND_REGISTER_RESOURCE(return_value, result, le_result);  }  /* }}} */ @@ -2913,6 +2940,7 @@ PHP_FUNCTION(odbc_specialcolumns)  	}  	result->conn_ptr = conn;  	result->fetched = 0; +	ODBC_REGISTER_RESULT_WITH_CONNECTION(result);  	ZEND_REGISTER_RESOURCE(return_value, result, le_result);  }  /* }}} */ @@ -2997,6 +3025,7 @@ PHP_FUNCTION(odbc_statistics)  	}  	result->conn_ptr = conn;  	result->fetched = 0; +	ODBC_REGISTER_RESULT_WITH_CONNECTION(result);  	ZEND_REGISTER_RESOURCE(return_value, result, le_result);  }  /* }}} */ @@ -3073,6 +3102,7 @@ PHP_FUNCTION(odbc_tableprivileges)  	}  	result->conn_ptr = conn;  	result->fetched = 0; +	ODBC_REGISTER_RESULT_WITH_CONNECTION(result);  	ZEND_REGISTER_RESOURCE(return_value, result, le_result);  }  /* }}} */ diff --git a/ext/odbc/php_odbc.h b/ext/odbc/php_odbc.h index 658cac6976..899b6e65af 100644 --- a/ext/odbc/php_odbc.h +++ b/ext/odbc/php_odbc.h @@ -218,6 +218,7 @@ typedef struct odbc_connection {  /*	int open;*/  	int id;  	int persistent; +	struct odbc_result *one_result; // to enable _close_odbc_conn to call _free_odbc_result  } odbc_connection;  typedef struct odbc_result_value { | 
