From: Michael Wallner Date: Tue, 18 Jun 2019 10:02:30 +0000 (+0200) Subject: fix issue #19: Failed test with PgSQL < 9.3 X-Git-Tag: v2.1.6~5^2 X-Git-Url: https://git.m6w6.name/?a=commitdiff_plain;h=refs%2Fpull%2F33%2Fhead;p=m6w6%2Fext-pq fix issue #19: Failed test with PgSQL < 9.3 --- diff --git a/src/php_pqres.c b/src/php_pqres.c index 849f8bf..3427b38 100644 --- a/src/php_pqres.c +++ b/src/php_pqres.c @@ -491,65 +491,83 @@ static void php_pqres_object_read_error_message(zval *object, void *o, zval *ret } } -static void php_pqres_object_read_diag(zval *object, void *o, zval *return_value) -{ - php_pqres_object_t *obj = o; - int i; - struct { - char code; - const char *const name; - } diag[] = { -#ifdef PG_DIAG_SEVERITY - {PG_DIAG_SEVERITY, "severity"}, +#ifndef PG_DIAG_SEVERITY +# define PG_DIAG_SEVERITY 'S' #endif -#ifdef PG_DIAG_SQLSTATE - {PG_DIAG_SQLSTATE, "sqlstate"}, +#ifndef PG_DIAG_SQLSTATE +# define PG_DIAG_SQLSTATE 'C' #endif -#ifdef PG_DIAG_MESSAGE_PRIMARY - {PG_DIAG_MESSAGE_PRIMARY, "message_primary"}, +#ifndef PG_DIAG_MESSAGE_PRIMARY +# define PG_DIAG_MESSAGE_PRIMARY 'M' #endif -#ifdef PG_DIAG_MESSAGE_DETAIL - {PG_DIAG_MESSAGE_DETAIL, "message_detail"}, +#ifndef PG_DIAG_MESSAGE_DETAIL +# define PG_DIAG_MESSAGE_DETAIL 'D' #endif -#ifdef PG_DIAG_MESSAGE_HINT - {PG_DIAG_MESSAGE_HINT, "message_hint"}, +#ifndef PG_DIAG_MESSAGE_HINT +# define PG_DIAG_MESSAGE_HINT 'H' #endif -#ifdef PG_DIAG_STATEMENT_POSITION - {PG_DIAG_STATEMENT_POSITION,"statement_position"}, +#ifndef PG_DIAG_STATEMENT_POSITION +# define PG_DIAG_STATEMENT_POSITION 'P' #endif -#ifdef PG_DIAG_INTERNAL_POSITION - {PG_DIAG_INTERNAL_POSITION, "internal_position"}, +#ifndef PG_DIAG_INTERNAL_POSITION +# define PG_DIAG_INTERNAL_POSITION 'p' #endif -#ifdef PG_DIAG_INTERNAL_QUERY - {PG_DIAG_INTERNAL_QUERY, "internal_query"}, +#ifndef PG_DIAG_INTERNAL_QUERY +# define PG_DIAG_INTERNAL_QUERY 'q' #endif -#ifdef PG_DIAG_CONTEXT - {PG_DIAG_CONTEXT, "context"}, +#ifndef PG_DIAG_CONTEXT +# define PG_DIAG_CONTEXT 'W' #endif -#ifdef PG_DIAG_SCHEMA_NAME - {PG_DIAG_SCHEMA_NAME, "schema_name"}, +#ifndef PG_DIAG_SCHEMA_NAME +# define PG_DIAG_SCHEMA_NAME 's' #endif -#ifdef PG_DIAG_TABLE_NAME - {PG_DIAG_TABLE_NAME, "table_name"}, +#ifndef PG_DIAG_TABLE_NAME +# define PG_DIAG_TABLE_NAME 't' #endif -#ifdef PG_DIAG_COLUMN_NAME - {PG_DIAG_COLUMN_NAME, "column_name"}, +#ifndef PG_DIAG_COLUMN_NAME +# define PG_DIAG_COLUMN_NAME 'c' #endif -#ifdef PG_DIAG_DATATYPE_NAME - {PG_DIAG_DATATYPE_NAME, "datatype_name"}, +#ifndef PG_DIAG_DATATYPE_NAME +# define PG_DIAG_DATATYPE_NAME 'd' #endif -#ifdef PG_DIAG_CONSTRAINT_NAME - {PG_DIAG_CONSTRAINT_NAME, "constraint_name"}, +#ifndef PG_DIAG_CONSTRAINT_NAME +# define PG_DIAG_CONSTRAINT_NAME 'n' #endif -#ifdef PG_DIAG_SOURCE_FILE - {PG_DIAG_SOURCE_FILE, "source_file"}, +#ifndef PG_DIAG_SOURCE_FILE +# define PG_DIAG_SOURCE_FILE 'F' #endif -#ifdef PG_DIAG_SOURCE_LINE - {PG_DIAG_SOURCE_LINE, "source_line"}, +#ifndef PG_DIAG_SOURCE_LINE +# define PG_DIAG_SOURCE_LINE 'L' #endif -#ifdef PG_DIAG_SOURCE_FUNCTION - {PG_DIAG_SOURCE_FUNCTION, "source_function"}, +#ifndef PG_DIAG_SOURCE_FUNCTION +# define PG_DIAG_SOURCE_FUNCTION 'R' #endif + +static void php_pqres_object_read_diag(zval *object, void *o, zval *return_value) +{ + php_pqres_object_t *obj = o; + int i; + struct { + char code; + const char *const name; + } diag[] = { + {PG_DIAG_SEVERITY, "severity"}, + {PG_DIAG_SQLSTATE, "sqlstate"}, + {PG_DIAG_MESSAGE_PRIMARY, "message_primary"}, + {PG_DIAG_MESSAGE_DETAIL, "message_detail"}, + {PG_DIAG_MESSAGE_HINT, "message_hint"}, + {PG_DIAG_STATEMENT_POSITION,"statement_position"}, + {PG_DIAG_INTERNAL_POSITION, "internal_position"}, + {PG_DIAG_INTERNAL_QUERY, "internal_query"}, + {PG_DIAG_CONTEXT, "context"}, + {PG_DIAG_SCHEMA_NAME, "schema_name"}, + {PG_DIAG_TABLE_NAME, "table_name"}, + {PG_DIAG_COLUMN_NAME, "column_name"}, + {PG_DIAG_DATATYPE_NAME, "datatype_name"}, + {PG_DIAG_CONSTRAINT_NAME, "constraint_name"}, + {PG_DIAG_SOURCE_FILE, "source_file"}, + {PG_DIAG_SOURCE_LINE, "source_line"}, + {PG_DIAG_SOURCE_FUNCTION, "source_function"}, }; array_init_size(return_value, 32);