pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Rod Taylor <rbt@zort.ca>
To: Christopher Kings-Lynne <chriskl@familyhealth.com.au>
To: Hackers <pgsql-hackers@postgresql.org>
To: pgsql-sql@postgresql.org
Subject: Re: Function to split pg_trigger.tgargs
Date: Mon, 18 Feb 2002 07:40:16 -0500
Message-ID: <019001c1b879$6b4a2760$8001a8c0@jester> (raw)
References: <GNELIHDDFBOCMGBFGEFOEEGOCBAA.chriskl@familyhealth.com.au>

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
>




view thread (2+ messages)

Message-ID: <019001c1b879$6b4a2760$8001a8c0@jester>
Permalink:  ../019001c1b879$6b4a2760$8001a8c0@jester/
Also on:    postgresql.org/message-id/019001c1b879$6b4a2760$8001a8c0@jester

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: rbt@zort.ca, chriskl@familyhealth.com.au, pgsql-hackers@postgresql.org
  Subject: Re: Function to split pg_trigger.tgargs
  In-Reply-To: <019001c1b879$6b4a2760$8001a8c0@jester>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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