Skip to content

Commit d1538d5

Browse files
David EllingsworthDavid Ellingsworth
David Ellingsworth
authored and
David Ellingsworth
committed
Add additional flags to the output returned from the getColumnMeta() method for the pdo_mysql driver.
1 parent a7bd911 commit d1538d5

File tree

2 files changed

+50
-7
lines changed

2 files changed

+50
-7
lines changed

ext/mysqlnd/mysqlnd_enum_n_def.h

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -348,14 +348,27 @@ typedef enum mysqlnd_server_option
348348
#define SET_FLAG 2048
349349
#define NO_DEFAULT_VALUE_FLAG 4096
350350
#define ON_UPDATE_NOW_FLAG 8192
351+
#define NUM_FLAG 32768
352+
353+
/* The following flags are marked as internal in mysql_com.h */
351354
#define PART_KEY_FLAG 16384
352355
#define GROUP_FLAG 32768
353-
#define NUM_FLAG 32768
354356

355-
#define IS_PRI_KEY(n) ((n) & PRI_KEY_FLAG)
356-
#define IS_NOT_NULL(n) ((n) & NOT_NULL_FLAG)
357-
#define IS_BLOB(n) ((n) & BLOB_FLAG)
358-
#define IS_NUM(t) ((t) <= FIELD_TYPE_INT24 || (t) == FIELD_TYPE_YEAR || (t) == FIELD_TYPE_NEWDECIMAL)
357+
#define IS_NOT_NULL(n) ((n) & NOT_NULL_FLAG)
358+
#define IS_PRI_KEY(n) ((n) & PRI_KEY_FLAG)
359+
#define IS_UNIQUE_KEY(n) ((n) & UNIQUE_KEY_FLAG)
360+
#define IS_MULTIPLE_KEY(n) ((n) & MULTIPLE_KEY_FLAG)
361+
#define IS_BLOB(n) ((n) & BLOB_FLAG)
362+
#define IS_UNSIGNED(n) ((n) & UNSIGNED_FLAG)
363+
#define IS_ZEROFILL(n) ((n) & ZEROFILL_FLAG)
364+
#define IS_BINARY(n) ((n) & BINARY_FLAG)
365+
#define IS_ENUM(n) ((n) & ENUM_FLAG)
366+
#define IS_AUTO_INCREMENT ((n) & AUTO_INCREMENT_FLAG)
367+
#define IS_TIMESTAMP ((n) & TIMESTAMP_FLAG)
368+
#define IS_SET(n) ((n) & SET_FLAG)
369+
#define IS_NO_DEFAULT_VALUE ((n) & NO_DEFAULT_VALUE_FLAG)
370+
#define IS_ON_UPDATE_NOW ((n) & ON_UPDATE_NOW_FLAG)
371+
#define IS_NUM(n) ((n) & NUM_FLAG)
359372

360373

361374
/*

ext/pdo_mysql/mysql_statement.c

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -793,15 +793,45 @@ static int pdo_mysql_stmt_col_meta(pdo_stmt_t *stmt, zend_long colno, zval *retu
793793
if (IS_PRI_KEY(F->flags)) {
794794
add_next_index_string(&flags, "primary_key");
795795
}
796-
if (F->flags & MULTIPLE_KEY_FLAG) {
796+
if (IS_MULTIPLE_KEY(F->flags)) {
797797
add_next_index_string(&flags, "multiple_key");
798798
}
799-
if (F->flags & UNIQUE_KEY_FLAG) {
799+
if (IS_UNIQUE_KEY(F->flags)) {
800800
add_next_index_string(&flags, "unique_key");
801801
}
802802
if (IS_BLOB(F->flags)) {
803803
add_next_index_string(&flags, "blob");
804804
}
805+
if (IS_UNSIGNED(F->flags)) {
806+
add_next_index_string(&flags, "unsigned");
807+
}
808+
if (IS_ZEROFILL(F->flags)) {
809+
add_next_index_string(&flags, "zerofill");
810+
}
811+
if (IS_BINARY(F->flags)) {
812+
add_next_index_string(&flags, "binary");
813+
}
814+
if (IS_ENUM(F->flags)) {
815+
add_next_index_string(&flags, "enum");
816+
}
817+
if (IS_AUTO_INCREMENT(F->flags)) {
818+
add_next_index_string(&flags, "auto_increment");
819+
}
820+
if (IS_TIMESTAMP(F->flags)) {
821+
add_next_index_string(&flags, "timestamp");
822+
}
823+
if (IS_SET(F->flags)) {
824+
add_next_index_string(&flags, "set");
825+
}
826+
if (IS_NO_DEFAULT_VALUE(F->flags)) {
827+
add_next_index_string(&flags, "no_default_value");
828+
}
829+
if (IS_ON_UPDATE_NOW(F->flags)) {
830+
add_next_index_string(&flags, "on_update_now");
831+
}
832+
if (IS_NUM(F->flags)) {
833+
add_next_index_string(&flags, "num");
834+
}
805835
str = type_to_name_native(F->type);
806836
if (str) {
807837
add_assoc_string(return_value, "native_type", str);

0 commit comments

Comments
 (0)