Обсуждение: Patch for Bug No: 1254

Поиск
Список
Период
Сортировка

Patch for Bug No: 1254

От
"Anoop Kumar"
Дата:
I am sending a patch for the following bug:

http://gborg.postgresql.org/project/psqlodbc/bugs/bugupdate.php?1254

The patch was tested on postgresql (ver. 8.0.1), psqlodbc (ver.
08.00.0101), Windows XP (client side) and Windows XP with SP2 (Server
end)/Fedora Core 3 (Server end).


Regards

Anoop

------------------------------------------------------------------------
-----------------------------------------
Index: info.c
===================================================================
RCS file: /usr/local/cvsroot/psqlodbc/info.c,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 info.c
--- info.c    21 Apr 2005 05:27:13 -0000    1.1.1.1
+++ info.c    21 Apr 2005 05:29:28 -0000
@@ -1217,6 +1217,7 @@
                 table_types[MAX_INFO_STRING];
     char        show_system_tables,
                 show_regular_tables,
+                remarks[254], //Added for holding Table
Description, if any.
                 show_views;
     char        regular_table,
                 view,
@@ -1254,9 +1255,18 @@
     if (conn->schema_support)
     {
         /* view is represented by its relkind since 7.1 */
-        strcpy(tables_query, "select relname, nspname, relkind"
-        " from pg_catalog.pg_class c, pg_catalog.pg_namespace
n");
-        strcat(tables_query, " where relkind in ('r', 'v')");
+
+        /* Previously it was:
+         * strcpy(tables_query, "select relname, nspname,
relkind"
+         * from pg_catalog.pg_class c, pg_catalog.pg_namespace
n");
+         * strcat(tables_query, " where relkind in ('r', 'v')");
+         * Modified query to retrieve the description of the
table:
+         */
+
+        strcpy(tables_query,"SELECT DISTINCT tt.relname,
tt.nspname, tt.relkind, COALESCE(d.description,'') from");
+        strcat(tables_query," (SELECT c.oid as oid, c.tableoid as
tableoid, n.nspname as nspname, c.relname, c.relkind");
+        strcat(tables_query," FROM pg_catalog.pg_class c LEFT
JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace");
+        strcat(tables_query," WHERE c.relkind IN ('r', 'v') ");
     }
     else if (PG_VERSION_GE(conn, 7.1))
     {
@@ -1367,7 +1377,16 @@
         strcat(tables_query, " and relname !~ '^xinv[0-9]+'");

     if (conn->schema_support)
-        strcat(tables_query, " and n.oid = relnamespace order by
nspname, relname");
+    {
+        /* Previously it was:
+         * strcat(tables_query, " and n.oid = relnamespace order
by nspname, relname");
+         * Modified query to retrieve the description of the
table:
+         */
+
+        strcat(tables_query," ) AS tt LEFT JOIN
pg_catalog.pg_description d ");
+        strcat(tables_query," ON (tt.oid = d.objoid AND
tt.tableoid = d.classoid AND d.objsubid = 0)");
+        strcat(tables_query," order by nspname, relname");
+    }
     else
         strcat(tables_query, " and usesysid = relowner order by
relname");

@@ -1427,7 +1446,15 @@
         SC_error_copy(stmt, tbl_stmt);
         goto cleanup;
     }
-
+    /* Binds the description column to variable 'remarks' */
+    result = PGAPI_BindCol(htbl_stmt, 4, internal_asis_type,
+                               remarks, 254,
NULL);
+    if ((result != SQL_SUCCESS) && (result !=
SQL_SUCCESS_WITH_INFO))
+    {
+            SC_error_copy(stmt, tbl_stmt);
+            goto cleanup;
+    }
+
     if (res = QR_Constructor(), !res)
     {
         SC_set_error(stmt, STMT_NO_MEMORY_ERROR, "Couldn't
allocate memory for PGAPI_Tables result.");
@@ -1525,7 +1552,7 @@
                 set_tuplefield_null(&row->tuple[1]);
             set_tuplefield_string(&row->tuple[2],
table_name);
             set_tuplefield_string(&row->tuple[3], systable ?
"SYSTEM TABLE" : (view ? "VIEW" : "TABLE"));
-            set_tuplefield_string(&row->tuple[4], "");
+            set_tuplefield_string(&row->tuple[4], remarks);
             /*** set_tuplefield_string(&row->tuple[4],
"TABLE"); ***/

             QR_add_tuple(res, row);

------------------------------------------------------------------------
---------------------------------------------

Re: Patch for Bug No: 1254

От
"Dave Page"
Дата:
Thanks Anoop, patch applied, bug closed.

Regards, Dave.

> -----Original Message-----
> From: pgsql-odbc-owner@postgresql.org
> [mailto:pgsql-odbc-owner@postgresql.org] On Behalf Of Anoop Kumar
> Sent: 21 April 2005 10:09
> To: pgsql-odbc@postgresql.org
> Subject: [ODBC] Patch for Bug No: 1254
>
> I am sending a patch for the following bug:
>
> http://gborg.postgresql.org/project/psqlodbc/bugs/bugupdate.php?1254
>
> The patch was tested on postgresql (ver. 8.0.1), psqlodbc (ver.
> 08.00.0101), Windows XP (client side) and Windows XP with SP2 (Server
> end)/Fedora Core 3 (Server end).
>
>
> Regards
>
> Anoop
>
> --------------------------------------------------------------
> ----------
> -----------------------------------------
> Index: info.c
> ===================================================================
> RCS file: /usr/local/cvsroot/psqlodbc/info.c,v
> retrieving revision 1.1.1.1
> diff -u -r1.1.1.1 info.c
> --- info.c    21 Apr 2005 05:27:13 -0000    1.1.1.1
> +++ info.c    21 Apr 2005 05:29:28 -0000
> @@ -1217,6 +1217,7 @@
>                  table_types[MAX_INFO_STRING];
>      char        show_system_tables,
>                  show_regular_tables,
> +                remarks[254], //Added for holding Table
> Description, if any.
>                  show_views;
>      char        regular_table,
>                  view,
> @@ -1254,9 +1255,18 @@
>      if (conn->schema_support)
>      {
>          /* view is represented by its relkind since 7.1 */
> -        strcpy(tables_query, "select relname, nspname, relkind"
> -        " from pg_catalog.pg_class c, pg_catalog.pg_namespace
> n");
> -        strcat(tables_query, " where relkind in ('r', 'v')");
> +
> +        /* Previously it was:
> +         * strcpy(tables_query, "select relname, nspname,
> relkind"
> +         * from pg_catalog.pg_class c, pg_catalog.pg_namespace
> n");
> +         * strcat(tables_query, " where relkind in ('r', 'v')");
> +         * Modified query to retrieve the description of the
> table:
> +         */
> +
> +        strcpy(tables_query,"SELECT DISTINCT tt.relname,
> tt.nspname, tt.relkind, COALESCE(d.description,'') from");
> +        strcat(tables_query," (SELECT c.oid as oid, c.tableoid as
> tableoid, n.nspname as nspname, c.relname, c.relkind");
> +        strcat(tables_query," FROM pg_catalog.pg_class c LEFT
> JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace");
> +        strcat(tables_query," WHERE c.relkind IN ('r', 'v') ");
>      }
>      else if (PG_VERSION_GE(conn, 7.1))
>      {
> @@ -1367,7 +1377,16 @@
>          strcat(tables_query, " and relname !~ '^xinv[0-9]+'");
>
>      if (conn->schema_support)
> -        strcat(tables_query, " and n.oid = relnamespace order by
> nspname, relname");
> +    {
> +        /* Previously it was:
> +         * strcat(tables_query, " and n.oid = relnamespace order
> by nspname, relname");
> +         * Modified query to retrieve the description of the
> table:
> +         */
> +
> +        strcat(tables_query," ) AS tt LEFT JOIN
> pg_catalog.pg_description d ");
> +        strcat(tables_query," ON (tt.oid = d.objoid AND
> tt.tableoid = d.classoid AND d.objsubid = 0)");
> +        strcat(tables_query," order by nspname, relname");
> +    }
>      else
>          strcat(tables_query, " and usesysid = relowner order by
> relname");
>
> @@ -1427,7 +1446,15 @@
>          SC_error_copy(stmt, tbl_stmt);
>          goto cleanup;
>      }
> -
> +    /* Binds the description column to variable 'remarks' */
> +    result = PGAPI_BindCol(htbl_stmt, 4, internal_asis_type,
> +                               remarks, 254,
> NULL);
> +    if ((result != SQL_SUCCESS) && (result !=
> SQL_SUCCESS_WITH_INFO))
> +    {
> +            SC_error_copy(stmt, tbl_stmt);
> +            goto cleanup;
> +    }
> +
>      if (res = QR_Constructor(), !res)
>      {
>          SC_set_error(stmt, STMT_NO_MEMORY_ERROR, "Couldn't
> allocate memory for PGAPI_Tables result.");
> @@ -1525,7 +1552,7 @@
>                  set_tuplefield_null(&row->tuple[1]);
>              set_tuplefield_string(&row->tuple[2],
> table_name);
>              set_tuplefield_string(&row->tuple[3], systable ?
> "SYSTEM TABLE" : (view ? "VIEW" : "TABLE"));
> -            set_tuplefield_string(&row->tuple[4], "");
> +            set_tuplefield_string(&row->tuple[4], remarks);
>              /*** set_tuplefield_string(&row->tuple[4],
> "TABLE"); ***/
>
>              QR_add_tuple(res, row);
>
> --------------------------------------------------------------
> ----------
> ---------------------------------------------
>
> ---------------------------(end of
> broadcast)---------------------------
> TIP 7: don't forget to increase your free space map settings
>