]> granicus.if.org Git - postgresql/commitdiff
Fix SQL3 type return value.
authorMichael Meskes <meskes@postgresql.org>
Wed, 13 Jan 2010 08:41:50 +0000 (08:41 +0000)
committerMichael Meskes <meskes@postgresql.org>
Wed, 13 Jan 2010 08:41:50 +0000 (08:41 +0000)
For non-SQL3 types ecpg used to return -Oid. This will break if there are
enough Oids to fill the namespace. Therefore we play it safe and return 0 if
there is no Oid->SQL3 tyoe mapping available.

src/interfaces/ecpg/ecpglib/typename.c
src/interfaces/ecpg/test/expected/sql-dyntest.c
src/interfaces/ecpg/test/expected/sql-dyntest.stderr
src/interfaces/ecpg/test/expected/sql-dyntest.stdout
src/interfaces/ecpg/test/sql/dyntest.pgc

index 36df7a144dcd073dc1178a249beb16d0c78f2ca2..e24124ed9aabeb7965cb9f6e7e808f9f3036ce2d 100644 (file)
@@ -1,4 +1,4 @@
-/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/typename.c,v 1.16 2010/01/05 16:38:23 meskes Exp $ */
+/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/typename.c,v 1.17 2010/01/13 08:41:48 meskes Exp $ */
 
 #define POSTGRES_ECPG_INTERNAL
 #include "postgres_fe.h"
@@ -98,7 +98,7 @@ ecpg_dynamic_type(Oid type)
                case NUMERICOID:
                        return SQL3_NUMERIC;    /* numeric */
                default:
-                       return -(int) type;
+                       return 0;
        }
 }
 
index ebc8f22ed9d956fa05dbb3331a08ec8c78630597..1871e1338ff443454b764ff0af5e14e2bbb14a78 100644 (file)
@@ -385,10 +385,7 @@ if (sqlca.sqlcode < 0) error ( );}
                printf ("varchar()");
              break;
            default:
-             if (TYPE < 0)
-               printf ("<OID %d>", -TYPE);
-             else
-               printf ("<SQL3 %d>", TYPE);
+             printf ("<SQL3 %d>", TYPE);
              break;
            }
          printf (")\n\toctet_length: %d returned_octet_length: %d)\n\t= ",
@@ -402,10 +399,10 @@ if (sqlca.sqlcode < 0) error ( );}
              { ECPGget_desc(__LINE__, "MYDESC", INDEX,ECPGd_data,
        ECPGt_bool,&(BOOLVAR),(long)1,(long)1,sizeof(bool), ECPGd_EODT);
 
-#line 166 "dyntest.pgc"
+#line 163 "dyntest.pgc"
 
 if (sqlca.sqlcode < 0) error ( );}
-#line 166 "dyntest.pgc"
+#line 163 "dyntest.pgc"
 
                printf ("%s\n", BOOLVAR ? "true" : "false");
                break;
@@ -414,10 +411,10 @@ if (sqlca.sqlcode < 0) error ( );}
              { ECPGget_desc(__LINE__, "MYDESC", INDEX,ECPGd_data,
        ECPGt_int,&(INTVAR),(long)1,(long)1,sizeof(int), ECPGd_EODT);
 
-#line 171 "dyntest.pgc"
+#line 168 "dyntest.pgc"
 
 if (sqlca.sqlcode < 0) error ( );}
-#line 171 "dyntest.pgc"
+#line 168 "dyntest.pgc"
 
                printf ("%d\n", INTVAR);
                break;
@@ -425,10 +422,10 @@ if (sqlca.sqlcode < 0) error ( );}
              { ECPGget_desc(__LINE__, "MYDESC", INDEX,ECPGd_data,
        ECPGt_double,&(DOUBLEVAR),(long)1,(long)1,sizeof(double), ECPGd_EODT);
 
-#line 175 "dyntest.pgc"
+#line 172 "dyntest.pgc"
 
 if (sqlca.sqlcode < 0) error ( );}
-#line 175 "dyntest.pgc"
+#line 172 "dyntest.pgc"
 
                printf ("%.*f\n", PRECISION, DOUBLEVAR);
                break;
@@ -437,10 +434,10 @@ if (sqlca.sqlcode < 0) error ( );}
        ECPGt_char,(STRINGVAR),(long)1024,(long)1,(1024)*sizeof(char), ECPGd_di_code,
        ECPGt_int,&(DATETIME_INTERVAL_CODE),(long)1,(long)1,sizeof(int), ECPGd_EODT);
 
-#line 181 "dyntest.pgc"
+#line 178 "dyntest.pgc"
 
 if (sqlca.sqlcode < 0) error ( );}
