From 7dcf0401137c3b76f0f19963d7cd590085ad5316 Mon Sep 17 00:00:00 2001 From: byungwook-kim Date: Fri, 30 Jun 2017 15:18:12 +0900 Subject: [PATCH] [CBRD-PDO#1] PDO Driver for Cubrid 10.1 (#2) --- cubrid_driver.c | 5 ++--- tests/pdo_022.phpt | 2 +- tests/pdo_036.phpt | 11 ++++------- tests/pdo_038.phpt | 16 ++++++++-------- tests/pdo_039.phpt | 6 +++--- tests/pdo_cubrid_stmt_getcolumnmeta.phpt | 11 +++++------ 6 files changed, 23 insertions(+), 28 deletions(-) diff --git a/cubrid_driver.c b/cubrid_driver.c index 66f845d..02bf5c4 100644 --- a/cubrid_driver.c +++ b/cubrid_driver.c @@ -343,14 +343,13 @@ static int cubrid_handle_quoter(pdo_dbh_t *dbh, const char *unquoted, int unquot *quoted = (char *) emalloc(2 * unquotedlen + 18); - if ((ret = cci_escape_string(H->conn_handle, *quoted+1, unquoted, unquotedlen, &error)) < 0) { + if ((ret = cci_escape_string(H->conn_handle, *quoted, unquoted, unquotedlen, &error)) < 0) { pdo_cubrid_error(dbh, ret, &error, NULL); efree(*quoted); return 0; } *quotedlen = ret; - (*quoted)[0] =(*quoted)[++*quotedlen] = '\''; - (*quoted)[++*quotedlen] = '\0'; + (*quoted)[*quotedlen] = '\0'; return 1; } diff --git a/tests/pdo_022.phpt b/tests/pdo_022.phpt index f07fb09..4c50991 100644 --- a/tests/pdo_022.phpt +++ b/tests/pdo_022.phpt @@ -172,7 +172,7 @@ array(16) { ["scale"]=> int(0) ["not_null"]=> - int(1) + int(0) ["auto_increment"]=> int(0) ["unique_key"]=> diff --git a/tests/pdo_036.phpt b/tests/pdo_036.phpt index 6bd38cb..495e001 100644 --- a/tests/pdo_036.phpt +++ b/tests/pdo_036.phpt @@ -2,20 +2,17 @@ Testing PDORow and PDOStatement instances with Reflection --FILE-- newInstance(); var_dump($x); - -$instance = new reflectionclass('pdostatement'); +$instance = new reflectionclass('pdorow'); $x = $instance->newInstance(); var_dump($x); - ?> --EXPECTF-- -object(PDORow)#%d (0) { -} object(PDOStatement)#%d (1) { [%u|b%"queryString"]=> NULL } + +Fatal error: PDORow::__construct(): You should not create a PDOStatement manually in %spdo_036.php on line %d diff --git a/tests/pdo_038.phpt b/tests/pdo_038.phpt index 41a83e7..767a5ec 100644 --- a/tests/pdo_038.phpt +++ b/tests/pdo_038.phpt @@ -59,13 +59,13 @@ array(2) { [0]=> array(9) { ["PKTABLE_NAME"]=> - string(5) "event" + string(7) "athlete" ["PKCOLUMN_NAME"]=> string(4) "code" ["FKTABLE_NAME"]=> string(4) "game" ["FKCOLUMN_NAME"]=> - string(10) "event_code" + string(12) "athlete_code" ["KEY_SEQ"]=> string(1) "1" ["UPDATE_RULE"]=> @@ -73,20 +73,20 @@ array(2) { ["DELETE_RULE"]=> string(1) "1" ["FK_NAME"]=> - string(18) "fk_game_event_code" + string(20) "fk_game_athlete_code" ["PK_NAME"]=> - string(13) "pk_event_code" + string(15) "pk_athlete_code" } [1]=> array(9) { ["PKTABLE_NAME"]=> - string(7) "athlete" + string(5) "event" ["PKCOLUMN_NAME"]=> string(4) "code" ["FKTABLE_NAME"]=> string(4) "game" ["FKCOLUMN_NAME"]=> - string(12) "athlete_code" + string(10) "event_code" ["KEY_SEQ"]=> string(1) "1" ["UPDATE_RULE"]=> @@ -94,8 +94,8 @@ array(2) { ["DELETE_RULE"]=> string(1) "1" ["FK_NAME"]=> - string(20) "fk_game_athlete_code" + string(18) "fk_game_event_code" ["PK_NAME"]=> - string(15) "pk_athlete_code" + string(13) "pk_event_code" } } diff --git a/tests/pdo_039.phpt b/tests/pdo_039.phpt index 89472f2..b45bbb4 100644 --- a/tests/pdo_039.phpt +++ b/tests/pdo_039.phpt @@ -22,10 +22,10 @@ printf("\nautocommit: %d\ntimeout: %d\nlock_timeout: %d\nisolation_level: %d\nma $db->setAttribute(PDO::ATTR_TIMEOUT, 1); $db->setAttribute(PDO::CUBRID_ATTR_LOCK_TIMEOUT, 4); $db->setAttribute(PDO::ATTR_AUTOCOMMIT, 0); -$db->setAttribute(PDO::CUBRID_ATTR_ISOLATION_LEVEL, 2); +$db->setAttribute(PDO::CUBRID_ATTR_ISOLATION_LEVEL, 5); printf("\n---- PDO Attributes after set ----\n"); -printf("\nautocommit: %d\ntimeout: %d\nlock_timeout: %d\nisolation_level: %d", +printf("\nautocommit: %d\ntimeout: %d\nlock_timeout: %d\nisolation_level: %d\n", $db->getAttribute(PDO::ATTR_AUTOCOMMIT), $db->getAttribute(PDO::ATTR_TIMEOUT), $db->getAttribute(PDO::CUBRID_ATTR_LOCK_TIMEOUT),$db->getAttribute(PDO::CUBRID_ATTR_ISOLATION_LEVEL)); ?> @@ -45,4 +45,4 @@ client_version: %s autocommit: 0 timeout: 1 lock_timeout: 4 -isolation_level: 2 +isolation_level: 5 diff --git a/tests/pdo_cubrid_stmt_getcolumnmeta.phpt b/tests/pdo_cubrid_stmt_getcolumnmeta.phpt index 542508d..bddfd81 100644 --- a/tests/pdo_cubrid_stmt_getcolumnmeta.phpt +++ b/tests/pdo_cubrid_stmt_getcolumnmeta.phpt @@ -37,7 +37,7 @@ array(16) { ["scale"]=> int(0) ["not_null"]=> - int(1) + int(0) ["auto_increment"]=> int(0) ["unique_key"]=> @@ -65,7 +65,7 @@ array(16) { ["table"]=> string(4) "game" ["def"]=> - string(0) "" + string(4) "NULL" ["precision"]=> int(10) ["scale"]=> @@ -99,7 +99,7 @@ array(16) { ["table"]=> string(4) "game" ["def"]=> - string(0) "" + string(4) "NULL" ["precision"]=> int(10) ["scale"]=> @@ -133,7 +133,7 @@ array(16) { ["table"]=> string(4) "game" ["def"]=> - string(0) "" + string(4) "NULL" ["precision"]=> int(3) ["scale"]=> @@ -167,7 +167,7 @@ array(16) { ["table"]=> string(4) "game" ["def"]=> - string(0) "" + string(4) "NULL" ["precision"]=> int(10) ["scale"]=> @@ -193,4 +193,3 @@ array(16) { ["pdo_type"]=> int(2) } -