@@ -212,8 +212,7 @@ static void
212
212
ps_fetch_time (zval * zv , const MYSQLND_FIELD * const field , const unsigned int pack_len , const zend_uchar * * row )
213
213
{
214
214
struct st_mysqlnd_time t ;
215
- zend_ulong length ; /* First byte encodes the length*/
216
- char * value ;
215
+ zend_ulong length ; /* First byte encodes the length */
217
216
DBG_ENTER ("ps_fetch_time" );
218
217
219
218
if ((length = php_mysqlnd_net_field_length (row ))) {
@@ -241,24 +240,13 @@ ps_fetch_time(zval * zv, const MYSQLND_FIELD * const field, const unsigned int p
241
240
}
242
241
243
242
if (field -> decimals > 0 && field -> decimals < 7 ) {
244
- length = mnd_sprintf (
245
- & value ,
246
- 0 ,
247
- "%s%02u:%02u:%02u.%0*u" ,
248
- (t .neg ? "-" : "" ),
249
- t .hour ,
250
- t .minute ,
251
- t .second ,
252
- field -> decimals ,
253
- (uint32_t ) (t .second_part / pow (10 , 6 - field -> decimals ))
254
- );
243
+ ZVAL_STR (zv , zend_strpprintf (0 , "%s%02u:%02u:%02u.%0*u" ,
244
+ (t .neg ? "-" : "" ), t .hour , t .minute , t .second , field -> decimals ,
245
+ (uint32_t ) (t .second_part / pow (10 , 6 - field -> decimals ))));
255
246
} else {
256
- length = mnd_sprintf (& value , 0 , "%s%02u:%02u:%02u" , (t .neg ? "-" : "" ), t .hour , t .minute , t .second );
247
+ ZVAL_STR (zv , zend_strpprintf (0 , "%s%02u:%02u:%02u" ,
248
+ (t .neg ? "-" : "" ), t .hour , t .minute , t .second ));
257
249
}
258
-
259
- DBG_INF_FMT ("%s" , value );
260
- ZVAL_STRINGL (zv , value , length );
261
- mnd_sprintf_free (value );
262
250
DBG_VOID_RETURN ;
263
251
}
264
252
/* }}} */
@@ -270,7 +258,6 @@ ps_fetch_date(zval * zv, const MYSQLND_FIELD * const field, const unsigned int p
270
258
{
271
259
struct st_mysqlnd_time t = {0 };
272
260
zend_ulong length ; /* First byte encodes the length*/
273
- char * value ;
274
261
DBG_ENTER ("ps_fetch_date" );
275
262
276
263
if ((length = php_mysqlnd_net_field_length (row ))) {
@@ -291,11 +278,7 @@ ps_fetch_date(zval * zv, const MYSQLND_FIELD * const field, const unsigned int p
291
278
t .time_type = MYSQLND_TIMESTAMP_DATE ;
292
279
}
293
280
294
- length = mnd_sprintf (& value , 0 , "%04u-%02u-%02u" , t .year , t .month , t .day );
295
-
296
- DBG_INF_FMT ("%s" , value );
297
- ZVAL_STRINGL (zv , value , length );
298
- mnd_sprintf_free (value );
281
+ ZVAL_STR (zv , zend_strpprintf (0 , "%04u-%02u-%02u" , t .year , t .month , t .day ));
299
282
DBG_VOID_RETURN ;
300
283
}
301
284
/* }}} */
@@ -307,7 +290,6 @@ ps_fetch_datetime(zval * zv, const MYSQLND_FIELD * const field, const unsigned i
307
290
{
308
291
struct st_mysqlnd_time t ;
309
292
zend_ulong length ; /* First byte encodes the length*/
310
- char * value ;
311
293
DBG_ENTER ("ps_fetch_datetime" );
312
294
313
295
if ((length = php_mysqlnd_net_field_length (row ))) {
@@ -336,26 +318,13 @@ ps_fetch_datetime(zval * zv, const MYSQLND_FIELD * const field, const unsigned i
336
318
}
337
319
338
320
if (field -> decimals > 0 && field -> decimals < 7 ) {
339
- length = mnd_sprintf (
340
- & value ,
341
- 0 ,
342
- "%04u-%02u-%02u %02u:%02u:%02u.%0*u" ,
343
- t .year ,
344
- t .month ,
345
- t .day ,
346
- t .hour ,
347
- t .minute ,
348
- t .second ,
349
- field -> decimals ,
350
- (uint32_t ) (t .second_part / pow (10 , 6 - field -> decimals ))
351
- );
321
+ ZVAL_STR (zv , zend_strpprintf (0 , "%04u-%02u-%02u %02u:%02u:%02u.%0*u" ,
322
+ t .year , t .month , t .day , t .hour , t .minute , t .second , field -> decimals ,
323
+ (uint32_t ) (t .second_part / pow (10 , 6 - field -> decimals ))));
352
324
} else {
353
- length = mnd_sprintf (& value , 0 , "%04u-%02u-%02u %02u:%02u:%02u" , t .year , t .month , t .day , t .hour , t .minute , t .second );
325
+ ZVAL_STR (zv , zend_strpprintf (0 , "%04u-%02u-%02u %02u:%02u:%02u" ,
326
+ t .year , t .month , t .day , t .hour , t .minute , t .second ));
354
327
}
355
-
356
- DBG_INF_FMT ("%s" , value );
357
- ZVAL_STRINGL (zv , value , length );
358
- mnd_sprintf_free (value );
359
328
DBG_VOID_RETURN ;
360
329
}
361
330
/* }}} */
@@ -365,15 +334,11 @@ ps_fetch_datetime(zval * zv, const MYSQLND_FIELD * const field, const unsigned i
365
334
static void
366
335
ps_fetch_string (zval * zv , const MYSQLND_FIELD * const field , const unsigned int pack_len , const zend_uchar * * row )
367
336
{
368
- /*
369
- For now just copy, before we make it possible
370
- to write \0 to the row buffer
371
- */
372
337
const zend_ulong length = php_mysqlnd_net_field_length (row );
373
338
DBG_ENTER ("ps_fetch_string" );
374
339
DBG_INF_FMT ("len = %lu" , length );
375
340
DBG_INF ("copying from the row buffer" );
376
- ZVAL_STRINGL (zv , (char * )* row , length );
341
+ ZVAL_STRINGL_FAST (zv , (char * )* row , length );
377
342
378
343
(* row ) += length ;
379
344
DBG_VOID_RETURN ;
0 commit comments