-#line 181 "dyntest.pgc"
+#line 178 "dyntest.pgc"
 
                printf ("%d \"%s\"\n", DATETIME_INTERVAL_CODE, STRINGVAR);
                break;
@@ -449,10 +446,10 @@ if (sqlca.sqlcode < 0) error ( );}
              { ECPGget_desc(__LINE__, "MYDESC", INDEX,ECPGd_data,
        ECPGt_char,(STRINGVAR),(long)1024,(long)1,(1024)*sizeof(char), ECPGd_EODT);
 
-#line 186 "dyntest.pgc"
+#line 183 "dyntest.pgc"
 
 if (sqlca.sqlcode < 0) error ( );}
-#line 186 "dyntest.pgc"
+#line 183 "dyntest.pgc"
 
                printf ("\"%s\"\n", STRINGVAR);
                break;
@@ -460,10 +457,10 @@ if (sqlca.sqlcode < 0) error ( );}
              { ECPGget_desc(__LINE__, "MYDESC", INDEX,ECPGd_data,
        ECPGt_char,(STRINGVAR),(long)1024,(long)1,(1024)*sizeof(char), ECPGd_EODT);
 
-#line 190 "dyntest.pgc"
+#line 187 "dyntest.pgc"
 
 if (sqlca.sqlcode < 0) error ( );}
-#line 190 "dyntest.pgc"
+#line 187 "dyntest.pgc"
 
                printf ("<\"%s\">\n", STRINGVAR);
                break;
@@ -472,17 +469,17 @@ if (sqlca.sqlcode < 0) error ( );}
     }
 
   { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close MYCURS", ECPGt_EOIT, ECPGt_EORT);
-#line 197 "dyntest.pgc"
+#line 194 "dyntest.pgc"
 
 if (sqlca.sqlcode < 0) error ( );}
-#line 197 "dyntest.pgc"
+#line 194 "dyntest.pgc"
 
 
   ECPGdeallocate_desc(__LINE__, "MYDESC");
-#line 199 "dyntest.pgc"
+#line 196 "dyntest.pgc"
 
 if (sqlca.sqlcode < 0) error ( );
-#line 199 "dyntest.pgc"
+#line 196 "dyntest.pgc"
 
 
   return 0;
index a428e087ea0c866255ea04e387b257ee64d8c591..30b07056a143df2901a84397e911880b5c6cabfd 100644 (file)
@@ -64,7 +64,7 @@
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ECPGget_desc: reading items for tuple 1
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_get_data on line 186: RESULT: first entry    offset: -1; array: yes
+[NO_PID]: ecpg_get_data on line 183: RESULT: first entry    offset: -1; array: yes
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ECPGget_desc: reading items for tuple 2
 [NO_PID]: sqlca: code: 0, state: 00000
