5 messages in com.mysql.lists.perl[PATCH] add mysql_is_auto_increment s...
FromSent OnAttachments
Paul Walmsley10 Apr 2002 19:38 
Jochen Wiedmann11 Apr 2002 00:18 
Paul Walmsley11 Apr 2002 10:32 
Jochen Wiedmann11 Apr 2002 23:45 
Jochen Wiedmann12 Apr 2002 00:07 
Subject:[PATCH] add mysql_is_auto_increment sth attribute
From:Paul Walmsley (shag@booyaka.com)
Date:04/10/2002 07:38:17 PM
List:com.mysql.lists.perl

This patch, enclosed below, adds a 'mysql_is_auto_increment' statement handle attribute to DBD::mysql. It operates similarly to statement handle attributes such as 'mysql_is_pri_key' or 'mysql_is_num'.

The motivation behind this patch is to support table structure inspection; I am presently working on code that requires this feature.

Comments welcomed.

- Paul

diff -ru Msql-Mysql-modules-1.2219/dbd/dbdimp.c
Msql-Mysql-modules-1.2219-new/dbd/dbdimp.c --- Msql-Mysql-modules-1.2219/dbd/dbdimp.c Sat Apr 7 08:32:37 2001 +++ Msql-Mysql-modules-1.2219-new/dbd/dbdimp.c Wed Apr 10 20:27:03 2002 @@ -1616,6 +1616,10 @@ #define IS_KEY(A) (((A) & (PRI_KEY_FLAG | UNIQUE_KEY_FLAG | MULTIPLE_KEY_FLAG))
!= 0) #endif

+#ifndef IS_AUTO_INCREMENT +#define IS_AUTO_INCREMENT(A) (((A) & AUTO_INCREMENT_FLAG) != 0) +#endif + SV* dbd_st_FETCH_internal(SV* sth, int what, result_t res, int cacheit) { D_imp_sth(sth); AV *av = Nullav; @@ -1684,6 +1688,9 @@ case AV_ATTRIB_MAX_LENGTH: sv = newSViv((int) curField->max_length); break; + case AV_ATTRIB_IS_AUTO_INCREMENT: + sv = boolSV(IS_AUTO_INCREMENT(curField->flags)); + break; case AV_ATTRIB_IS_KEY: sv = boolSV(IS_KEY(curField->flags)); break; @@ -2010,6 +2017,11 @@ } else if (strEQ(key, "mysql_use_result")) { retsv = boolSV(imp_sth->use_mysql_use_result); } + break; + case 23: + if (strEQ(key, "mysql_is_auto_increment")) { + retsv = ST_FETCH_AV(AV_ATTRIB_IS_AUTO_INCREMENT); + }; break; } #else diff -ru Msql-Mysql-modules-1.2219/dbd/dbdimp.h
Msql-Mysql-modules-1.2219-new/dbd/dbdimp.h --- Msql-Mysql-modules-1.2219/dbd/dbdimp.h Sat Apr 7 08:15:15 2001 +++ Msql-Mysql-modules-1.2219-new/dbd/dbdimp.h Wed Apr 10 20:27:03 2002 @@ -82,6 +82,7 @@ AV_ATTRIB_MAX_LENGTH, AV_ATTRIB_IS_KEY, AV_ATTRIB_IS_BLOB, + AV_ATTRIB_IS_AUTO_INCREMENT, #endif AV_ATTRIB_LAST /* Dummy attribute, never used, for allocation */ }; /* purposes only */ diff -ru Msql-Mysql-modules-1.2219/mysql/lib/DBD/mysql.pm
Msql-Mysql-modules-1.2219-new/mysql/lib/DBD/mysql.pm --- Msql-Mysql-modules-1.2219/mysql/lib/DBD/mysql.pm Wed Apr 10 18:39:28 2002 +++ Msql-Mysql-modules-1.2219-new/mysql/lib/DBD/mysql.pm Wed Apr 10 20:27:03
2002 @@ -761,6 +761,12 @@ respective column is a primary key. This is only valid for MySQL and mSQL 1.0.x: mSQL 2.x uses indices.

+=item mysql_is_auto_increment + +Reference to an array of boolean values; TRUE indicates that the +respective column is an AUTO_INCREMENT column. This is only valid +for MySQL. + =item mysql_length

=item mysql_max_length