@@ -323,10 +323,14 @@ static int really_register_bound_param(struct pdo_bound_param_data *param, pdo_s
323
323
}
324
324
return 0 ;
325
325
}
326
-
327
- /* tell the driver we just created a parameter */
326
+
327
+ /* ask the driver to perform any normalization it needs on the
328
+ * parameter name. Note that it is illegal for the driver to take
329
+ * a reference to param, as it resides in transient storage only
330
+ * at this time. */
328
331
if (stmt -> methods -> param_hook ) {
329
- if (!stmt -> methods -> param_hook (stmt , param , PDO_PARAM_EVT_ALLOC TSRMLS_CC )) {
332
+ if (!stmt -> methods -> param_hook (stmt , param , PDO_PARAM_EVT_NORMALIZE
333
+ TSRMLS_CC )) {
330
334
if (param -> name ) {
331
335
efree (param -> name );
332
336
param -> name = NULL ;
@@ -335,16 +339,36 @@ static int really_register_bound_param(struct pdo_bound_param_data *param, pdo_s
335
339
}
336
340
}
337
341
342
+ /* delete any other parameter registered with this number.
343
+ * If the parameter is named, it will be removed and correctly
344
+ * disposed of by the hash_update call that follows */
338
345
if (param -> paramno >= 0 ) {
339
346
zend_hash_index_del (hash , param -> paramno );
340
347
}
341
-
348
+
349
+ /* allocate storage for the parameter, keyed by its "canonical" name */
342
350
if (param -> name ) {
343
- zend_hash_update (hash , param -> name , param -> namelen , param , sizeof (* param ), (void * * )& pparam );
351
+ zend_hash_update (hash , param -> name , param -> namelen , param ,
352
+ sizeof (* param ), (void * * )& pparam );
344
353
} else {
345
- zend_hash_index_update (hash , param -> paramno , param , sizeof (* param ), (void * * )& pparam );
354
+ zend_hash_index_update (hash , param -> paramno , param , sizeof (* param ),
355
+ (void * * )& pparam );
346
356
}
347
357
358
+ /* tell the driver we just created a parameter */
359
+ if (stmt -> methods -> param_hook ) {
360
+ if (!stmt -> methods -> param_hook (stmt , pparam , PDO_PARAM_EVT_ALLOC
361
+ TSRMLS_CC )) {
362
+ /* undo storage allocation; the hash will free the parameter
363
+ * name if required */
364
+ if (pparam -> name ) {
365
+ zend_hash_del (hash , pparam -> name , pparam -> namelen );
366
+ } else {
367
+ zend_hash_index_del (hash , pparam -> paramno );
368
+ }
369
+ return 0 ;
370
+ }
371
+ }
348
372
return 1 ;
349
373
}
350
374
/* }}} */
0 commit comments