pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Function to split pg_trigger.tgargs
2+ messages / 2 participants
[nested] [flat]

* Function to split pg_trigger.tgargs
@ 2002-02-18 05:35  Christopher Kings-Lynne <chriskl@familyhealth.com.au>
  0 siblings, 1 reply; 2+ messages in thread

From: Christopher Kings-Lynne @ 2002-02-18 05:35 UTC (permalink / raw)
  To: Hackers <pgsql-hackers@postgresql.org>; pgsql-sql

Hi All,

Is there a function in the catalogs somewhere that will split this?:

australia=# select tgargs from pg_trigger where oid=3842228;
                                             tgargs

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

<unnamed>\000users_mealplans_prefs\000medidiets_meals\000UNSPECIFIED\000meal
_id\0
00meal_id\000
(1 row)

I'm hoping to do the splitting within pl/pgsql even.  If there is no
function to break it up, can someone please suggest how I would code taking
this string and breaking it into components.

Chris




^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: Function to split pg_trigger.tgargs
@ 2002-02-18 12:40  Rod Taylor <rbt@zort.ca>
  parent: Christopher Kings-Lynne <chriskl@familyhealth.com.au>
  0 siblings, 0 replies; 2+ messages in thread

From: Rod Taylor @ 2002-02-18 12:40 UTC (permalink / raw)
  To: Christopher Kings-Lynne <chriskl@familyhealth.com.au>; Hackers <pgsql-hackers@postgresql.org>; pgsql-sql

http://www.zort.ca/postgresql/postgresql_autodoc_0.50.tar.gz

The below is taken from the above.

    my $args = $forcols->{'args'};
    my $nargs = $forcols->{'number_args'};

    if ($nargs == 6) {
      my ( $keyname
         , $table
         , $ftable
         , $unspecified
         , $lcolumn_name
         , $fcolumn_name
         ) = split(/\000/, $args);

      $structure{$group}{$table_name}{'COLUMN'}{$lcolumn_name}{'FK'} =
"$ftable";  #.$fcolumn_name";

      # print "   FK   $lcolumn_name -> $ftable.$fcolumn_name\n";
    } elsif (($nargs - 6) % 2 == 0) {
      my ( $keyname
         , $table
         , $ftable
         , $unspecified
         , $lcolumn_name
         , $fcolumn_name
         , @junk
         ) = split(/\000/, $args);

      my $key_cols = "$lcolumn_name";
      my $ref_cols = "$fcolumn_name";

      while ($lcolumn_name = pop(@junk) and $fcolumn_name =
pop(@junk)) {

        $key_cols .= ", $lcolumn_name";
        $ref_cols .= ", $fcolumn_name";
      }

      $structure{$group}{$table_name}{'CONSTRAINT'}{$constraint_name}
= "FOREIGN KEY ($key_cols) REFERENCES $ftable($ref_cols)";
    }
--
Rod Taylor

This message represents the official view of the voices in my head

----- Original Message -----
From: "Christopher Kings-Lynne" <chriskl@familyhealth.com.au>
To: "Hackers" <pgsql-hackers@postgresql.org>;
<pgsql-sql@postgresql.org>
Sent: Monday, February 18, 2002 12:35 AM
Subject: [HACKERS] Function to split pg_trigger.tgargs


> Hi All,
>
> Is there a function in the catalogs somewhere that will split this?:
>
> australia=# select tgargs from pg_trigger where oid=3842228;
>                                              tgargs
>
> --------------------------------------------------------------------
--------
> ------
> --------------
>
>
<unnamed>\000users_mealplans_prefs\000medidiets_meals\000UNSPECIFIED\0
00meal
> _id\0
> 00meal_id\000
> (1 row)
>
> I'm hoping to do the splitting within pl/pgsql even.  If there is no
> function to break it up, can someone please suggest how I would code
taking
> this string and breaking it into components.
>
> Chris
>
>
> ---------------------------(end of
broadcast)---------------------------
> TIP 1: subscribe and unsubscribe commands go to
majordomo@postgresql.org
>




^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2002-02-18 12:40 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2002-02-18 05:35 Function to split pg_trigger.tgargs Christopher Kings-Lynne <chriskl@familyhealth.com.au>
2002-02-18 12:40 ` Rod Taylor <rbt@zort.ca>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox