# pdo_mysql patch

- Thread: https://externals.io/message/30335
- Original archive: https://news-web.php.net/php.internals/30335
- Started by Kevin Waterson on 2007-06-26T01:49:40+00:00
- Messages: 5
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #30335 — Kevin Waterson — 2007-06-26T01:49:40+00:00

URL: https://externals.io/message/30335#30335

currently pdo_mysql is unable to discern between a BLOB and a TEXT field
in mysql_statement.c
By using the current  if (IS_BLOB(F->flags)), which is now deprecated in
the mysql c api, it will be true for both TEXT and BLOB fields.

By updating a little to the newer api and checking with F->type we get
the same result, however, further checking on the character set number
can distinguish between BINARY and CHAR, VARBINARY and VARCHAR, and BLOB
and TEXT fields.

When using PDOStatement::getColumnMeta() any field with charsetnr of 63
reports as text, rather than blob. Patch follows...

--- old.c       2007-06-26 11:27:57.000000000 +1000
+++ mysql_statement.c   2007-06-26 11:26:47.000000000 +1000
@@ -581,8 +581,12 @@
        if (F->flags & UNIQUE_KEY_FLAG) {
                add_next_index_string(flags, "unique_key", 1);
        }
-       if (IS_BLOB(F->flags)) {
-               add_next_index_string(flags, "blob", 1);
+       if(F->type == MYSQL_TYPE_BLOB)  {
+               if(F->charsetnr == 63) {
+                       add_next_index_string(flags, "blob", 1);
+               } else {
+                       add_next_index_string(flags, "text", 1);
+               }
        }
        str = type_to_name_native(F->type);
        if (str) {




-- 
"Democracy is two wolves and a lamb voting on what to have for lunch. 
Liberty is a well-armed lamb contesting the vote."

---

## #30336 — Ilia Alshanetsky — 2007-06-26T02:03:02+00:00

URL: https://externals.io/message/30335#30336 · In reply to: #30335

Will this mechanism for differentiating between TEXT and BLOB work in  
MySQL 3.23?




> currently pdo_mysql is unable to discern between a BLOB and a TEXT  
> field
> in mysql_statement.c
> By using the current  if (IS_BLOB(F->flags)), which is now  
> deprecated in
> the mysql c api, it will be true for both TEXT and BLOB fields.
>
> By updating a little to the newer api and checking with F->type we get
> the same result, however, further checking on the character set number
> can distinguish between BINARY and CHAR, VARBINARY and VARCHAR, and  
> BLOB
> and TEXT fields.
>
> When using PDOStatement::getColumnMeta() any field with charsetnr  
> of 63
> reports as text, rather than blob. Patch follows...
>
> --- old.c       2007-06-26 11:27:57.000000000 +1000
> +++ mysql_statement.c   2007-06-26 11:26:47.000000000 +1000
> @@ -581,8 +581,12 @@
>         if (F->flags & UNIQUE_KEY_FLAG) {
>                 add_next_index_string(flags, "unique_key", 1);
>         }
> -       if (IS_BLOB(F->flags)) {
> -               add_next_index_string(flags, "blob", 1);
> +       if(F->type == MYSQL_TYPE_BLOB)  {
> +               if(F->charsetnr == 63) {
> +                       add_next_index_string(flags, "blob", 1);
> +               } else {
> +                       add_next_index_string(flags, "text", 1);
> +               }
>         }
>         str = type_to_name_native(F->type);
>         if (str) {
>
>
>
>
> -- 
> "Democracy is two wolves and a lamb voting on what to have for lunch.
> Liberty is a well-armed lamb contesting the vote."
>
> -- 
> 
> 
>

Ilia Alshanetsky

---

## #30337 — Kevin Waterson — 2007-06-26T02:39:20+00:00

URL: https://externals.io/message/30335#30337 · In reply to: #30336

This one time, at band camp, Ilia Alshanetsky <ilia@prohost.org> wrote:

> Will this mechanism for differentiating between TEXT and BLOB work in  
> MySQL 3.23?

unable to test with 3.* 

Kevin

-- 
"Democracy is two wolves and a lamb voting on what to have for lunch. 
Liberty is a well-armed lamb contesting the vote."

---

## #30338 — Kevin Waterson — 2007-06-26T02:39:58+00:00

URL: https://externals.io/message/30335#30338 · In reply to: #30336

This one time, at band camp, Ilia Alshanetsky <ilia@prohost.org> wrote:

> Will this mechanism for differentiating between TEXT and BLOB work in  
> MySQL 3.23?

unable to test with 3.* 

Kevin

-- 
"Democracy is two wolves and a lamb voting on what to have for lunch. 
Liberty is a well-armed lamb contesting the vote."

---

## #30339 — Kevin Waterson — 2007-06-26T06:26:48+00:00

URL: https://externals.io/message/30335#30339 · In reply to: #30336

This one time, at band camp, Ilia Alshanetsky <ilia@prohost.org> wrote:

> Will this mechanism for differentiating between TEXT and BLOB work in  
> MySQL 3.23?

From what I can see of the c api, the 3.23 and 4 api is the same. So
should work in both.

Kevin


-- 
"Democracy is two wolves and a lamb voting on what to have for lunch. 
Liberty is a well-armed lamb contesting the vote."
