Your message dated Wed, 27 Sep 2006 10:17:39 -0500
with message-id <[EMAIL PROTECTED]>
and subject line Bug#389715: mysql-query-browser: Cannot edit a table without
primary key
has caused the attached Bug report to be marked as done.
This means that you claim that the problem has been dealt with.
If this is not the case it is now your responsibility to reopen the
Bug report if necessary, and/or fix the problem forthwith.
(NB: If you are a system administrator and have no idea what I am
talking about this indicates a serious mail system misconfiguration
somewhere. Please contact me immediately.)
Debian bug tracking system administrator
(administrator, Debian Bugs database)
--- Begin Message ---
Package: mysql-query-browser
Version: 1.1.6-1sarge0
Severity: normal
If I select rows from a table that has no primary key
button "Start Editing" on the bottom remains shaded (=unclickable).
Gabor
-- System Information:
Debian Release: 3.1
Architecture: i386 (i686)
Kernel: Linux 2.6.17
Locale: LANG=C, LC_CTYPE=C (charmap=ANSI_X3.4-1968)
Versions of packages mysql-query-browser depends on:
ii libart-2.0-2 2.3.17-1 Library of functions for 2D graphi
ii libatk1.0-0 1.8.0-4 The ATK accessibility toolkit
ii libbonobo2-0 2.8.1-2 Bonobo CORBA interfaces library
ii libbonoboui2-0 2.8.1-2 The Bonobo UI library
ii libc6 2.3.2.ds1-22sarge4 GNU C Library: Shared libraries an
ii libgcc1 1:3.4.3-13sarge1 GCC support library
ii libgconf2-4 2.8.1-6 GNOME configuration database syste
ii libglade2-0 1:2.4.2-2 library to load .glade files at ru
ii libglib2.0-0 2.6.4-1 The GLib library of C routines
ii libgnome2-0 2.8.1-2 The GNOME 2 library - runtime file
ii libgnomecanvas2-0 2.8.0-1 A powerful object-oriented display
ii libgnomeprint2.2-0 2.8.2-1.2 The GNOME 2.2 print architecture -
ii libgnomeprintui2.2 2.8.2-2 GNOME 2.2 print architecture User
ii libgnomeui-0 2.8.1-3 The GNOME 2 libraries (User Interf
ii libgnomevfs2-0 2.8.4-4 The GNOME virtual file-system libr
ii libgtk2.0-0 2.6.4-3.1 The GTK+ graphical user interface
ii libgtkhtml3.2-11 3.2.5-1 HTML rendering/editing library - r
ii libgtkmm2.0-1c102 2.2.12-1.1 C++ wrappers for GTK+ 2.0 (shared
ii libice6 4.3.0.dfsg.1-14sarge1 Inter-Client Exchange library
ii libmysqlclient14 4.1.11a-4sarge7 mysql database client library
ii liborbit2 1:2.12.2-1 libraries for ORBit2 - a CORBA ORB
ii libpango1.0-0 1.8.1-1 Layout and rendering of internatio
ii libpcre3 4.5-1.2sarge1 Perl 5 Compatible Regular Expressi
ii libpopt0 1.7-5 lib for parsing cmdline parameters
ii libsigc++-1.2-5c10 1.2.5-4 type-safe Signal Framework for C++
ii libsm6 4.3.0.dfsg.1-14sarge1 X Window System Session Management
ii libstdc++5 1:3.3.5-13 The GNU Standard C++ Library v3
ii libxml2 2.6.16-7 GNOME XML library
ii mysql-query-browse 1.1.6-1sarge0 Architecture independent files for
ii xlibs 4.3.0.dfsg.1-14sarge1 X Keyboard Extension (XKB) configu
ii zlib1g 1:1.2.2-4.sarge.2 compression library - runtime
-- no debconf information
--- End Message ---
--- Begin Message ---
Gabor Kiss wrote:
> Package: mysql-query-browser
> Version: 1.1.6-1sarge0
> Severity: normal
>
> If I select rows from a table that has no primary key
> button "Start Editing" on the bottom remains shaded (=unclickable).
This is not a bug, so I'll close it.
The reason you cannot edit tables with no primary key, is that there is
NO POSSIBLE way for the database to edit single rows and correct rows.
Why? Because there is no guarantee that a given row is unique. For example,
mysql> create table test( a int, b int );
Query OK, 0 rows affected (0.04 sec)
mysql> insert into test values (1,2),(1,3),(2,3),(1,2),(1,2);
Query OK, 5 rows affected (0.02 sec)
Records: 5 Duplicates: 0 Warnings: 0
mysql> select * from test;
+------+------+
| a | b |
+------+------+
| 1 | 2 |
| 1 | 3 |
| 2 | 3 |
| 1 | 2 |
| 1 | 2 |
+------+------+
5 rows in set (0.01 sec)
mysql>
Now, how can I change the 5th row? The row with 1, 2 ?? I cannot do
this! If I try,
mysql> update test set a=2 where a=1 and b=2;
Query OK, 3 rows affected (0.01 sec)
Rows matched: 3 Changed: 3 Warnings: 0
mysql> select * from test;
+------+------+
| a | b |
+------+------+
| 2 | 2 |
| 1 | 3 |
| 2 | 3 |
| 2 | 2 |
| 2 | 2 |
+------+------+
5 rows in set (0.00 sec)
OOPS! Got all of the rows. Ok, so let's try something else,
mysql> update test set a=2 where a=1 and b=2 limit 1;
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0
mysql> select * from test;
+------+------+
| a | b |
+------+------+
| 2 | 2 |
| 1 | 3 |
| 2 | 3 |
| 1 | 2 |
| 1 | 2 |
+------+------+
5 rows in set (0.00 sec)
OOPS! That changed the "first" row. So, how do you fix this? You add a
primary key. Then you can reference that primary key in the update
statement to change a single, distinct row. That's what these keys are
there for.
For example,
mysql> alter table test add column id int auto_increment primary key not
null;
Query OK, 5 rows affected (0.02 sec)
Records: 5 Duplicates: 0 Warnings: 0
mysql> select * from test;
+------+------+----+
| a | b | id |
+------+------+----+
| 1 | 2 | 1 |
| 1 | 3 | 2 |
| 2 | 3 | 3 |
| 1 | 2 | 4 |
| 1 | 2 | 5 |
+------+------+----+
5 rows in set (0.01 sec)
mysql> update test set a=2 where id=4;
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0
mysql> select * from test;
+------+------+----+
| a | b | id |
+------+------+----+
| 1 | 2 | 1 |
| 1 | 3 | 2 |
| 2 | 3 | 3 |
| 2 | 2 | 4 |
| 1 | 2 | 5 |
+------+------+----+
5 rows in set (0.01 sec)
Now, it worked!
Hope this clears things a bit,
Adam
--- End Message ---