com php-src: Last few changes : . force the nls_da te_format . add the scale to the return of the function . add tests on some functi on return .
removing unused variables: ext/p do_oci/oci_statement.c ext/pdo_oci/tests/pdo_oci_ stmt_getcolumnmeta.phpt
| From: | Remi Collet | Date: | Wed, 26 Sep 2018 11:19:29 +0000 |
| Subject: | com php-src: Last few changes : . force the nls_da te_format . add the scale to the return of the function . add tests on some functi on return . removing unused variables: ext/p do_oci/oci_statement.c ext/pdo_oci/tests/pdo_oci_ stmt_getcolumnmeta.phpt |
||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-103281@lists.php.net to get a copy of this message | ||
Commit: 478f3d57e670bd3c4c19e7aeeb8d1b0ee1f336e0
Author: Letargie <valentin@famillecollet.com> Wed, 26 Sep 2018 13:19:29 +0200
Parents: f185ab7daf4e8235bf4b9e405e4bf91f3764bfcd
Branches: master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=478f3d57e670bd3c4c19e7aeeb8d1b0ee1f336e0
Log:
Last few changes :
. force the nls_date_format
. add the scale to the return of the function
.. add tests on some function return
. removing unused variables
Changed paths:
M ext/pdo_oci/oci_statement.c
M ext/pdo_oci/tests/pdo_oci_stmt_getcolumnmeta.phpt
Diff:
diff --git a/ext/pdo_oci/oci_statement.c b/ext/pdo_oci/oci_statement.c
index 0c19369..c9686f6 100644
--- a/ext/pdo_oci/oci_statement.c
+++ b/ext/pdo_oci/oci_statement.c
@@ -525,7 +525,7 @@ static int oci_stmt_describe(pdo_stmt_t *stmt, int colno) /* {{{ */
pdo_oci_stmt *S = (pdo_oci_stmt*)stmt->driver_data;
OCIParam *param = NULL;
text *colname;
- ub2 dtype, data_size, scale, precis;
+ ub2 dtype, data_size, precis;
ub4 namelen;
struct pdo_column_data *col = &stmt->columns[colno];
zend_bool dyn = FALSE;
@@ -541,10 +541,6 @@ static int oci_stmt_describe(pdo_stmt_t *stmt, int colno) /* {{{ */
STMT_CALL_MSG(OCIAttrGet, "OCI_ATTR_DATA_SIZE",
(param, OCI_DTYPE_PARAM, &data_size, 0, OCI_ATTR_DATA_SIZE, S->err));
- /* scale ? */
- STMT_CALL_MSG(OCIAttrGet, "OCI_ATTR_SCALE",
- (param, OCI_DTYPE_PARAM, &scale, 0, OCI_ATTR_SCALE, S->err));
-
/* precision ? */
STMT_CALL_MSG(OCIAttrGet, "OCI_ATTR_PRECISION",
(param, OCI_DTYPE_PARAM, &precis, 0, OCI_ATTR_PRECISION, S->err));
@@ -799,13 +795,8 @@ static int oci_stmt_col_meta(pdo_stmt_t *stmt, zend_long colno, zval
*return_val
pdo_oci_stmt *S = (pdo_oci_stmt*)stmt->driver_data;
pdo_oci_column *C;
OCIParam *param = NULL;
- OraText *colname;
- OraText * schema;
- ub2 dtype, data_size;
- ub2 precis = 0;
- ub4 namelen, schemalen, typelen, objlen;
+ ub2 dtype, precis;
sb1 scale;
- char *str;
zval flags;
ub1 isnull, charset_form;
if (!S->stmt) {
@@ -828,9 +819,6 @@ static int oci_stmt_col_meta(pdo_stmt_t *stmt, zend_long colno, zval *return_val
STMT_CALL_MSG(OCIAttrGet, "OCI_ATTR_DATA_TYPE",
(param, OCI_DTYPE_PARAM, &dtype, 0, OCI_ATTR_DATA_TYPE, S->err));
- /* column length */
- STMT_CALL_MSG(OCIAttrGet, "OCI_ATTR_DATA_SIZE",
- (param, OCI_DTYPE_PARAM, &data_size, 0, OCI_ATTR_DATA_SIZE, S->err));
/* column precision */
STMT_CALL_MSG(OCIAttrGet, "OCI_ATTR_PRECISION",
(param, OCI_DTYPE_PARAM, &precis, 0, OCI_ATTR_PRECISION, S->err));
@@ -963,9 +951,6 @@ static int oci_stmt_col_meta(pdo_stmt_t *stmt, zend_long colno, zval *return_val
add_assoc_long(return_value, "oci:decl_type", dtype);
add_assoc_string(return_value, "native_type", "UNKNOWN");
}
- } else if (data_size) {
- /* if the column is the result of a function */
- add_assoc_string(return_value, "native_type", "UNKNOWN");
} else {
/* if the column is NULL */
add_assoc_long(return_value, "oci:decl_type", 0);
@@ -993,6 +978,7 @@ static int oci_stmt_col_meta(pdo_stmt_t *stmt, zend_long colno, zval *return_val
add_assoc_long(return_value, "pdo_type", PDO_PARAM_STR);
}
+ add_assoc_long(return_value, "scale", scale);
add_assoc_zval(return_value, "flags", &flags);
OCIDescriptorFree(param, OCI_DTYPE_PARAM);
diff --git a/ext/pdo_oci/tests/pdo_oci_stmt_getcolumnmeta.phpt
b/ext/pdo_oci/tests/pdo_oci_stmt_getcolumnmeta.phpt
index cdbd3b1..475b2b1 100755
--- a/ext/pdo_oci/tests/pdo_oci_stmt_getcolumnmeta.phpt
+++ b/ext/pdo_oci/tests/pdo_oci_stmt_getcolumnmeta.phpt
@@ -70,41 +70,14 @@ SQL
var_export($native, true), var_export($emulated, true));
}
- function test_meta(&$db, $offset, $sql_type, $value, $native_type, $pdo_type) {
-
- $db->exec(<<<SQL
-BEGIN
- EXECUTE IMMEDIATE 'DROP TABLE test';
-EXCEPTION
- WHEN OTHERS THEN
- IF SQLCODE != -942 THEN
- RAISE;
- END IF;
-END;
-SQL
-);
-
- $sql = sprintf('CREATE TABLE test(id INT, label %s)', $sql_type);
- $stmt = $db->prepare($sql);
- $stmt->execute();
-
- if (!$db->exec(sprintf("INSERT INTO test(id, label) VALUES (1, '%s')",
$value))) {
- printf("[%03d] + 1] Insert failed, %d - %s\n", $offset,
- $db->errorCode(), var_export($db->errorInfo(), true));
- return false;
- }
-
- $stmt = $db->prepare('SELECT id, label FROM test');
- $stmt->execute();
- $meta = $stmt->getColumnMeta(1);
- $row = $stmt->fetch(PDO::FETCH_ASSOC);
+ function test_return($meta, $offset, $native_type, $pdo_type){
if (empty($meta)) {
printf("[%03d + 2] getColumnMeta() failed, %d - %s\n", $offset,
$stmt->errorCode(), var_export($stmt->errorInfo(), true));
return false;
}
- $elements = array('flags', 'name', 'len', 'precision',
'pdo_type');
+ $elements = array('flags', 'scale', 'name', 'len',
'precision', 'pdo_type');
foreach ($elements as $k => $element)
if (!isset($meta[$element])) {
printf("[%03d + 3] Element %s missing, %s\n", $offset,
@@ -146,6 +119,37 @@ SQL
return true;
}
+
+ function test_meta(&$db, $offset, $sql_type, $value, $native_type, $pdo_type) {
+
+ $db->exec(<<<SQL
+BEGIN
+ EXECUTE IMMEDIATE 'DROP TABLE test';
+EXCEPTION
+ WHEN OTHERS THEN
+ IF SQLCODE != -942 THEN
+ RAISE;
+ END IF;
+END;
+SQL
+);
+
+ $sql = sprintf('CREATE TABLE test(id INT, label %s)', $sql_type);
+ $stmt = $db->prepare($sql);
+ $stmt->execute();
+
+ if (!$db->exec(sprintf("INSERT INTO test(id, label) VALUES (1, '%s')",
$value))) {
+ printf("[%03d] + 1] Insert failed, %d - %s\n", $offset,
+ $db->errorCode(), var_export($db->errorInfo(), true));
+ return false;
+ }
+
+ $stmt = $db->prepare('SELECT id, label FROM test');
+ $stmt->execute();
+ $meta = $stmt->getColumnMeta(1);
+ return test_return($meta, $offset, $native_type, $pdo_type);
+ }
+
echo "Test 2.2 testing numeric columns\n";
test_meta($db, 20, 'NUMBER' , 0 , 'NUMBER',
PDO::PARAM_STR);
@@ -167,6 +171,7 @@ SQL
echo "Test 2.3 testing temporal columns\n";
+ $db->exec("alter session set nls_date_format='YYYY-MM-DD'");
test_meta($db, 160, 'DATE' , '2008-04-23' , 'DATE',
PDO::PARAM_STR);
echo "Test 2.4 testing string columns\n";
@@ -198,6 +203,7 @@ SQL
test_meta($db, 360, 'LONG RAW' , str_repeat('b', 256) , 'LONG
RAW', PDO::PARAM_STR);
test_meta($db, 370, 'RAW(256)' , str_repeat('b', 256) , 'RAW'
, PDO::PARAM_STR);
+
$db->exec(<<<SQL
BEGIN
EXECUTE IMMEDIATE 'DROP TABLE test';
@@ -209,7 +215,20 @@ EXCEPTION
END;
SQL
);
- echo "Test 2.6 testing flags returned\n";
+ echo "Test 2.6 testing function return\n";
+
+ $stmt = $db->query('SELECT count(*) FROM dual');
+ $meta = $stmt->getColumnMeta(0);
+ test_return($meta, 380, 'NUMBER', PDO::PARAM_STR);
+ $stmt = $db->query("SELECT TO_DATE('2008-04-23') FROM dual");
+ $meta = $stmt->getColumnMeta(0);
+ test_return($meta, 390, 'DATE', PDO::PARAM_STR);
+ $stmt = $db->query("SELECT TO_CHAR(542) FROM dual");
+ $meta = $stmt->getColumnMeta(0);
+ test_return($meta, 400, 'VARCHAR2', PDO::PARAM_STR);
+
+
+ echo "Test 2.7 testing flags returned\n";
$sql = sprintf('CREATE TABLE test(id INT NOT NULL, label INT NULL)');
$stmt = $db->prepare($sql);
@@ -277,5 +296,6 @@ Test 2.2 testing numeric columns
Test 2.3 testing temporal columns
Test 2.4 testing string columns
Test 2.5 testing lobs columns
-Test 2.6 testing flags returned
+Test 2.6 testing function return
+Test 2.7 testing flags returned
done!