~ubuntu-branches/ubuntu/utopic/pgadmin3/utopic

« back to all changes in this revision

Viewing changes to docs/en_US/slony/function.determineidxnameunique-text-name.html

  • Committer: Bazaar Package Importer
  • Author(s): Raphael Enrici, src/frm/frmBackup.cpp, debian/control
  • Date: 2006-10-06 21:06:48 UTC
  • mfrom: (1.2.1 upstream) (2.1.2 edgy)
  • Revision ID: james.westby@ubuntu.com-20061006210648-nscnazrse5jbwswf
* Patched frmBackup.cpp to ensure the schema is specified when backing up
  individual tables. (Closes: #387256)
  [src/frm/frmBackup.cpp]
* Cleaned up and updated description of the package. (Closes: #379188)
  [debian/control]

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<html>
 
2
<head>
 
3
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
 
4
<title>1.37.�       determineidxnameunique( text, name )
 
5
      </title>
 
6
<link rel="stylesheet" href="stylesheet.css" type="text/css">
 
7
<link rev="made" href="pgsql-docs@postgresql.org">
 
8
<meta name="generator" content="DocBook XSL Stylesheets V1.70.1">
 
9
<link rel="start" href="index.html" title="Slony-I HEAD_20060719 Documentation">
 
10
<link rel="up" href="schema.html" title="Chapter�1.�Schema schemadoc">
 
11
<link rel="prev" href="function.determineidxnameserial-text.html" title="1.36.�       determineidxnameserial( text )
 
12
      ">
 
13
<link rel="next" href="function.disablenode-integer.html" title="1.38.�       disablenode( integer )
 
14
      ">
 
15
<link rel="copyright" href="ln-legalnotice.html" title="Legal Notice">
 
16
</head>
 
17
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="section" lang="en">
 
18
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
 
19
<a name="function.determineidxnameunique-text-name"></a>1.37.�       determineidxnameunique( text, name )
 
20
      </h2></div></div></div>
 
21
<p>       </p>
 
22
<div class="segmentedlist">
 
23
<div class="title"><strong><span class="title">Function Properties</span></strong></div>
 
24
<div class="seglistitem">
 
25
<div class="seg">
 
26
<strong><span class="segtitle">Language: </span></strong>PLPGSQL</div>
 
27
<div class="seg">
 
28
<strong><span class="segtitle">Return Type: </span></strong>name</div>
 
29
</div>
 
30
</div>
 
31
<p>
 
32
 
 
33
       FUNCTION determineIdxnameUnique (tab_fqname, indexname)
 
34
 
 
35
Given a tablename, tab_fqname, check that the unique index, indexname,
 
36
exists or return the primary key index name for the table.  If there
 
37
is no unique index, it raises an exception.
 
38
        </p>
 
39
<pre class="programlisting">declare
 
40
        p_tab_fqname    alias for $1;
 
41
        v_tab_fqname_quoted     text default '';
 
42
        p_idx_name              alias for $2;
 
43
        v_idxrow                record;
 
44
begin
 
45
        v_tab_fqname_quoted := slon_quote_input(p_tab_fqname);
 
46
        --
 
47
        -- Ensure that the table exists
 
48
        --
 
49
        if (select PGC.relname
 
50
                                from "pg_catalog".pg_class PGC,
 
51
                                        "pg_catalog".pg_namespace PGN
 
52
                                where slon_quote_brute(PGN.nspname) || '.' ||
 
53
                                        slon_quote_brute(PGC.relname) = v_tab_fqname_quoted
 
54
                                        and PGN.oid = PGC.relnamespace) is null then
 
55
                raise exception 'Slony-I: table % not found', v_tab_fqname_quoted;
 
56
        end if;
 
57
 
 
58
        --
 
59
        -- Lookup the tables primary key or the specified unique index
 
60
        --
 
61
        if p_idx_name isnull then
 
62
                select PGXC.relname
 
63
                                into v_idxrow
 
64
                                from "pg_catalog".pg_class PGC,
 
65
                                        "pg_catalog".pg_namespace PGN,
 
66
                                        "pg_catalog".pg_index PGX,
 
67
                                        "pg_catalog".pg_class PGXC
 
68
                                where slon_quote_brute(PGN.nspname) || '.' ||
 
69
                                        slon_quote_brute(PGC.relname) = v_tab_fqname_quoted
 
70
                                        and PGN.oid = PGC.relnamespace
 
71
                                        and PGX.indrelid = PGC.oid
 
72
                                        and PGX.indexrelid = PGXC.oid
 
73
                                        and PGX.indisprimary;
 
74
                if not found then
 
75
                        raise exception 'Slony-I: table % has no primary key',
 
76
                                        v_tab_fqname_quoted;
 
77
                end if;
 
78
        else
 
79
                select PGXC.relname
 
80
                                into v_idxrow
 
81
                                from "pg_catalog".pg_class PGC,
 
82
                                        "pg_catalog".pg_namespace PGN,
 
83
                                        "pg_catalog".pg_index PGX,
 
84
                                        "pg_catalog".pg_class PGXC
 
85
                                where slon_quote_brute(PGN.nspname) || '.' ||
 
86
                                        slon_quote_brute(PGC.relname) = v_tab_fqname_quoted
 
87
                                        and PGN.oid = PGC.relnamespace
 
88
                                        and PGX.indrelid = PGC.oid
 
89
                                        and PGX.indexrelid = PGXC.oid
 
90
                                        and PGX.indisunique
 
91
                                        and slon_quote_brute(PGXC.relname) = slon_quote_input(p_idx_name);
 
92
                if not found then
 
93
                        raise exception 'Slony-I: table % has no unique index %',
 
94
                                        v_tab_fqname_quoted, p_idx_name;
 
95
                end if;
 
96
        end if;
 
97
 
 
98
        --
 
99
        -- Return the found index name
 
100
        --
 
101
        return v_idxrow.relname;
 
102
end;</pre>
 
103
<p>
 
104
      </p>
 
105
</div></body>
 
106
</html>