@@ -86,7 +86,7 @@
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ECPGget_desc: reading items for tuple 2
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_get_data on line 175: RESULT: 14.7 offset: -1; array: yes
+[NO_PID]: ecpg_get_data on line 172: RESULT: 14.7 offset: -1; array: yes
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ECPGget_desc: reading items for tuple 3
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ECPGget_desc: reading items for tuple 3
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_get_data on line 171: RESULT: 14 offset: -1; array: yes
+[NO_PID]: ecpg_get_data on line 168: RESULT: 14 offset: -1; array: yes
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ECPGget_desc: reading items for tuple 4
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ECPGget_desc: LENGTH = -5
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ECPGget_desc: TYPE = -20
+[NO_PID]: ECPGget_desc: TYPE = 0
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ECPGget_desc: INDICATOR[0] = 0
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ECPGget_desc: reading items for tuple 4
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_get_data on line 190: RESULT: 123045607890 offset: -1; array: yes
+[NO_PID]: ecpg_get_data on line 187: RESULT: 123045607890 offset: -1; array: yes
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ECPGget_desc: reading items for tuple 5
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ECPGget_desc: reading items for tuple 5
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_get_data on line 166: RESULT: t offset: -1; array: yes
+[NO_PID]: ecpg_get_data on line 163: RESULT: t offset: -1; array: yes
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ECPGget_desc: reading items for tuple 6
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ECPGget_desc: reading items for tuple 6
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_get_data on line 186: RESULT: The world's most advanced open source database. offset: -1; array: yes
+[NO_PID]: ecpg_get_data on line 183: RESULT: The world's most advanced open source database. offset: -1; array: yes
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ECPGget_desc: reading items for tuple 7
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ECPGget_desc: TYPE = 1
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_get_data on line 179: RESULT: 14.07.1987 offset: -1; array: yes
+[NO_PID]: ecpg_get_data on line 176: RESULT: 14.07.1987 offset: -1; array: yes
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 64: query: fetch in MYCURS; with 0 parameter(s) on connection regress1
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ECPGget_desc: reading items for tuple 1
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_get_data on line 186: RESULT: second entry   offset: -1; array: yes
+[NO_PID]: ecpg_get_data on line 183: RESULT: second entry   offset: -1; array: yes
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ECPGget_desc: reading items for tuple 2
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ECPGget_desc: reading items for tuple 2
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_get_data on line 175: RESULT: 1407.87 offset: -1; array: yes
+[NO_PID]: ecpg_get_data on line 172: RESULT: 1407.87 offset: -1; array: yes
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ECPGget_desc: reading items for tuple 3
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ECPGget_desc: reading items for tuple 3
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_get_data on line 171: RESULT: 1407 offset: -1; array: yes
+[NO_PID]: ecpg_get_data on line 168: RESULT: 1407 offset: -1; array: yes
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ECPGget_desc: reading items for tuple 4
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ECPGget_desc: LENGTH = -5
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ECPGget_desc: TYPE = -20
+[NO_PID]: ECPGget_desc: TYPE = 0
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ECPGget_desc: INDICATOR[0] = 0
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ECPGget_desc: reading items for tuple 4
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_get_data on line 190: RESULT: 987065403210 offset: -1; array: yes
+[NO_PID]: ecpg_get_data on line 187: RESULT: 987065403210 offset: -1; array: yes
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ECPGget_desc: reading items for tuple 5
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ECPGget_desc: reading items for tuple 5
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_get_data on line 166: RESULT: f offset: -1; array: yes
+[NO_PID]: ecpg_get_data on line 163: RESULT: f offset: -1; array: yes
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ECPGget_desc: reading items for tuple 6
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ECPGget_desc: reading items for tuple 6
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_get_data on line 186: RESULT: The elephant never forgets. offset: -1; array: yes
+[NO_PID]: ecpg_get_data on line 183: RESULT: The elephant never forgets. offset: -1; array: yes
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ECPGget_desc: reading items for tuple 7
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ECPGget_desc: TYPE = 1
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_get_data on line 179: RESULT: 05.11.1999 offset: -1; array: yes
+[NO_PID]: ecpg_get_data on line 176: RESULT: 05.11.1999 offset: -1; array: yes
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 64: query: fetch in MYCURS; with 0 parameter(s) on connection regress1
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: raising sqlcode 100 on line 64: no data found on line 64
 [NO_PID]: sqlca: code: 100, state: 02000
-[NO_PID]: ecpg_execute on line 197: query: close MYCURS; with 0 parameter(s) on connection regress1
+[NO_PID]: ecpg_execute on line 194: query: close MYCURS; with 0 parameter(s) on connection regress1
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 197: using PQexec
+[NO_PID]: ecpg_execute on line 194: using PQexec
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 197: OK: CLOSE CURSOR
+[NO_PID]: ecpg_execute on line 194: OK: CLOSE CURSOR
 [NO_PID]: sqlca: code: 0, state: 00000
index d198706ca9ce8d95707f2a627f433cfbf868a3f2..f8c4c8e43223ad184090dce09fa501e826f77555 100644 (file)
@@ -8,7 +8,7 @@ Found 7 columns
  3     i (type: 4 length: -5 precision: -1 scale: 65531 = integer)
        octet_length: 4 returned_octet_length: 2)
        = 14
- 4     bignumber (type: -20 length: -5 precision: -1 scale: 65531 = <OID 20>)
+ 4     bignumber (type: 0 length: -5 precision: -1 scale: 65531 = <SQL3 0>)
        octet_length: 8 returned_octet_length: 12)
        = <"123045607890">
  5     b (type: 16 length: -5 precision: -1 scale: 65531 = bool)
@@ -29,7 +29,7 @@ Found 7 columns
  3     i (type: 4 length: -5 precision: -1 scale: 65531 = integer)
        octet_length: 4 returned_octet_length: 4)
        = 1407
- 4     bignumber (type: -20 length: -5 precision: -1 scale: 65531 = <OID 20>)
+ 4     bignumber (type: 0 length: -5 precision: -1 scale: 65531 = <SQL3 0>)
        octet_length: 8 returned_octet_length: 12)
        = <"987065403210">
  5     b (type: 16 length: -5 precision: -1 scale: 65531 = bool)
index d917dd27c6377f7724ffe10041a4b5411086420f..5c615a091f5268dc91a5366b6fa0e07503f53939 100644 (file)
@@ -149,10 +149,7 @@ main ()
                printf ("varchar()");
              break;
            default:
-             if (TYPE < 0)
-               printf ("<OID %d>", -TYPE);
-             else
-               printf ("<SQL3 %d>", TYPE);
+             printf ("<SQL3 %d>", TYPE);
              break;
            }
          printf (")\n\toctet_length: %d returned_octet_length: %d)\n\t= ",