Skip to content

Commit 43ed1aa

Browse files
committed
Change check to assertion as it is handled before calling said function
1 parent 2f20f98 commit 43ed1aa

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

ext/pgsql/pgsql.c

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4261,6 +4261,7 @@ PHP_FUNCTION(pg_flush)
42614261
/* }}} */
42624262

42634263
/* {{{ php_pgsql_meta_data
4264+
* table_name must not be empty
42644265
* TODO: Add meta_data cache for better performance
42654266
*/
42664267
PHP_PGSQL_API int php_pgsql_meta_data(PGconn *pg_link, const char *table_name, zval *meta, zend_bool extended)
@@ -4273,11 +4274,7 @@ PHP_PGSQL_API int php_pgsql_meta_data(PGconn *pg_link, const char *table_name, z
42734274
int i, num_rows;
42744275
zval elem;
42754276

4276-
if (!*table_name) {
4277-
// CHeck if can be TODO
4278-
php_error_docref(NULL, E_WARNING, "The table name must be specified");
4279-
return FAILURE;
4280-
}
4277+
ZEND_ASSERT(*table_name);
42814278

42824279
src = estrdup(table_name);
42834280
tmp_name = php_strtok_r(src, ".", &tmp_name2);
@@ -4393,7 +4390,7 @@ PHP_FUNCTION(pg_meta_data)
43934390
RETURN_THROWS();
43944391
}
43954392

4396-
/* php_pgsql_meta_data() warns on empty table_name */
4393+
/* php_pgsql_meta_data() asserts that table_name is not empty */
43974394
if (table_name_len == 0) {
43984395
zend_argument_value_error(2, "cannot be empty");
43994396
RETURN_THROWS();
@@ -4604,6 +4601,8 @@ PHP_PGSQL_API int php_pgsql_convert(PGconn *pg_link, const char *table_name, con
46044601
ZEND_ASSERT(Z_TYPE_P(result) == IS_ARRAY);
46054602
ZEND_ASSERT(!(opt & ~PGSQL_CONV_OPTS));
46064603
ZEND_ASSERT(table_name);
4604+
/* Table name cannot be empty for php_pgsql_meta_data() */
4605+
ZEND_ASSERT(*table_name);
46074606

46084607
array_init(&meta);
46094608
/* table_name is escaped by php_pgsql_meta_data */

0 commit comments

Comments
 (0)